53 lines · python
1"""Test that backtraces can follow cross-object tail calls"""2 3 4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TestCrossObjectTailCalls(TestBase):11 @skipIf(compiler="clang", compiler_version=["<", "22.0"])12 @skipIf(dwarf_version=["<", "4"])13 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")14 def test_cross_object_tail_calls(self):15 self.build()16 exe = self.getBuildArtifact("a.out")17 target = self.dbg.CreateTarget(exe)18 self.assertTrue(target, VALID_TARGET)19 20 lldbutil.run_break_set_by_source_regexp(21 self, "// break here", extra_options="-f Two.c"22 )23 24 process = target.LaunchSimple(None, None, self.get_process_working_directory())25 self.assertTrue(process, PROCESS_IS_VALID)26 27 # We should be stopped in the second dylib.28 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)29 30 # Debug helper:31 # self.runCmd("log enable -f /tmp/lldb.log lldb step")32 # self.runCmd("bt")33 34 # Check that the backtrace is what we expect:35 # frame #0: 0x000000010be73f94 a.out`tail_called_in_b_from_b at Two.c:7:3 [opt]36 # frame #1: 0x000000010be73fa0 a.out`tail_called_in_b_from_a at Two.c:8:1 [opt] [artificial]37 # frame #2: 0x000000010be73f80 a.out`helper_in_a at One.c:11:1 [opt] [artificial]38 # frame #3: 0x000000010be73f79 a.out`tail_called_in_a_from_main at One.c:10:3 [opt]39 # frame #4: 0x000000010be73f60 a.out`helper at main.c:11:3 [opt] [artificial]40 # frame #5: 0x000000010be73f59 a.out`main at main.c:10:3 [opt]41 expected_frames = [42 ("tail_called_in_b_from_b", False),43 ("tail_called_in_b_from_a", True),44 ("helper_in_a", True),45 ("tail_called_in_a_from_main", False),46 ("helper", True),47 ("main", False),48 ]49 for idx, (name, is_artificial) in enumerate(expected_frames):50 frame = thread.GetFrameAtIndex(idx)51 self.assertIn(name, frame.GetDisplayFunctionName())52 self.assertEqual(frame.IsArtificial(), is_artificial)53