[Lldb-commits] [lldb] [lldb] Expose the Target API lock through the SB API (PR #131404)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 19 07:50:25 PDT 2025


================
@@ -1692,6 +1692,20 @@ class Target : public std::enable_shared_from_this<Target>,
   }
 };
 
+/// The private implementation backing SBLock.
+struct APILock {
+  APILock(std::recursive_mutex &mutex) : lock(mutex) {}
+  std::lock_guard<std::recursive_mutex> lock;
+};
+
+/// The private implementation used by SBLock to hand out the target API mutex.
+/// It has a TargetSP to ensure the lock cannot outlive the target.
+struct TargetAPILock : public APILock {
----------------
JDevlieghere wrote:

I was indeed looking at (8). But even if it's available it still takes an existing reference/pointer, while what I need is to create a new object the (lock_guard) based on the pointer. Unless you mean changing the shared_ptr in the TargetAPILock to hold onto the mutex that way, which is indeed possible (but doesn't eliminate the class, as I had hoped).

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


More information about the lldb-commits mailing list