summaryrefslogtreecommitdiff
path: root/lldb/source/Target/Target.cpp
diff options
context:
space:
mode:
authorPiyush Jaiswal <piyushjais98@gmail.com>2025-10-31 13:06:36 -0700
committerGitHub <noreply@github.com>2025-10-31 13:06:36 -0700
commit6bac76bf2714784b6ab9757cdbddbfcd5288a05e (patch)
treeb64adc969be1df27012c25d9fbc8531140a75000 /lldb/source/Target/Target.cpp
parentfe8ab75b408b4a252a1d0233c8ef585360b66490 (diff)
[lldb] Refactor LLDB Breakpoint Event Notifications to centralize and eliminate code duplication (#164739)
### Summary This PR refactors breakpoint event notification in LLDB to centralize and eliminate code duplication. It creates a unified method in the `Target` class for sending breakpoint change events. The new methods check if listeners exist before broadcasting events ### Test <img width="1532" height="76" alt="Screenshot 2025-10-23 at 12 49 31 PM" src="https://github.com/user-attachments/assets/6d6a6da6-9684-463c-aeeb-90663cdbd077" /> --------- Co-authored-by: Piyush Jaiswal <piyushjais@meta.com>
Diffstat (limited to 'lldb/source/Target/Target.cpp')
-rw-r--r--lldb/source/Target/Target.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index d070c3d953d4..1e43094421f0 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Target/Target.h"
+#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointPrecondition.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
@@ -5271,3 +5272,19 @@ void Target::ClearSectionLoadList() { GetSectionLoadList().Clear(); }
void Target::DumpSectionLoadList(Stream &s) {
GetSectionLoadList().Dump(s, this);
}
+
+void Target::NotifyBreakpointChanged(Breakpoint &bp,
+ lldb::BreakpointEventType eventKind) {
+ if (EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) {
+ std::shared_ptr<Breakpoint::BreakpointEventData> data_sp =
+ std::make_shared<Breakpoint::BreakpointEventData>(
+ eventKind, bp.shared_from_this());
+ BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data_sp);
+ }
+}
+
+void Target::NotifyBreakpointChanged(
+ Breakpoint &bp, const lldb::EventDataSP &breakpoint_data_sp) {
+ if (EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+ BroadcastEvent(Target::eBroadcastBitBreakpointChanged, breakpoint_data_sp);
+}