[Lldb-commits] [PATCH] D143215: Separate Process::GetWatchpointSupportInfo into two methods to get the two separate pieces of information

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 2 13:46:13 PST 2023


jasonmolenda created this revision.
jasonmolenda added a reviewer: jingham.
jasonmolenda added a project: LLDB.
Herald added subscribers: JDevlieghere, kristof.beyls.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

There are two Process:GetWatchpointSupportInfo methods - one which (possibly) returns the number of watchpoints available in the target, and one which (possibly) returns the number of watchpoints in the target & whether watchpoint exceptions are received after the instruction has executed, or before.

The number of watchpoints in the target is determined by sending the `qWatchpointSupportInfo:` packet, an lldb extension.  We don't do anything with this except print it in the watchpoint commands, and return it in SBProcess.  One user-requested watchpoint may need to use multiple actual watchpoints to implement - an unaligned buffer, or a buffer too large for a single watchpoint, so even if the target reports 4 watchpoints available, you may not be able to watch 4 different things simultaneously.

Whether watchpoint exception is received before or after is based on either the `qHostInfo` response from the remote stub (if it includes a k-v like `watchpoint_exceptions_received:before;`, an lldb extension, but maybe all of qHostInfo is now that I think of it), OR it is determined by the target CPU.  realistically, I suspect it's always determined by the target CPU, but who knows, maybe there could exist a cu where it is selectable.

If the number of watchpoints could not be fetched with an lldb-extension packet, `Process:GetWatchpointSupportInfo` would not report whether breakpoints are received before or after the instruction has executed.  This latter is important to know to handle watchpoints; the former doesn't really matter.  So when we connect to a non-lldb-server/debugserver stub, and we are targetting an arm cpu (where watchpoint exceptions are received before the instruction executes), lldb would not correctly disable the watchpoint/insn-step/re-enable the watchpoint (v. StopInfoWatchpoint::ShouldStopSynchronous in StopInfo.cpp), you'd hit the watchpoint exception over and over without advancing.

This patch separates these into two different Process methods, and sets a default of "before" for arm targets if the qHostInfo packet didn't provide any hints.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143215

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/lldb-defines.h
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/StopInfo.cpp
  lldb/source/Target/Target.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143215.494427.patch
Type: text/x-patch
Size: 12913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230202/fe6d9c77/attachment-0001.bin>


More information about the lldb-commits mailing list