xref: /llvm-project/lldb/test/API/functionalities/unwind/ehframe/TestEhFrameUnwind.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test that we can backtrace correctly from Non ABI functions on the stack
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class EHFrameBasedUnwind(TestBase):
13    @skipUnlessPlatform(["linux"])
14    @skipIf(archs=["aarch64", "arm", "i386", "i686"])
15    def test(self):
16        """Test that we can backtrace correctly from Non ABI  functions on the stack"""
17        self.build()
18        self.setTearDownCleanup()
19
20        exe = self.getBuildArtifact("a.out")
21        target = self.dbg.CreateTarget(exe)
22
23        self.assertTrue(target, VALID_TARGET)
24
25        lldbutil.run_break_set_by_symbol(self, "func")
26
27        process = target.LaunchSimple(
28            ["abc", "xyz"], None, self.get_process_working_directory()
29        )
30
31        if not process:
32            self.fail("SBTarget.Launch() failed")
33
34        if process.GetState() != lldb.eStateStopped:
35            self.fail(
36                "Process should be in the 'stopped' state, "
37                "instead the actual state is: '%s'"
38                % lldbutil.state_type_to_str(process.GetState())
39            )
40
41        stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
42        self.expect(stacktraces, exe=False, substrs=["(int)argc=3"])
43
44        self.runCmd("thread step-inst")
45
46        stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
47        self.expect(stacktraces, exe=False, substrs=["(int)argc=3"])
48