[all-commits] [llvm/llvm-project] fc6b72: [lldb] [mostly NFC] Large WP foundation: Watchpoin...
Jason Molenda via All-commits
all-commits at lists.llvm.org
Mon Nov 27 13:29:14 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fc6b72523f3d73b921690a713e97a433c96066c6
https://github.com/llvm/llvm-project/commit/fc6b72523f3d73b921690a713e97a433c96066c6
Author: Jason Molenda <jmolenda at apple.com>
Date: 2023-11-27 (Mon, 27 Nov 2023)
Changed paths:
M lldb/include/lldb/Breakpoint/BreakpointSite.h
R lldb/include/lldb/Breakpoint/BreakpointSiteList.h
A lldb/include/lldb/Breakpoint/StopPointSiteList.h
M lldb/include/lldb/Breakpoint/Watchpoint.h
A lldb/include/lldb/Breakpoint/WatchpointResource.h
A lldb/include/lldb/Breakpoint/WatchpointResourceList.h
M lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
M lldb/include/lldb/Target/Process.h
M lldb/include/lldb/lldb-defines.h
M lldb/include/lldb/lldb-forward.h
M lldb/include/lldb/lldb-types.h
M lldb/source/API/SBThread.cpp
M lldb/source/API/SBWatchpoint.cpp
M lldb/source/Breakpoint/BreakpointLocation.cpp
M lldb/source/Breakpoint/BreakpointSite.cpp
R lldb/source/Breakpoint/BreakpointSiteList.cpp
M lldb/source/Breakpoint/CMakeLists.txt
A lldb/source/Breakpoint/StopPointSiteList.cpp
M lldb/source/Breakpoint/Watchpoint.cpp
A lldb/source/Breakpoint/WatchpointResource.cpp
A lldb/source/Breakpoint/WatchpointResourceList.cpp
M lldb/source/Commands/CommandObjectProcess.cpp
M lldb/source/Commands/CommandObjectWatchpoint.cpp
M lldb/source/Interpreter/OptionGroupWatchpoint.cpp
M lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
M lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
M lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
M lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
M lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
M lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
M lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
M lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
M lldb/source/Target/Platform.cpp
M lldb/source/Target/Process.cpp
M lldb/source/Target/StackFrameList.cpp
M lldb/source/Target/StopInfo.cpp
M lldb/source/Target/Target.cpp
M lldb/source/Target/ThreadPlanCallFunction.cpp
M lldb/source/Target/ThreadPlanStepOut.cpp
M lldb/source/Target/ThreadPlanStepRange.cpp
M lldb/source/Target/ThreadPlanStepUntil.cpp
M lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
M lldb/test/Shell/Watchpoint/Inputs/val.c
M lldb/test/Shell/Watchpoint/LocalVariableWatchpointDisabler.test
M lldb/test/Shell/Watchpoint/SetErrorCases.test
Log Message:
-----------
[lldb] [mostly NFC] Large WP foundation: WatchpointResources (#68845)
This patch is rearranging code a bit to add WatchpointResources to
Process. A WatchpointResource is meant to represent a hardware
watchpoint register in the inferior process. It has an address, a size,
a type, and a list of Watchpoints that are using this
WatchpointResource.
This current patch doesn't add any of the features of
WatchpointResources that make them interesting -- a user asking to watch
a 24 byte object could watch this with three 8 byte WatchpointResources.
Or a Watchpoint on 1 byte at 0x1002 and a second watchpoint on 1 byte at
0x1003, these must both be served by a single WatchpointResource on that
doubleword at 0x1000 on a 64-bit target, if two hardware watchpoint
registers were used to track these separately, one of them may not be
hit. Or if you have one Watchpoint on a variable with a condition set,
and another Watchpoint on that same variable with a command defined or
different condition, or ignorecount, both of those Watchpoints need to
evaluate their criteria/commands when their WatchpointResource has been
hit.
There's a bit of code movement to rearrange things in the direction I'll
need for implementing this feature, so I want to start with reviewing &
landing this mostly NFC patch and we can focus on the algorithmic
choices about how WatchpointResources are shared and handled as they're
triggeed, separately.
This patch also stops printing "Watchpoint <n> hit: old value: <x>, new
vlaue: <y>" for Read watchpoints. I could make an argument for print
"Watchpoint <n> hit: current value <x>" but the current output doesn't
make any sense, and the user can print the value if they are
particularly interested. Read watchpoints are used primarily to
understand what code is reading a variable.
This patch adds more fallbacks for how to print the objects being
watched if we have types, instead of assuming they are all integral
values, so a struct will print its elements. As large watchpoints are
added, we'll be doing a lot more of those.
To track the WatchpointSP in the WatchpointResources, I changed the
internal API which took a WatchpointSP and devolved it to a Watchpoint*,
which meant touching several different Process files. I removed the
watchpoint code in ProcessKDP which only reported that watchpoints
aren't supported, the base class does that already.
I haven't yet changed how we receive a watchpoint to identify the
WatchpointResource responsible for the trigger, and identify all
Watchpoints that are using this Resource to evaluate their conditions
etc. This is the same work that a BreakpointSite needs to do when it has
been tiggered, where multiple Breakpoints may be at the same address.
There is not yet any printing of the Resources that a Watchpoint is
implemented in terms of ("watchpoint list", or
SBWatchpoint::GetDescription).
"watchpoint set var" and "watchpoint set expression" take a size
argument which was previously 1, 2, 4, or 8 (an enum). I've changed this
to an unsigned int. Most hardware implementations can only watch 1, 2,
4, 8 byte ranges, but with Resources we'll allow a user to ask for
different sized watchpoints and set them in hardware-expressble terms
soon.
I've annotated areas where I know there is work still needed with
LWP_TODO that I'll be working on once this is landed.
I've tested this on aarch64 macOS, aarch64 Linux, and Intel macOS.
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116
More information about the All-commits
mailing list