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