[Lldb-commits] [lldb] [lldb] Expose the Target API lock through the SB API (PR #131404)
Adrian Vogelsgesang via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 20 05:23:38 PDT 2025
================
@@ -0,0 +1,11 @@
+%extend lldb::SBLock {
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ self.Unlock()
----------------
vogelsgesang wrote:
It's a bit unfortunate, that
```
lock = target.AcquireLock();
with lock:
# we are correctly locked here
with lock:
# we are no longer locked here :/
```
does not work as expected.
In Python, the convention seems to be that locks can be locked or unlocked, and entering a `with` scope` acquires the lock. We might want to model this after the Python's [Lock](https://docs.python.org/3/library/threading.html#lock-objects) or [RLock](std::unique_lock) objects, i.e. closer to a `std::unique_lock` than a `std::lock_guard`
WDYT?
https://github.com/llvm/llvm-project/pull/131404
More information about the lldb-commits
mailing list