cce485bd5a5aed84135bc110875f939086a397f5
[openbsd] /
1 """
2 Test that we properly display the backtrace when a noreturn function happens to
3 be at the end of the stack.
4 """
5
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class TestNoreturnModuleEnd(TestBase):
15     NO_DEBUG_INFO_TESTCASE = True
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         super(TestNoreturnModuleEnd, self).setUp()
20         self._initial_platform = lldb.DBG.GetSelectedPlatform()
21
22     def tearDown(self):
23         lldb.DBG.SetSelectedPlatform(self._initial_platform)
24         super(TestNoreturnModuleEnd, self).tearDown()
25
26     def test(self):
27         target = self.dbg.CreateTarget("test.out")
28         process = target.LoadCore("test.core")
29         self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
30         self.assertEqual(process.GetNumThreads(), 1)
31
32         thread = process.GetSelectedThread()
33         self.assertTrue(thread.IsValid())
34
35         backtrace = [
36             ["func2", 3],
37             ["func1", 8],
38             ["_start", 8],
39         ]
40         self.assertEqual(thread.GetNumFrames(), len(backtrace))
41         for i in range(len(backtrace)):
42             frame = thread.GetFrameAtIndex(i)
43             self.assertTrue(frame.IsValid())
44             symbol = frame.GetSymbol()
45             self.assertTrue(symbol.IsValid())
46             self.assertEqual(symbol.GetName(), backtrace[i][0])
47             function_start = symbol.GetStartAddress().GetLoadAddress(target)
48             self.assertEquals(function_start + backtrace[i][1], frame.GetPC())
49
50         self.dbg.DeleteTarget(target)