[Lldb-commits] [lldb] [lldb] Make the PluginManager thread safe (PR #184452)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 3 17:46:36 PST 2026


JDevlieghere wrote:

Your suggestion to use `GetSnapshot` and `std::optional` made me realize that there's an easier way to achieve this, with less locking. It also made me realize that the whole `GetFooAtIndex` thing isn't really resilient against plugins coming and going while you're iterating over that.

If we double down on taking snapshots, we could get rid of this pattern and instead return a snapshot of callbacks. So we could replace patterns like

```
ObjectContainerCreateInstance callback;
for (uint32_t idx = 0;
    (callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(
        idx)) != nullptr;
    ++idx) {
// Call callback();
}
```

with something like

```
for (ObjectContainerCreateInstance callback : PluginManager::GetObjectContainerCreateCallbacks()) {
  // Call callback();
}
```

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


More information about the lldb-commits mailing list