]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / thread / backtrace_all / TestBacktraceAll.py
1 """
2 Test regression for Bug 25251.
3 """
4
5 import os, time
6 import unittest2
7 import lldb
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
10
11 class BreakpointAfterJoinTestCase(TestBase):
12
13     mydir = TestBase.compute_mydir(__file__)
14
15     def setUp(self):
16         # Call super's setUp().
17         TestBase.setUp(self)
18         # Find the line number for our breakpoint.
19         self.breakpoint = line_number('ParallelTask.cpp', '// Set breakpoint here')
20     
21     @skipIfTargetAndroid(archs=["arm"]) # The android-arm compiler can't compile the inferior
22                                         # because of an issue around std::future.
23                                         # TODO: Change the test to don't depend on std::future<T>
24     def test(self):
25         """Test breakpoint handling after a thread join."""
26         self.build(dictionary=self.getBuildFlags())
27
28         exe = os.path.join(os.getcwd(), "a.out")
29         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
30
31         # This should create a breakpoint
32         lldbutil.run_break_set_by_file_and_line (self, "ParallelTask.cpp", self.breakpoint, num_expected_locations=-1)
33
34         # The breakpoint list should show 1 location.
35         self.expect("breakpoint list -f", "Breakpoint location shown correctly",
36             substrs = ["1: file = 'ParallelTask.cpp', line = %d, exact_match = 0" % self.breakpoint])
37
38         # Run the program.
39         self.runCmd("run", RUN_SUCCEEDED)
40
41         # The stop reason of the thread should be breakpoint.
42         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
43             substrs = ['stopped',
44                        'stop reason = breakpoint'])
45
46         # This should not result in a segmentation fault
47         self.expect("thread backtrace all", STOPPED_DUE_TO_BREAKPOINT,
48             substrs = ["stop reason = breakpoint 1."])
49
50         # Run to completion
51         self.runCmd("continue")
52
53 if __name__ == '__main__':
54     import atexit
55     lldb.SBDebugger.Initialize()
56     atexit.register(lambda: lldb.SBDebugger.Terminate())
57     unittest2.main()