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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Breakpoint/WatchpointList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,45 @@ def test_with_python_api(self):
'make sure watchpoint condition is "' + condition + '"',
)

def GetWatchpointEvent(self, event_type):
# We added a watchpoint so we should get a watchpoint added event.
event = lldb.SBEvent()
success = self.listener.WaitForEvent(1, event)
self.assertTrue(success, "Successfully got watchpoint event")
self.assertTrue(
lldb.SBWatchpoint.EventIsWatchpointEvent(event),
"Event is a watchpoint event.",
target.DeleteWatchpoint(local_watch.GetID())
self.GetWatchpointEvent(
lldb.eWatchpointEventTypeDisabled, lldb.eWatchpointEventTypeRemoved
)
found_type = lldb.SBWatchpoint.GetWatchpointEventTypeFromEvent(event)
self.assertEqual(
found_type,
event_type,
"Event is not correct type, expected: %d, found: %d"
% (event_type, found_type),

# Re-create it so that we can check DeleteAllWatchpoints
local_watch = local_var.Watch(True, False, True, error)
if not error.Success():
self.fail(
"Failed to make watchpoint for local_var: %s" % (error.GetCString())
)
self.GetWatchpointEvent(lldb.eWatchpointEventTypeAdded)
target.DeleteAllWatchpoints()
self.GetWatchpointEvent(
lldb.eWatchpointEventTypeDisabled, lldb.eWatchpointEventTypeRemoved
)

def GetWatchpointEvent(self, *event_types):
# We added a watchpoint so we should get a watchpoint added event.
event = lldb.SBEvent()
for event_type in event_types:
success = self.listener.WaitForEvent(1, event)
self.assertTrue(success, "Successfully got watchpoint event")
self.assertTrue(
lldb.SBWatchpoint.EventIsWatchpointEvent(event),
"Event is a watchpoint event.",
)
found_type = lldb.SBWatchpoint.GetWatchpointEventTypeFromEvent(event)
self.assertEqual(
found_type,
event_type,
"Event is not correct type, expected: %d, found: %d"
% (event_type, found_type),
)
# There shouldn't be another event waiting around:
found_event = self.listener.PeekAtNextEventForBroadcasterWithType(
self.target_bcast, lldb.SBTarget.eBroadcastBitBreakpointChanged, event
self.target_bcast, lldb.SBTarget.eBroadcastBitWatchpointChanged, event
)
if found_event:
print("Found an event I didn't expect: ", event)
print("Found an event I didn't expect: ", event.GetType())

self.assertTrue(not found_event, "Only one event per change.")
self.assertTrue(not found_event, f"Only expected {len(event_types)} events.")