[all-commits] [llvm/llvm-project] 933ad5: [lldb] Add 'modify' type watchpoints, make it defa...

Jason Molenda via All-commits all-commits at lists.llvm.org
Wed Sep 20 13:42:33 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 933ad5c897ee366759a54869b35b2d7285a92137
  Author: Jason Molenda <jmolenda at apple.com>
  Date:   2023-09-20 (Wed, 20 Sep 2023)

  Changed paths:
    M lldb/bindings/headers.swig
    A lldb/bindings/interface/SBWatchpointOptionsDocstrings.i
    M lldb/bindings/interfaces.swig
    M lldb/include/lldb/API/SBTarget.h
    A lldb/include/lldb/API/SBWatchpointOptions.h
    M lldb/include/lldb/Breakpoint/Watchpoint.h
    M lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
    M lldb/include/lldb/lldb-defines.h
    M lldb/include/lldb/lldb-enumerations.h
    M lldb/include/lldb/lldb-forward.h
    M lldb/source/API/CMakeLists.txt
    M lldb/source/API/SBTarget.cpp
    M lldb/source/API/SBValue.cpp
    M lldb/source/API/SBWatchpoint.cpp
    A lldb/source/API/SBWatchpointOptions.cpp
    M lldb/source/Breakpoint/Watchpoint.cpp
    M lldb/source/Commands/CommandObjectWatchpoint.cpp
    M lldb/source/Interpreter/OptionGroupWatchpoint.cpp
    M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    M lldb/source/Target/StopInfo.cpp
    M lldb/source/Target/Target.cpp
    M lldb/test/API/commands/watchpoints/multiple_hits/main.cpp
    M lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c
    M lldb/test/API/commands/watchpoints/unaligned-watchpoint/main.c
    M lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py
    M lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py
    A lldb/test/API/functionalities/watchpoint/modify-watchpoints/Makefile
    A lldb/test/API/functionalities/watchpoint/modify-watchpoints/TestModifyWatchpoint.py
    A lldb/test/API/functionalities/watchpoint/modify-watchpoints/main.c
    M lldb/test/API/functionalities/watchpoint/unaligned-spanning-two-dwords/TestUnalignedSpanningDwords.py
    M lldb/test/API/python_api/default-constructor/sb_target.py
    M lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

  Log Message:
  [lldb] Add 'modify' type watchpoints, make it default (#66308)

Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This
is exposing the actual behavior of hardware watchpoints. gdb has a
different behavior: a "write" type watchpoint only stops when the
watched memory region *changes*.

A user is using a watchpoint for one of three reasons:

1. Want to find what is changing/corrupting this memory.
2. Want to find what is writing to this memory.
3. Want to find what is reading from this memory.

I believe (1) is the most common use case for watchpoints, and it
currently can't be done in lldb -- the user needs to continue every time
the same value is written to the watched-memory manually. I think gdb's
behavior is the correct one. There are some use cases where a developer
wants to find every function that writes/reads to/from a memory region,
regardless of value, I want to still allow that functionality.

This is also a bit of groundwork for my large watchpoint support
where I will be adding support for AArch64 MASK watchpoints which watch
power-of-2 memory regions. A user might ask to watch 24 bytes, and a
MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is
properly aligned. And we need to ignore writes to the final 8 bytes of
that watched region, and not show those hits to the user.

This patch adds a new 'modify' watchpoint type and it is the default.

Re-landing this patch after addressing testsuite failures found in CI on
Linux, Intel machines, and windows.


More information about the All-commits mailing list