[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

via lldb-commits lldb-commits at lists.llvm.org
Thu May 2 21:43:04 PDT 2024


================
@@ -731,8 +747,11 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::recursive_mutex m_destroy_callback_mutex;
----------------
royitaqi wrote:

> Handling a callback could add or remove other callbacks
IIUC, this answers the "recursive" part of @JDevlieghere 's comment.

> Does this actually need to be thread safe?
I had the same question in my mind when the thread safety requirement was raised. Now I look at it, the only other mutex in the same class is the global debugger list, which does sound important enough to not be messed up.

IMHO, the answer here depends on whether or not we already have a clear future where the class need to be thread safe.  If such future hasn't been aligned, I feel it can be unsafe for now, and we can add thread-safety as one-go once such direction has been aligned. WDYT?

https://github.com/llvm/llvm-project/pull/89868


More information about the lldb-commits mailing list