brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 41cb185 Raw
59 lines · python
1"""Test that backtraces can follow cross-DSO tail calls"""2 3 4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TestCrossDSOTailCalls(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_dso_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        # Register our shared libraries for remote targets so they get21        # automatically uploaded22        environment = self.registerSharedLibrariesWithTarget(target, ["One", "Two"])23 24        lldbutil.run_break_set_by_source_regexp(25            self, "// break here", extra_options="-f Two.c"26        )27 28        process = target.LaunchSimple(29            None, environment, self.get_process_working_directory()30        )31        self.assertTrue(process, PROCESS_IS_VALID)32 33        # We should be stopped in the second dylib.34        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)35 36        # Debug helper:37        # self.runCmd("log enable -f /tmp/lldb.log lldb step")38        # self.runCmd("bt")39 40        # Check that the backtrace is what we expect:41        #  frame #0: 0x000000010d5e5f94 libTwo.dylib`tail_called_in_b_from_b at Two.c:7:3 [opt]42        #  frame #1: 0x000000010d5e5fa0 libTwo.dylib`tail_called_in_b_from_a [opt] [artificial]43        #  frame #2: 0x000000010d5dcf80 libOne.dylib`helper_in_a [opt] [artificial]44        #  frame #3: 0x000000010d5dcf79 libOne.dylib`tail_called_in_a_from_main at One.c:10:3 [opt]45        #  frame #4: 0x000000010d5d3f80 a.out`helper [opt] [artificial]46        #  frame #5: 0x000000010d5d3f79 a.out`main at main.c:10:3 [opt]47        expected_frames = [48            ("tail_called_in_b_from_b", False),49            ("tail_called_in_b_from_a", True),50            ("helper_in_a", True),51            ("tail_called_in_a_from_main", False),52            ("helper", True),53            ("main", False),54        ]55        for idx, (name, is_artificial) in enumerate(expected_frames):56            frame = thread.GetFrameAtIndex(idx)57            self.assertIn(name, frame.GetDisplayFunctionName())58            self.assertEqual(frame.IsArtificial(), is_artificial)59