Skip to content

Commit 6179c0e

Browse files
author
Aleksandr Urakov
committed
[Windows] Add support of watchpoints to ProcessWindows
Summary: This patch adds support of watchpoints to the old `ProcessWindows` plugin. The `ProcessWindows` plugin uses the `RegisterContext` to set and reset watchpoints. The `RegisterContext` has some interface to access watchpoints, but it is very limited (e.g. it is impossible to retrieve the last triggered watchpoint with it), that's why I have implemented a slightly different interface in the `RegisterContextWindows`. Moreover, I have made the `ProcessWindows` plugin responsible for search of a vacant watchpoint slot, because watchpoints exist per-process (not per-thread), then we can place the same watchpoint in the same slot in different threads. With this scheme threads don't need to have their own watchpoint lists, and it simplifies identifying of the last triggered watchpoint. Reviewers: asmith, stella.stamenova, amccarth Reviewed By: amccarth Subscribers: labath, zturner, leonid.mashinskiy, abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67168 llvm-svn: 371166
1 parent dfacf88 commit 6179c0e

27 files changed

+259
-158
lines changed

lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ def setUp(self):
3131
self.exe_name = self.testMethodName
3232
self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
3333

34-
@expectedFailureAll(
35-
oslist=["windows"],
36-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3734
# Most of the MIPS boards provide only one H/W watchpoints, and S/W
3835
# watchpoints are not supported yet
3936
@expectedFailureAll(triple=re.compile('^mips'))

lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def setUp(self):
2929
self.exe_name = self.getBuildArtifact('a.out')
3030
self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
3131

32-
@expectedFailureAll(
33-
oslist=["windows"],
34-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3532
@add_test_categories(["basic_process"])
3633
def test_hello_watchpoint_using_watchpoint_set(self):
3734
"""Test a simple sequence of watchpoint creation and watchpoint hit."""

lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class MultipleHitsTestCase(TestBase):
1616
mydir = TestBase.compute_mydir(__file__)
1717
NO_DEBUG_INFO_TESTCASE = True
1818

19-
@expectedFailureAll(
20-
oslist=["windows"],
21-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2219
@skipIf(bugnumber="llvm.org/pr30758", oslist=["linux"], archs=["arm", "aarch64", "powerpc64le"])
2320
@skipIfwatchOS
2421
def test(self):

lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ class WatchpointForMultipleThreadsTestCase(TestBase):
1818
NO_DEBUG_INFO_TESTCASE = True
1919
main_spec = lldb.SBFileSpec("main.cpp", False)
2020

21-
@expectedFailureAll(
22-
oslist=["windows"],
23-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2421
@expectedFailureNetBSD
2522
def test_watchpoint_before_thread_start(self):
2623
"""Test that we can hit a watchpoint we set before starting another thread"""
2724
self.do_watchpoint_test("Before running the thread")
2825

29-
@expectedFailureAll(
30-
oslist=["windows"],
31-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3226
@expectedFailureNetBSD
3327
def test_watchpoint_after_thread_start(self):
3428
"""Test that we can hit a watchpoint we set after starting another thread"""
@@ -66,9 +60,6 @@ def do_watchpoint_test(self, line):
6660
self.expect("watchpoint list -v",
6761
substrs=['hit_count = 1'])
6862

69-
@expectedFailureAll(
70-
oslist=["windows"],
71-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
7263
def test_watchpoint_multiple_threads_wp_set_and_then_delete(self):
7364
"""Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires."""
7465
self.build()

lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class TestStepOverWatchpoint(TestBase):
1919
'aarch64',
2020
'arm'],
2121
bugnumber="llvm.org/pr26031")
22-
@expectedFailureAll(
23-
oslist=["windows"],
24-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2522
# Read-write watchpoints not supported on SystemZ
2623
@expectedFailureAll(archs=['s390x'])
2724
@expectedFailureAll(oslist=["ios", "watchos", "tvos", "bridgeos"], bugnumber="<rdar://problem/34027183>") # watchpoint tests aren't working on arm64

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def setUp(self):
3434
self.exe_name = self.testMethodName
3535
self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
3636

37-
@expectedFailureAll(
38-
oslist=["windows"],
39-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
4037
# Read-write watchpoints not supported on SystemZ
4138
@expectedFailureAll(archs=['s390x'])
4239
def test_rw_watchpoint(self):
@@ -105,9 +102,6 @@ def test_rw_watchpoint(self):
105102
self.expect("watchpoint list -v",
106103
substrs=['hit_count = 2'])
107104

108-
@expectedFailureAll(
109-
oslist=["windows"],
110-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
111105
# Read-write watchpoints not supported on SystemZ
112106
@expectedFailureAll(archs=['s390x'])
113107
def test_rw_watchpoint_delete(self):
@@ -162,9 +156,6 @@ def test_rw_watchpoint_delete(self):
162156
self.expect("process status",
163157
substrs=['exited'])
164158

165-
@expectedFailureAll(
166-
oslist=["windows"],
167-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
168159
# Read-write watchpoints not supported on SystemZ
169160
@expectedFailureAll(archs=['s390x'])
170161
def test_rw_watchpoint_set_ignore_count(self):
@@ -222,9 +213,6 @@ def test_rw_watchpoint_set_ignore_count(self):
222213
self.expect("watchpoint list -v",
223214
substrs=['hit_count = 2', 'ignore_count = 2'])
224215

225-
@expectedFailureAll(
226-
oslist=["windows"],
227-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
228216
# Read-write watchpoints not supported on SystemZ
229217
@expectedFailureAll(archs=['s390x'])
230218
def test_rw_disable_after_first_stop(self):
@@ -292,9 +280,6 @@ def test_rw_disable_after_first_stop(self):
292280
self.expect("watchpoint list -v",
293281
substrs=['hit_count = 1'])
294282

295-
@expectedFailureAll(
296-
oslist=["windows"],
297-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
298283
# Read-write watchpoints not supported on SystemZ
299284
@expectedFailureAll(archs=['s390x'])
300285
def test_rw_disable_then_enable(self):

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ def setUp(self):
3636
archs=["aarch64"],
3737
triple=no_match(".*-android"),
3838
bugnumber="llvm.org/pr27710") # work on android
39-
@expectedFailureAll(
40-
oslist=["windows"],
41-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
4239
@expectedFailureNetBSD
4340
def test_watchpoint_command(self):
4441
"""Test 'watchpoint command'."""
@@ -106,9 +103,6 @@ def test_watchpoint_command(self):
106103
archs=["aarch64"],
107104
triple=no_match(".*-android"),
108105
bugnumber="llvm.org/pr27710") # work on android
109-
@expectedFailureAll(
110-
oslist=["windows"],
111-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
112106
def test_watchpoint_command_can_disable_a_watchpoint(self):
113107
"""Test that 'watchpoint command' action can disable a watchpoint after it is triggered."""
114108
self.build(dictionary=self.d)

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def setUp(self):
3333
self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
3434

3535
@skipIfFreeBSD # timing out on buildbot
36-
@expectedFailureAll(
37-
oslist=["windows"],
38-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3936
@expectedFailureAll(
4037
oslist=["linux"],
4138
archs=["aarch64"],
@@ -105,9 +102,6 @@ def test_watchpoint_command(self):
105102
substrs=['(int32_t)', 'cookie = 777'])
106103

107104
@skipIfFreeBSD # timing out on buildbot
108-
@expectedFailureAll(
109-
oslist=["windows"],
110-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
111105
@expectedFailureAll(
112106
oslist=["linux"],
113107
archs=["aarch64"],

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ def setUp(self):
3636
archs=["aarch64"],
3737
triple=no_match(".*-android"),
3838
bugnumber="llvm.org/pr27710")
39-
@expectedFailureAll(
40-
oslist=["windows"],
41-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
4239
@expectedFailureNetBSD
4340
def test_watchpoint_cond(self):
4441
"""Test watchpoint condition."""

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ def setUp(self):
1515
# Call super's setUp().
1616
TestBase.setUp(self)
1717

18-
@expectedFailureAll(
19-
oslist=["windows"],
20-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2118
def test_disable_works (self):
2219
"""Set a watchpoint, disable it, and make sure it doesn't get hit."""
2320
self.build()
2421
self.do_test(False)
2522

26-
@expectedFailureAll(
27-
oslist=["windows"],
28-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2923
def test_disable_enable_works (self):
3024
"""Set a watchpoint, disable it, and make sure it doesn't get hit."""
3125
self.build()

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def setUp(self):
2525
archs=["aarch64"],
2626
triple=no_match(".*-android"),
2727
bugnumber="llvm.org/pr27710")
28-
@expectedFailureAll(
29-
oslist=["windows"],
30-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3128
def test_with_python_api(self):
3229
"""Test that adding, deleting and modifying watchpoints sends the appropriate events."""
3330
self.build()

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ class TestValueOfVectorVariableTestCase(TestBase):
1515

1616
mydir = TestBase.compute_mydir(__file__)
1717

18-
@expectedFailureAll(
19-
oslist=["windows"],
20-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
2118
def test_value_of_vector_variable_using_watchpoint_set(self):
2219
"""Test verify displayed value of vector variable."""
2320
exe = self.getBuildArtifact("a.out")

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def setUp(self):
3434
'aarch64',
3535
'arm'],
3636
bugnumber="llvm.org/pr26031")
37-
@expectedFailureAll(
38-
oslist=["windows"],
39-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
4037
@expectedFailureNetBSD
4138
def test_watchlocation_using_watchpoint_set(self):
4239
"""Test watching a location with 'watchpoint set expression -w write -s size' option."""

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,18 @@ def setUp(self):
2929
self.exe_name = self.getBuildArtifact("a.out")
3030
self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
3131

32-
@expectedFailureAll(
33-
oslist=["windows"],
34-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3532
# Read-write watchpoints not supported on SystemZ
3633
@expectedFailureAll(archs=['s390x'])
3734
def test_byte_size_watchpoints_with_byte_selection(self):
3835
"""Test to selectively watch different bytes in a 8-byte array."""
3936
self.run_watchpoint_size_test('byteArray', 8, '1')
4037

41-
@expectedFailureAll(
42-
oslist=["windows"],
43-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
4438
# Read-write watchpoints not supported on SystemZ
4539
@expectedFailureAll(archs=['s390x'])
4640
def test_two_byte_watchpoints_with_word_selection(self):
4741
"""Test to selectively watch different words in an 8-byte word array."""
4842
self.run_watchpoint_size_test('wordArray', 4, '2')
4943

50-
@expectedFailureAll(
51-
oslist=["windows"],
52-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
5344
# Read-write watchpoints not supported on SystemZ
5445
@expectedFailureAll(archs=['s390x'])
5546
def test_four_byte_watchpoints_with_dword_selection(self):

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def setUp(self):
2525
self.source, '// Set break point at this line.')
2626

2727
@add_test_categories(['pyapi'])
28-
@expectedFailureAll(
29-
oslist=["windows"],
30-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3128
# Read-write watchpoints not supported on SystemZ
3229
@expectedFailureAll(archs=['s390x'])
3330
def test_watch_val(self):

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def setUp(self):
2525
self.source, '// Set break point at this line.')
2626

2727
@add_test_categories(['pyapi'])
28-
@expectedFailureAll(
29-
oslist=["windows"],
30-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3128
# Read-write watchpoints not supported on SystemZ
3229
@expectedFailureAll(archs=['s390x'])
3330
def test_set_watch_ignore_count(self):

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ def setUp(self):
3030
self.source, '// Set break point at this line.')
3131

3232
@add_test_categories(['pyapi'])
33-
@expectedFailureAll(
34-
oslist=["windows"],
35-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3633
def test_watch_iter(self):
3734
"""Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints."""
3835
self.build()

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def setUp(self):
3636
archs=["aarch64"],
3737
triple=no_match(".*-android"),
3838
bugnumber="llvm.org/pr27710")
39-
@skipIfWindows # Watchpoints not supported on Windows, and this test hangs
4039
def test_watchpoint_cond_api(self):
4140
"""Test watchpoint condition API."""
4241
self.build(dictionary=self.d)

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ def setUp(self):
2828
self.violating_func = "do_bad_thing_with_location"
2929

3030
@add_test_categories(['pyapi'])
31-
@expectedFailureAll(
32-
oslist=["windows"],
33-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3431
@expectedFailureNetBSD
3532
def test_watch_location(self):
3633
"""Exercise SBValue.WatchPointee() API to set a watchpoint."""

lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ def setUp(self):
2727
self.violating_func = "do_bad_thing_with_location"
2828

2929
@add_test_categories(['pyapi'])
30-
@expectedFailureAll(
31-
oslist=["windows"],
32-
bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
3330
@expectedFailureNetBSD
3431
def test_watch_address(self):
3532
"""Exercise SBTarget.WatchAddress() API to set a watchpoint."""

lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ProcessWindowsData {
4141
HANDLE m_initial_stop_event = nullptr;
4242
bool m_initial_stop_received = false;
4343
bool m_stop_at_entry;
44-
std::map<lldb::tid_t, HostThread> m_new_threads;
44+
std::map<lldb::tid_t, lldb::ThreadSP> m_new_threads;
4545
std::set<lldb::tid_t> m_exited_threads;
4646
};
4747

0 commit comments

Comments
 (0)