2 Test hardware breakpoints for multiple threads.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
12 # Hardware breakpoints are supported only by platforms mentioned in oslist.
13 @skipUnlessPlatform(oslist=['linux'])
14 class HardwareBreakpointMultiThreadTestCase(TestBase):
15 NO_DEBUG_INFO_TESTCASE = True
17 mydir = TestBase.compute_mydir(__file__)
19 # LLDB supports hardware breakpoints for arm and aarch64 architectures.
20 @skipIf(archs=no_match(['arm', 'aarch64']))
21 def test_hw_break_set_delete_multi_thread(self):
23 self.setTearDownCleanup()
24 self.break_multi_thread('delete')
26 # LLDB supports hardware breakpoints for arm and aarch64 architectures.
27 @skipIf(archs=no_match(['arm', 'aarch64']))
28 def test_hw_break_set_disable_multi_thread(self):
30 self.setTearDownCleanup()
31 self.break_multi_thread('disable')
34 # Call super's setUp().
36 # Our simple source filename.
37 self.source = 'main.cpp'
38 # Find the line number to break inside main().
39 self.first_stop = line_number(
40 self.source, 'Starting thread creation with hardware breakpoint set')
42 def break_multi_thread(self, removal_type):
43 """Test that lldb hardware breakpoints work for multiple threads."""
44 self.runCmd("file " + self.getBuildArtifact("a.out"),
45 CURRENT_EXECUTABLE_SET)
47 # Stop in main before creating any threads.
48 lldbutil.run_break_set_by_file_and_line(
49 self, None, self.first_stop, num_expected_locations=1)
52 self.runCmd("run", RUN_SUCCEEDED)
54 # We should be stopped again due to the breakpoint.
55 # The stop reason of the thread should be breakpoint.
56 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
58 'stop reason = breakpoint'])
60 # Now set a hardware breakpoint in thread function.
61 self.expect("breakpoint set -b hw_break_function --hardware",
67 # We should stop in hw_break_function function for 4 threads.
72 self.runCmd("process continue")
74 # We should be stopped in hw_break_function
75 # The stop reason of the thread should be breakpoint.
76 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
78 'stop reason = breakpoint',
81 # Continue the loop and test that we are stopped 4 times.
84 if removal_type == 'delete':
85 self.runCmd("settings set auto-confirm true")
87 # Now 'breakpoint delete' should just work fine without confirmation
88 # prompt from the command interpreter.
89 self.expect("breakpoint delete",
90 startstr="All breakpoints removed")
92 # Restore the original setting of auto-confirm.
93 self.runCmd("settings clear auto-confirm")
95 elif removal_type == 'disable':
96 self.expect("breakpoint disable",
97 startstr="All breakpoints disabled.")
99 # Continue. Program should exit without stopping anywhere.
100 self.runCmd("process continue")
102 # Process should have stopped and exited with status = 0
103 self.expect("process status", PROCESS_STOPPED,
104 patterns=['Process .* exited with status = 0'])