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