-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AArch64 MASK watchpoint support in debugserver
Add suport for MASK style watchpoints on AArch64 in debugserver on Darwin systems, for watching power-of-2 sized memory ranges. More work needed in lldb before this can be exposed to the user (because they will often try watching memory ranges that are not exactly power-of-2 in size/alignment) but this is the first part of adding that capability. Differential Revision: https://reviews.llvm.org/D149792 rdar://108233371
- Loading branch information
1 parent
4fac08f
commit 2e16e41
Showing
6 changed files
with
217 additions
and
39 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
lldb/test/API/functionalities/watchpoint/large-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 |
59 changes: 59 additions & 0 deletions
59
lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.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,59 @@ | ||
""" | ||
Watch larger-than-8-bytes regions of memory, confirm that | ||
writes to those regions are detected. | ||
""" | ||
|
||
|
||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
class UnalignedWatchpointTestCase(TestBase): | ||
|
||
def continue_and_report_stop_reason(self, process, iter_str): | ||
process.Continue() | ||
self.assertIn(process.GetState(), [lldb.eStateStopped, lldb.eStateExited], | ||
iter_str) | ||
thread = process.GetSelectedThread() | ||
return thread.GetStopReason() | ||
|
||
|
||
NO_DEBUG_INFO_TESTCASE = True | ||
# debugserver on AArch64 has this feature. | ||
@skipIf(archs=no_match(['arm64', 'arm64e', 'aarch64'])) | ||
@skipUnlessDarwin | ||
|
||
# debugserver only gained the ability to watch larger regions | ||
# with this patch. | ||
@skipIfOutOfTreeDebugserver | ||
|
||
def test_large_watchpoint(self): | ||
"""Test watchpoint that covers a large region of memory.""" | ||
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) | ||
|
||
array_addr = frame.GetValueForVariablePath("array").GetValueAsUnsigned() | ||
|
||
# watch 256 uint32_t elements in the middle of the array, | ||
# don't assume that the heap allocated array is aligned | ||
# to a 1024 byte boundary to begin with, force alignment. | ||
wa_256_addr = ((array_addr + 1024) & ~(1024-1)) | ||
err = lldb.SBError() | ||
wp = target.WatchAddress(wa_256_addr, 1024, False, True, err) | ||
self.assertTrue(wp.IsValid()) | ||
self.assertSuccess(err) | ||
|
||
c_count = 0 | ||
reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) | ||
while reason == lldb.eStopReasonWatchpoint: | ||
c_count = c_count + 1 | ||
reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) | ||
self.assertLessEqual(c_count, 16) | ||
|
||
self.assertEqual(c_count, 16) |
16 changes: 16 additions & 0 deletions
16
lldb/test/API/functionalities/watchpoint/large-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,16 @@ | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
int main() { | ||
const int count = 65535; | ||
int *array = (int*) malloc(sizeof (int) * count); | ||
memset (array, 0, count * sizeof (int)); | ||
|
||
puts ("break here"); | ||
|
||
for (int i = 0; i < count - 16; i += 16) | ||
array[i] += 10; | ||
|
||
puts ("done, exiting."); | ||
} |
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