61 lines · python
1"""Test that inlined argument variables have their correct location in debuginfo"""2 3import lldb4from lldbsuite.test.decorators import *5from lldbsuite.test.lldbtest import *6from lldbsuite.test import lldbutil7 8 9class TestRedefinitionsInInlines(TestBase):10 # https://github.com/llvm/llvm-project/issues/2821911 @skipIf(compiler="clang", compiler_version=["<", "3.5"])12 def test(self):13 self.source = "main.c"14 self.build()15 (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint(16 self, "first breakpoint", lldb.SBFileSpec(self.source, False)17 )18 19 bp2 = target.BreakpointCreateBySourceRegex(20 "second breakpoint", lldb.SBFileSpec(self.source, False)21 )22 bp3 = target.BreakpointCreateBySourceRegex(23 "third breakpoint", lldb.SBFileSpec(self.source, False)24 )25 26 # When called from main(), test2 is passed in the value of 42 in 'b'27 self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["42"])28 29 process.Continue()30 31 self.assertState(process.GetState(), lldb.eStateStopped)32 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)33 self.assertIsNotNone(thread)34 bp_id = thread.GetStopReasonDataAtIndex(0)35 self.assertEqual(bp_id, bp2.GetID())36 37 self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["42"])38 self.expect("expression c", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["84"])39 40 process.Continue()41 42 # Now we're in test1(), and the first thing it does is call test2(24). "Step in"43 # and check that we have the value 24 as the argument.44 self.assertState(process.GetState(), lldb.eStateStopped)45 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)46 self.assertIsNotNone(thread)47 bp_id = thread.GetStopReasonDataAtIndex(0)48 self.assertEqual(bp_id, bp3.GetID())49 50 frame = thread.GetFrameAtIndex(0)51 self.assertTrue(frame.IsInlined())52 self.assertEqual(frame.GetFunctionName(), "test1")53 54 thread.StepInto()55 56 frame = thread.GetFrameAtIndex(0)57 self.assertTrue(frame.IsInlined())58 self.assertEqual(frame.GetFunctionName(), "test2")59 60 self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["24"])61