File: TestCrossDSOTailCalls.py

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (65 lines) | stat: -rw-r--r-- 2,630 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Test that backtraces can follow cross-DSO tail calls"""



import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestCrossDSOTailCalls(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    def setUp(self):
        TestBase.setUp(self)

    @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_dso_tail_calls(self):
        self.build()
        exe = self.getBuildArtifact("a.out")
        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)

        # Register our shared libraries for remote targets so they get
        # automatically uploaded
        environment = self.registerSharedLibrariesWithTarget(
            target, ['One', 'Two'])

        lldbutil.run_break_set_by_source_regexp(self, '// break here',
                extra_options='-f Two.c')

        process = target.LaunchSimple(
            None, environment, self.get_process_working_directory())
        self.assertTrue(process, PROCESS_IS_VALID)

        # We should be stopped in the second dylib.
        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)

        # Debug helper:
        # self.runCmd("log enable -f /tmp/lldb.log lldb step")
        # self.runCmd("bt")

        # Check that the backtrace is what we expect:
        #  frame #0: 0x000000010d5e5f94 libTwo.dylib`tail_called_in_b_from_b at Two.c:7:3 [opt]
        #  frame #1: 0x000000010d5e5fa0 libTwo.dylib`tail_called_in_b_from_a [opt] [artificial]
        #  frame #2: 0x000000010d5dcf80 libOne.dylib`helper_in_a [opt] [artificial]
        #  frame #3: 0x000000010d5dcf79 libOne.dylib`tail_called_in_a_from_main at One.c:10:3 [opt]
        #  frame #4: 0x000000010d5d3f80 a.out`helper [opt] [artificial]
        #  frame #5: 0x000000010d5d3f79 a.out`main at main.c:10:3 [opt]
        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)