2 Test SB API support for identifying artificial (tail call) frames.
6 import lldbsuite.test.lldbutil as lldbutil
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
10 class TestTailCallFrameSBAPI(TestBase):
11 mydir = TestBase.compute_mydir(__file__)
13 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
14 @skipIf(dwarf_version=['<', '4'])
15 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
16 def test_tail_call_frame_sbapi(self):
21 exe = self.getBuildArtifact("a.out")
23 # Create a target by the debugger.
24 target = self.dbg.CreateTarget(exe)
25 self.assertTrue(target, VALID_TARGET)
27 breakpoint = target.BreakpointCreateBySourceRegex("break here",
28 lldb.SBFileSpec("main.cpp"))
29 self.assertTrue(breakpoint and
30 breakpoint.GetNumLocations() == 1,
33 error = lldb.SBError()
34 launch_info = lldb.SBLaunchInfo(None)
35 process = target.Launch(launch_info, error)
36 self.assertTrue(process, PROCESS_IS_VALID)
38 # Did we hit our breakpoint?
39 threads = lldbutil.get_threads_stopped_at_breakpoint(process,
43 "There should be a thread stopped at our breakpoint")
45 self.assertEqual(breakpoint.GetHitCount(), 1)
49 # Here's what we expect to see in the backtrace:
50 # frame #0: ... a.out`sink() at main.cpp:13:4 [opt]
51 # frame #1: ... a.out`func3() at main.cpp:14:1 [opt] [artificial]
52 # frame #2: ... a.out`func2() at main.cpp:18:62 [opt]
53 # frame #3: ... a.out`func1() at main.cpp:18:85 [opt] [artificial]
54 # frame #4: ... a.out`main at main.cpp:23:3 [opt]
55 names = ["sink", "func3", "func2", "func1", "main"]
56 artificiality = [False, True, False, True, False]
57 for idx, (name, is_artificial) in enumerate(zip(names, artificiality)):
58 frame = thread.GetFrameAtIndex(idx)
60 # Use a relaxed substring check because function dislpay names are
61 # platform-dependent. E.g we see "void sink(void)" on Windows, but
62 # "sink()" on Darwin. This seems like a bug -- just work around it
64 self.assertTrue(name in frame.GetDisplayFunctionName())
65 self.assertEqual(frame.IsArtificial(), is_artificial)