[Lldb-commits] [PATCH] D147820: debugserver: move AArch64 watchpoint traps within a watchpointed region, parse ESR flags and send them to lldb
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 7 15:39:18 PDT 2023
jasonmolenda created this revision.
jasonmolenda added a reviewer: JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added subscribers: omjavaid, atanasyan, kristof.beyls, arichardson, sdardis.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.
Currently on Darwin arm64 systems using debugserver, if you watch a memory region and a large write starts before the watched region, and extends in to the watched region, we will have a watchpoint exception but the address reported may be the start of the access -- before the watched memory range. In this case, lldb will not recognize which watchpoint to disable to step past the watchpoint and execution will stop, leaving the user to disable/stepi/re-enable manually.
This patch takes the trap address (FAR register) and finds the nearest watchpoint if it is not contained in any watched region. It also parses the ESR register flags and if the processor reported the watchpoint index number instead of an address in the FAR register, handle that. Send (1) an address within the watched mem range, (2) the watchpoint hardware index, and (3) the actual trap address which may exist outside a watched mem range to lldb in a `description` string in the stop packet.
Add a test case that has a uint8_t[8] array, watches a one-byte element in that array, and then does a 64-bit write to the entire array - so our FAR address may be the start of the uint8_t[8] array, and confirm that lldb correctly associates this with the watchpoint we set.
This patch depends on https://reviews.llvm.org/D147816 ("Clarify how watchpoint description in stop packets work, fix AArch64 unintended behavior") being present. Without that patch, when we have a trap address outside the range of all watched memory ranges, lldb will silently continue past this watchpoint. Correct behavior on MIPS targets, but not on AArch64.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147820
Files:
lldb/test/API/commands/watchpoints/unaligned-watchpoint/Makefile
lldb/test/API/commands/watchpoints/unaligned-watchpoint/TestUnalignedWatchpoint.py
lldb/test/API/commands/watchpoints/unaligned-watchpoint/main.c
lldb/tools/debugserver/source/DNBBreakpoint.cpp
lldb/tools/debugserver/source/DNBBreakpoint.h
lldb/tools/debugserver/source/DNBDefs.h
lldb/tools/debugserver/source/MacOSX/MachException.cpp
lldb/tools/debugserver/source/MacOSX/MachProcess.h
lldb/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/tools/debugserver/source/RNBRemote.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147820.511809.patch
Type: text/x-patch
Size: 19842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230407/481b62d7/attachment-0001.bin>
More information about the lldb-commits
mailing list