]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / thread / multi_break / TestMultipleBreakpoints.py
1 """
2 Test number of threads.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class MultipleBreakpointTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     def setUp(self):
21         # Call super's setUp().
22         TestBase.setUp(self)
23         # Find the line number for our breakpoint.
24         self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
25
26     @expectedFailureAll(
27         oslist=["linux"],
28         bugnumber="llvm.org/pr15824 thread states not properly maintained")
29     @expectedFailureAll(
30         oslist=lldbplatformutil.getDarwinOSTriples(),
31         bugnumber="llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237>")
32     @expectedFailureAll(
33         oslist=["freebsd"],
34         bugnumber="llvm.org/pr18190 thread states not properly maintained")
35     @expectedFailureAll(
36         oslist=["windows"],
37         bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
38     def test(self):
39         """Test simultaneous breakpoints in multiple threads."""
40         self.build(dictionary=self.getBuildFlags())
41         exe = os.path.join(os.getcwd(), "a.out")
42         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
43
44         # This should create a breakpoint in the main thread.
45         lldbutil.run_break_set_by_file_and_line(
46             self, "main.cpp", self.breakpoint, num_expected_locations=1)
47
48         # Run the program.
49         self.runCmd("run", RUN_SUCCEEDED)
50
51         # The stop reason of the thread should be breakpoint.
52         # The breakpoint may be hit in either thread 2 or thread 3.
53         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
54                     substrs=['stopped',
55                              'stop reason = breakpoint'])
56
57         # Get the target process
58         target = self.dbg.GetSelectedTarget()
59         process = target.GetProcess()
60
61         # Get the number of threads
62         num_threads = process.GetNumThreads()
63
64         # Make sure we see all three threads
65         self.assertTrue(
66             num_threads >= 3,
67             'Number of expected threads and actual threads do not match.')
68
69         # Get the thread objects
70         thread1 = process.GetThreadAtIndex(0)
71         thread2 = process.GetThreadAtIndex(1)
72         thread3 = process.GetThreadAtIndex(2)
73
74         # Make sure both threads are stopped
75         self.assertTrue(
76             thread1.IsStopped(),
77             "Primary thread didn't stop during breakpoint")
78         self.assertTrue(
79             thread2.IsStopped(),
80             "Secondary thread didn't stop during breakpoint")
81         self.assertTrue(
82             thread3.IsStopped(),
83             "Tertiary thread didn't stop during breakpoint")
84
85         # Delete the first breakpoint then continue
86         self.runCmd("breakpoint delete 1")
87
88         # Run to completion
89         self.runCmd("continue")
90
91         # At this point, the inferior process should have exited.
92         self.assertTrue(
93             process.GetState() == lldb.eStateExited,
94             PROCESS_EXITED)