Skip to content

[lldb] correct event when removing all watchpoints #125312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

puremourning
Copy link
Contributor

@puremourning puremourning commented Jan 31, 2025

LLDB: correct event when removing all watchpoints

Previously we incorrectly checked for a "breakpoint changed" event
listener removing all watchpoints (e.g. via
SBTarget::DeleteAllWatchpoints()), although we would emit a "watchpoint
changed" event if there were a listener for 'breakpoint changed'.

This meant that we might not emit a "watchpoint changed" event if there
was a listener for this event.

Correct it to check for the "watchpoint changed" event.

Updated regression tests which were also incorrectly peeking for the wrong event type. The 'remove' action actually triggers 2 events which the test didn't allow, so I updated it to allow specifically what was requested.

The test fails (expectedly) at the line following "DeleteAllWatchpoints" prior to this patch, and passes after.

@llvmbot
Copy link
Member

llvmbot commented Jan 31, 2025

@llvm/pr-subscribers-lldb

Author: Ben Jackson (puremourning)

Changes

Previously we incorrectly emitted a "breakpoint changed" event when removing all watchpoints (e.g. via SBTarget::DeleteAllWatchpoints()).

Correct it to emit the "watchpoint changed" event, as that's what "Remove" does and what it checks for being registered.


No test for now. It looks possible to add one though.


Full diff: https://github.com/llvm/llvm-project/pull/125312.diff

1 Files Affected:

  • (modified) lldb/source/Breakpoint/WatchpointList.cpp (+1-1)
diff --git a/lldb/source/Breakpoint/WatchpointList.cpp b/lldb/source/Breakpoint/WatchpointList.cpp
index f7564483e6f1fcd..57369b76c03aff0 100644
--- a/lldb/source/Breakpoint/WatchpointList.cpp
+++ b/lldb/source/Breakpoint/WatchpointList.cpp
@@ -236,7 +236,7 @@ void WatchpointList::RemoveAll(bool notify) {
       wp_collection::iterator pos, end = m_watchpoints.end();
       for (pos = m_watchpoints.begin(); pos != end; ++pos) {
         if ((*pos)->GetTarget().EventTypeHasListeners(
-                Target::eBroadcastBitBreakpointChanged)) {
+                Target::eBroadcastBitWatchpointChanged)) {
           auto data_sp = std::make_shared<Watchpoint::WatchpointEventData>(
               eWatchpointEventTypeRemoved, *pos);
           (*pos)->GetTarget().BroadcastEvent(

@puremourning puremourning force-pushed the lldb-fix-remove-all-event-type branch from c6c6e9b to 0bf7cf4 Compare January 31, 2025 22:45
@JDevlieghere
Copy link
Member

Can you write or modify a test? I glanced over TestWatchpointEvents.py and it looks like it's listening to the wrong bit (even thought the test is passing with your change).

@puremourning
Copy link
Contributor Author

Yes, on it. Sorry I should have marked this PR [wip].

@puremourning puremourning changed the title LLDB: correct event when removing all watchpoints [WIP] LLDB: correct event when removing all watchpoints Feb 1, 2025
Previously we incorrectly checked for a "breakpoint changed" event
listener removing all watchpoints (e.g. via
SBTarget::DeleteAllWatchpoints()), although we would emit a "watchpoint
changed" event if there were a listener for 'breakpoint changed'.

This meant that we might not emit a "watchpoint changed" event if there
was a listener for this event.

Correct it to check for the "watchpoint changed" event.
@puremourning puremourning force-pushed the lldb-fix-remove-all-event-type branch from 0bf7cf4 to 6af277d Compare February 1, 2025 18:27
@puremourning
Copy link
Contributor Author

Done. The test fails (expectedly) at the line following "DeleteAllWatchpoints" prior to this patch, and passes after.

@puremourning puremourning changed the title [WIP] LLDB: correct event when removing all watchpoints LLDB: correct event when removing all watchpoints Feb 1, 2025
@puremourning puremourning changed the title LLDB: correct event when removing all watchpoints [lldb] correct event when removing all watchpoints Feb 1, 2025
Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@JDevlieghere
Copy link
Member

@puremourning Let me know if you need someone to press the Merge button for you.

@puremourning
Copy link
Contributor Author

@puremourning Let me know if you need someone to press the Merge button for you.

Yes please. I don't have commit rights.

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@JDevlieghere JDevlieghere merged commit c26bb4f into llvm:main Feb 3, 2025
7 checks passed
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
LLDB: correct event when removing all watchpoints
    
    Previously we incorrectly checked for a "breakpoint changed" event
    listener removing all watchpoints (e.g. via
SBTarget::DeleteAllWatchpoints()), although we would emit a "watchpoint
    changed" event if there were a listener for 'breakpoint changed'.
    
This meant that we might not emit a "watchpoint changed" event if there
    was a listener for this event.
    
    Correct it to check for the "watchpoint changed" event.


---


Updated regression tests which were also incorrectly peeking for the
wrong event type. The 'remove' action actually triggers 2 events which
the test didn't allow, so I updated it to allow specifically what was
requested.

The test fails (expectedly) at the line following "DeleteAllWatchpoints"
prior to this patch, and passes after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants