[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 24 18:19:25 PDT 2024


================
@@ -321,9 +321,14 @@ class LLDB_API SBDebugger {
 
   void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
 
+  void AddDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
+                          void *baton);
+
   void SetDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
                           void *baton);
 
+  void ClearDestroyCallback();
----------------
royitaqi wrote:

> It seems wrong that one client can only remove its destroy callback by removing ones it didn't install.
Makes sense to me.

I think you are suggesting:
* `TToken AddDestroyCallback(callback, baton)`
* `bool RemoveDestroyCallback(TToken token)` - returns success/fail
* No/remove `ClearDestroyCallbacks` - because no one is supposed to clear

Then what should `SetDestroyCallback` be?
* It clears existing callbacks, so I think in this new world this semantics isn't allowed, similar to how `ClearDestroyCallbacks` shouldn't exist.
* ~~That is, unless, we introduce the concept of a client ID, where `SetDestroyCallback` will remove all callbacks from the specified client ID. But then I feel the introduction of the client ID opens up even more questions, and it's not an existing pattern in the Debugger class. So it's probably not a good idea.~~

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


More information about the lldb-commits mailing list