[Lldb-commits] [lldb] Add a StackFrameRecognizer for the Darwin specific abort_with_payload… (PR #101365)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 31 10:12:53 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 80c0e8d572d3b1c34d66faffc42bcfc9432583ec...5b2cf0ab7e382e41ff3dfe88e4d7e35ddc99afd5 lldb/test/API/macosx/abort_with_payload/TestAbortWithPayload.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- TestAbortWithPayload.py 2024-07-31 16:59:31.000000 +0000
+++ TestAbortWithPayload.py 2024-07-31 17:12:24.107113 +0000
@@ -27,37 +27,43 @@
TestBase.setUp(self)
self.main_source_file = lldb.SBFileSpec("main.c")
def abort_with_test(self, with_payload):
"""If with_payload is True, we test the abort_with_payload call,
- if false, we test abort_with_reason."""
+ if false, we test abort_with_reason."""
launch_info = lldb.SBLaunchInfo([])
if not with_payload:
launch_info.SetArguments(["use_reason"], True)
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
- self, "Stop here before abort", self.main_source_file,
- launch_info=launch_info
+ self,
+ "Stop here before abort",
+ self.main_source_file,
+ launch_info=launch_info,
)
frame = thread.GetFrameAtIndex(0)
payload_str_var = frame.FindVariable("payload_string")
self.assertSuccess(payload_str_var.GetError(), "Got payload string var")
payload_var_addr = payload_str_var.unsigned
-
+
payload_size_var = frame.FindVariable("payload_string_len")
self.assertSuccess(payload_size_var.GetError(), "Got payload string len var")
payload_size_val = payload_size_var.unsigned
# Not let it run to crash:
process.Continue()
-
+
# At this point we should have stopped at the internal function.
# Make sure we selected the right thread:
sel_thread = process.GetSelectedThread()
self.assertEqual(thread, sel_thread, "Selected the original thread")
# Make sure the stop reason is right:
- self.assertEqual(thread.GetStopDescription(100), "abort with payload or reason", "Description was right")
+ self.assertEqual(
+ thread.GetStopDescription(100),
+ "abort with payload or reason",
+ "Description was right",
+ )
frame_0 = thread.frames[0]
self.assertEqual(frame_0.name, "__abort_with_payload", "Frame 0 was right")
# Now check the recognized argument values and the ExtendedCrashInformation version:
options = lldb.SBVariablesOptions()
@@ -67,80 +73,136 @@
options.SetIncludeStatics(False)
options.SetIncludeRuntimeSupportValues(False)
arguments = frame_0.GetVariables(options)
- correct_values = { "namespace" : 5,
- "code" : 100,
- "payload_addr" : payload_var_addr,
- "payload_size" : payload_size_val,
- "payload_string" : '"This is a payload that happens to be a string"',
- "reason_string" : '"This is the reason string"',
- "reason_no_quote" : "This is the reason string",
- "flags": 0x85 }
-
- # First check the recognized argument values:
+ correct_values = {
+ "namespace": 5,
+ "code": 100,
+ "payload_addr": payload_var_addr,
+ "payload_size": payload_size_val,
+ "payload_string": '"This is a payload that happens to be a string"',
+ "reason_string": '"This is the reason string"',
+ "reason_no_quote": "This is the reason string",
+ "flags": 0x85,
+ }
+
+ # First check the recognized argument values:
self.assertEqual(len(arguments), 6, "Got all six values")
self.runCmd("frame variable")
self.assertEqual(arguments[0].name, "namespace")
- self.assertEqual(arguments[0].unsigned, correct_values["namespace"], "Namespace value correct")
+ self.assertEqual(
+ arguments[0].unsigned,
+ correct_values["namespace"],
+ "Namespace value correct",
+ )
self.assertEqual(arguments[1].name, "code")
- self.assertEqual(arguments[1].unsigned, correct_values["code"], "code value correct")
+ self.assertEqual(
+ arguments[1].unsigned, correct_values["code"], "code value correct"
+ )
# FIXME: I'm always adding these recognized arguments, but that looks wrong. Should only
# add the payload ones if it is the payload not the reason function.
self.assertEqual(arguments[2].name, "payload_addr")
self.assertEqual(arguments[3].name, "payload_size")
if with_payload:
- self.assertEqual(arguments[2].unsigned, correct_values["payload_addr"], "Payload matched variable address")
+ self.assertEqual(
+ arguments[2].unsigned,
+ correct_values["payload_addr"],
+ "Payload matched variable address",
+ )
# We've made a payload that is a string, try to fetch that:
char_ptr_type = target.FindFirstType("char").GetPointerType()
self.assertTrue(char_ptr_type.IsValid(), "Got char ptr type")
-
+
str_val = arguments[2].Cast(char_ptr_type)
- self.assertEqual(str_val.summary, correct_values["payload_string"], "Got payload string")
-
- self.assertEqual(arguments[3].unsigned, correct_values["payload_size"], "payload size value correct")
+ self.assertEqual(
+ str_val.summary, correct_values["payload_string"], "Got payload string"
+ )
+
+ self.assertEqual(
+ arguments[3].unsigned,
+ correct_values["payload_size"],
+ "payload size value correct",
+ )
else:
- self.assertEqual(arguments[2].unsigned, 0, "Got 0 payload addr for reason call")
- self.assertEqual(arguments[3].unsigned, 0, "Got 0 payload size for reason call")
-
+ self.assertEqual(
+ arguments[2].unsigned, 0, "Got 0 payload addr for reason call"
+ )
+ self.assertEqual(
+ arguments[3].unsigned, 0, "Got 0 payload size for reason call"
+ )
+
self.assertEqual(arguments[4].name, "reason")
- self.assertEqual(arguments[4].summary, correct_values["reason_string"], "Reason value correct")
+ self.assertEqual(
+ arguments[4].summary,
+ correct_values["reason_string"],
+ "Reason value correct",
+ )
self.assertEqual(arguments[5].name, "flags")
- self.assertEqual(arguments[5].unsigned, correct_values["flags"], "Flags value correct")
+ self.assertEqual(
+ arguments[5].unsigned, correct_values["flags"], "Flags value correct"
+ )
# Also check that the same info was stored in the ExtendedCrashInformation dict:
dict = process.GetExtendedCrashInformation()
self.assertTrue(dict.IsValid(), "Got extended crash information dict")
- self.assertEqual(dict.GetType(), lldb.eStructuredDataTypeDictionary, "It is a dictionary")
+ self.assertEqual(
+ dict.GetType(), lldb.eStructuredDataTypeDictionary, "It is a dictionary"
+ )
abort_dict = dict.GetValueForKey("abort_with_payload")
self.assertTrue(abort_dict.IsValid(), "Got an abort_with_payload dict")
- self.assertEqual(abort_dict.GetType(), lldb.eStructuredDataTypeDictionary, "It is a dictionary")
+ self.assertEqual(
+ abort_dict.GetType(),
+ lldb.eStructuredDataTypeDictionary,
+ "It is a dictionary",
+ )
namespace_val = abort_dict.GetValueForKey("namespace")
self.assertTrue(namespace_val.IsValid(), "Got a valid namespace")
- self.assertEqual(namespace_val.GetIntegerValue(0), correct_values["namespace"], "Namespace value correct")
+ self.assertEqual(
+ namespace_val.GetIntegerValue(0),
+ correct_values["namespace"],
+ "Namespace value correct",
+ )
code_val = abort_dict.GetValueForKey("code")
self.assertTrue(code_val.IsValid(), "Got a valid code")
- self.assertEqual(code_val.GetIntegerValue(0), correct_values["code"], "Code value correct")
+ self.assertEqual(
+ code_val.GetIntegerValue(0), correct_values["code"], "Code value correct"
+ )
if with_payload:
addr_val = abort_dict.GetValueForKey("payload_addr")
self.assertTrue(addr_val.IsValid(), "Got a payload_addr")
- self.assertEqual(addr_val.GetIntegerValue(0), correct_values["payload_addr"], "payload_addr right in dictionary")
+ self.assertEqual(
+ addr_val.GetIntegerValue(0),
+ correct_values["payload_addr"],
+ "payload_addr right in dictionary",
+ )
size_val = abort_dict.GetValueForKey("payload_size")
self.assertTrue(size_val.IsValid(), "Got a payload size value")
- self.assertEqual(size_val.GetIntegerValue(0), correct_values["payload_size"], "payload size right in dictionary")
+ self.assertEqual(
+ size_val.GetIntegerValue(0),
+ correct_values["payload_size"],
+ "payload size right in dictionary",
+ )
reason_val = abort_dict.GetValueForKey("reason")
self.assertTrue(reason_val.IsValid(), "Got a reason key")
- self.assertEqual(reason_val.GetStringValue(100), correct_values["reason_no_quote"], "reason right in dictionary")
+ self.assertEqual(
+ reason_val.GetStringValue(100),
+ correct_values["reason_no_quote"],
+ "reason right in dictionary",
+ )
flags_val = abort_dict.GetValueForKey("flags")
self.assertTrue(flags_val.IsValid(), "Got a flags value")
- self.assertEqual(flags_val.GetIntegerValue(0), correct_values["flags"], "flags right in dictionary")
+ self.assertEqual(
+ flags_val.GetIntegerValue(0),
+ correct_values["flags"],
+ "flags right in dictionary",
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/101365
More information about the lldb-commits
mailing list