[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 10 04:05:52 PDT 2024
================
@@ -739,16 +745,29 @@ DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
g_debugger_list_ptr->push_back(debugger_sp);
}
debugger_sp->InstanceInitialize();
+
+ InvokeNotificationCallbacks(debugger_sp, lldb::eDebuggerWillBeCreated);
return debugger_sp;
}
+void Debugger::InvokeNotificationCallbacks(DebuggerSP debugger_sp,
+ lldb::NotificationType notify_type) {
+ std::lock_guard<std::mutex> guard(s_notification_callback_mutex);
+ for (const auto &callback_info : s_notification_callbacks) {
+ if ((callback_info.type & notify_type) == notify_type)
+ callback_info.callback(notify_type, debugger_sp, nullptr,
----------------
labath wrote:
Note this will deadlock if any of the callbacks try to register _another_ callback.
You may want to consider making a copy of the list and iterating over *that* (without holding the mutex).
https://github.com/llvm/llvm-project/pull/111206
More information about the lldb-commits
mailing list