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