diff options
author | Jason Molenda <jmolenda@apple.com> | 2023-11-15 13:32:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 13:32:42 -0800 |
commit | a3fe9221ab1541a88e784507433cfe7fd13688fd (patch) | |
tree | e6e7a929b248dc8924b316a20e97155c482b2a53 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | f00bade67d3ad9cc5f7cbad226cf4b8bdd0c6524 (diff) | |
download | llvm-a3fe9221ab1541a88e784507433cfe7fd13688fd.zip llvm-a3fe9221ab1541a88e784507433cfe7fd13688fd.tar.gz llvm-a3fe9221ab1541a88e784507433cfe7fd13688fd.tar.bz2 |
Remove hardware index from watchpoints and breakpoints (#72012)
The Watchpoint and Breakpoint objects try to track the hardware index
that was used for them, if they are hardware wp/bp's. The majority of
our debugging goes over the gdb remote serial protocol, and when we set
the watchpoint/breakpoint, there is no (standard) way for the remote
stub to communicate to lldb which hardware index was used. We have an
lldb-extension packet to query the total number of watchpoint registers.
When a watchpoint is hit, there is an lldb extension to the stop reply
packet (documented in lldb-gdb-remote.txt) to describe the watchpoint
including its actual hardware index,
<addr within wp range> <wp hw index> <actual accessed address>
(the third field is specifically needed for MIPS). At this point, if the
stub reported these three fields (the stub is only required to provide
the first), we can know the actual hardware index for this watchpoint.
Breakpoints are worse; there's never any way for us to be notified about
which hardware index was used. Breakpoints got this as a side effect of
inherting from StoppointSite with Watchpoints.
We expose the watchpoint hardware index through "watchpoint list -v" and
through SBWatchpoint::GetHardwareIndex.
With my large watchpoint support, there is no *single* hardware index
that may be used for a watchpoint, it may need multiple resources. Also
I don't see what a user is supposed to do with this information, or an
IDE. Knowing the total number of watchpoint registers on the target, and
knowing how many Watchpoint Resources are currently in use, is helpful.
Knowing how many Watchpoint Resources
a single user-specified watchpoint needed to be implemented is useful.
But knowing which registers were used is an implementation detail and
not available until we hit the watchpoint when using gdb remote serial
protocol.
So given all that, I'm removing watchpoint hardware index numbers. I'm
changing the SB API to always return -1.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f90a561..e653ef5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1789,8 +1789,12 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( // disable/step/re-enable it, so one of the valid watchpoint // addresses should be provided as \a wp_addr. StringExtractor desc_extractor(description.c_str()); + // FIXME NativeThreadLinux::SetStoppedByWatchpoint sends this + // up as + // <address within wp range> <wp hw index> <actual accessed addr> + // but this is not reading the <wp hw index>. Seems like it + // wouldn't work on MIPS, where that third field is important. addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); - uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32); addr_t wp_hit_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); watch_id_t watch_id = LLDB_INVALID_WATCH_ID; bool silently_continue = false; @@ -1807,7 +1811,6 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( if (!wp_sp && wp_addr != LLDB_INVALID_ADDRESS) wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr); if (wp_sp) { - wp_sp->SetHardwareIndex(wp_index); watch_id = wp_sp->GetID(); } if (watch_id == LLDB_INVALID_WATCH_ID) { @@ -2238,17 +2241,13 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { WatchpointSP wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr); - uint32_t wp_index = LLDB_INVALID_INDEX32; - - if (wp_sp) - wp_index = wp_sp->GetHardwareIndex(); // Rewrite gdb standard watch/rwatch/awatch to // "reason:watchpoint" + "description:ADDR", // which is parsed in SetThreadStopInfo. reason = "watchpoint"; StreamString ostr; - ostr.Printf("%" PRIu64 " %" PRIu32, wp_addr, wp_index); + ostr.Printf("%" PRIu64, wp_addr); description = std::string(ostr.GetString()); } else if (key.compare("library") == 0) { auto error = LoadModules(); |