================
@@ -0,0 +1,211 @@
+"""
+Test that the FrameRecognizer for __abort_with_payload
+works properly
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestAbortWithPayload(TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    @skipUnlessDarwin
+    def test_abort_with_payload(self):
+        """There can be many tests in a test case - describe this test here."""
+        self.build()
+        self.abort_with_test(True)
+
+    @skipUnlessDarwin
+    def test_abort_with_reason(self):
+        """There can be many tests in a test case - describe this test here."""
+        self.build()
+        self.abort_with_test(False)
+
+    def setUp(self):
+        # Call super's setUp().
+        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."""
+        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,
+        )
+
+        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",
+        )
+        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()
+        options.SetIncludeRecognizedArguments(True)
+        options.SetIncludeArguments(False)
+        options.SetIncludeLocals(False)
+        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:
+        self.assertEqual(len(arguments), 6, "Got all six values")
+        self.runCmd("frame variable")
----------------
jimingham wrote:

Debugging...

https://github.com/llvm/llvm-project/pull/101365
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to