"""Test that backtraces can follow cross-object tail calls"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCrossObjectTailCalls(TestBase):
@skipIf(compiler="clang", compiler_version=["<", "10.0"])
@skipIf(dwarf_version=["<", "4"])
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
@expectedFailureAll(archs=["arm", "aarch64"], bugnumber="llvm.org/PR44561")
def test_cross_object_tail_calls(self):
self.build()
exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
lldbutil.run_break_set_by_source_regexp(
self, "// break here", extra_options="-f Two.c"
)
process = target.LaunchSimple(None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
expected_frames = [
("tail_called_in_b_from_b", False),
("tail_called_in_b_from_a", True),
("helper_in_a", True),
("tail_called_in_a_from_main", False),
("helper", True),
("main", False),
]
for idx, (name, is_artificial) in enumerate(expected_frames):
frame = thread.GetFrameAtIndex(idx)
self.assertIn(name, frame.GetDisplayFunctionName())
self.assertEqual(frame.IsArtificial(), is_artificial)