-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AArch64 debugserver parse ESR register for watchpoints
Have debugserver parse the watchpoint flags out of the exception syndrome register when we get a watchpoint mach exception. Relay those fields up to lldb in the stop reply packet, if the watchpoint number was reported by the hardware, use the address from that as the watchpoint address. Change how watchpoints are reported to lldb from using the mach exception data, to using the `reason:watchpoint` and `description:asciihex` method that lldb-server uses, which can relay the actual trap address as well as the address of a watched memory region responsible for the trap, so lldb can step past it. Have debugserver look for the nearest watchpoint that it has set when it gets a watchpoint trap, so accesses that are reported as starting before the watched region are associated with the correct watchpoint to lldb. Add a test case for this specific issue. Differential Revision: https://reviews.llvm.org/D147820 rdar://83996471
- Loading branch information
1 parent
9683d2a
commit e76cfac
Showing
10 changed files
with
362 additions
and
2 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
lldb/test/API/commands/watchpoints/unaligned-watchpoint/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
55 changes: 55 additions & 0 deletions
55
lldb/test/API/commands/watchpoints/unaligned-watchpoint/TestUnalignedWatchpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Watch one byte in the middle of a doubleword, mutate the | ||
entire doubleword including the watched byte. On AArch64 | ||
the trap address is probably the start of the doubleword, | ||
instead of the address of our watched byte. Test that lldb | ||
correctly associates this watchpoint trap with our watchpoint. | ||
""" | ||
|
||
|
||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class UnalignedWatchpointTestCase(TestBase): | ||
NO_DEBUG_INFO_TESTCASE = True | ||
@skipIfOutOfTreeDebugserver | ||
def test_unaligned_watchpoint(self): | ||
"""Test an unaligned watchpoint triggered by a larger aligned write.""" | ||
self.build() | ||
self.main_source_file = lldb.SBFileSpec("main.c") | ||
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, | ||
"break here", self.main_source_file) | ||
|
||
frame = thread.GetFrameAtIndex(0) | ||
|
||
self.expect("watchpoint set variable a.buf[2]") | ||
|
||
self.runCmd("process continue") | ||
|
||
# We should be stopped again due to the watchpoint (write type), but | ||
# only once. The stop reason of the thread should be watchpoint. | ||
self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, | ||
substrs=['stopped', | ||
'stop reason = watchpoint']) | ||
|
||
# Use the '-v' option to do verbose listing of the watchpoint. | ||
# The hit count should now be 1. | ||
self.expect("watchpoint list -v", | ||
substrs=['hit_count = 1']) | ||
|
||
self.runCmd("process continue") | ||
|
||
# We should be stopped again due to the watchpoint (write type), but | ||
# only once. The stop reason of the thread should be watchpoint. | ||
self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, | ||
substrs=['stopped', | ||
'stop reason = watchpoint']) | ||
|
||
# Use the '-v' option to do verbose listing of the watchpoint. | ||
# The hit count should now be 1. | ||
self.expect("watchpoint list -v", | ||
substrs=['hit_count = 2']) |
13 changes: 13 additions & 0 deletions
13
lldb/test/API/commands/watchpoints/unaligned-watchpoint/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
int main() { | ||
union { | ||
uint8_t buf[8]; | ||
uint64_t val; | ||
} a; | ||
a.val = 0; // break here | ||
for (int i = 0; i < 5; i++) { | ||
a.val = i; | ||
printf("a.val is %lu\n", a.val); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.