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