1 """Test that backtraces can follow cross-DSO tail calls"""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class TestCrossDSOTailCalls(TestBase
):
11 @skipIf(compiler
="clang", compiler_version
=["<", "10.0"])
12 @skipIf(dwarf_version
=["<", "4"])
13 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr26265")
14 @expectedFailureAll(archs
=["arm", "aarch64"], bugnumber
="llvm.org/PR44561")
15 def test_cross_dso_tail_calls(self
):
17 exe
= self
.getBuildArtifact("a.out")
18 target
= self
.dbg
.CreateTarget(exe
)
19 self
.assertTrue(target
, VALID_TARGET
)
21 # Register our shared libraries for remote targets so they get
22 # automatically uploaded
23 environment
= self
.registerSharedLibrariesWithTarget(target
, ["One", "Two"])
25 lldbutil
.run_break_set_by_source_regexp(
26 self
, "// break here", extra_options
="-f Two.c"
29 process
= target
.LaunchSimple(
30 None, environment
, self
.get_process_working_directory()
32 self
.assertTrue(process
, PROCESS_IS_VALID
)
34 # We should be stopped in the second dylib.
35 thread
= lldbutil
.get_stopped_thread(process
, lldb
.eStopReasonBreakpoint
)
38 # self.runCmd("log enable -f /tmp/lldb.log lldb step")
41 # Check that the backtrace is what we expect:
42 # frame #0: 0x000000010d5e5f94 libTwo.dylib`tail_called_in_b_from_b at Two.c:7:3 [opt]
43 # frame #1: 0x000000010d5e5fa0 libTwo.dylib`tail_called_in_b_from_a [opt] [artificial]
44 # frame #2: 0x000000010d5dcf80 libOne.dylib`helper_in_a [opt] [artificial]
45 # frame #3: 0x000000010d5dcf79 libOne.dylib`tail_called_in_a_from_main at One.c:10:3 [opt]
46 # frame #4: 0x000000010d5d3f80 a.out`helper [opt] [artificial]
47 # frame #5: 0x000000010d5d3f79 a.out`main at main.c:10:3 [opt]
49 ("tail_called_in_b_from_b", False),
50 ("tail_called_in_b_from_a", True),
51 ("helper_in_a", True),
52 ("tail_called_in_a_from_main", False),
56 for idx
, (name
, is_artificial
) in enumerate(expected_frames
):
57 frame
= thread
.GetFrameAtIndex(idx
)
58 self
.assertIn(name
, frame
.GetDisplayFunctionName())
59 self
.assertEqual(frame
.IsArtificial(), is_artificial
)