jimingham 85d94e1714
Make StopInfoMachException return the right data. (#180088)
When I changed lldb so that the StopInfo's compute their own stop reason
data (before it was oddly done in SBThread::GetStopReasonData...) I
didn't notice that StopInfoMachException was relying on that routine's
default of returning the Value as the 0th exception data, and didn't
actually return its own data.
This fixes that, and makes us report the exception type, and the code
and subcode if the exception has them. I also added a test for this.

rdar://169755672
2026-02-06 11:27:33 -08:00

37 lines
1.2 KiB
Python

"""
Test that we get the type code and subcode for MachExceptions
"""
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
class TestMachExceptionData(TestBase):
NO_DEBUG_INFO_TESTCASE = True
@skipUnlessDarwin
def test_exc_bad_access(self):
"""Test that we get type 1, code 1 and the right address for
a EXC_BAD_ACCESS mach exception."""
self.build()
self.main_source_file = lldb.SBFileSpec("main.c")
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "Set a breakpoint here", self.main_source_file
)
# Now continue and we should crash:
process.Continue()
self.assertEqual(
lldb.eStopReasonException,
thread.GetStopReason(),
"Got the right stop reason",
)
self.assertEqual(thread.GetStopReasonDataCount(), 3, "Got all the codes")
self.assertEqual(thread.stop_reason_data[0], 1, "1 is EXC_BAD_ACCESS")
self.assertEqual(thread.stop_reason_data[1], 1, "1 is 'access invalid memory'")
self.assertEqual(thread.stop_reason_data[2], 0x400, "That's the bad address")