[Lldb-commits] [lldb] [LLDB] Support enabling/disabling InstrumentationRuntime plugins during a debug session (PR #190083)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 6 14:39:30 PDT 2026
================
@@ -59,6 +59,42 @@ void InstrumentationRuntime::ModulesDidLoad(
});
}
+bool InstrumentationRuntime::Enable() {
+ if (IsActive())
+ return true;
+
+ // Fast path. During a previous time when the plugin was active the relevant
+ // runtime module was found so we can just activate immediately.
+ // FIXME: What if the module was unloaded via dlclose()?
+ if (GetRuntimeModuleSP()) {
+ Activate();
+ return true;
+ }
+
+ // Slow path. The plugin has never found the relevant runtime module in the
+ // past so pretend the current list of modules in the target were just loaded
+ // to give the plugin a chance to activate.
+ if (ProcessSP process_sp = GetProcessSP()) {
+ ModuleList module_list;
+ // FIXME: Does this need a lock?
----------------
JDevlieghere wrote:
Answer: no
```
void ModuleList::ForEach(
std::function<IterationAction(const ModuleSP &module_sp)> const &callback)
const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
for (const auto &module_sp : m_modules) {
assert(module_sp != nullptr);
if (callback(module_sp) == IterationAction::Stop)
break;
}
}
```
Also, I would use `target.Modules()` with a for loop directly, which does the same thing without the callback.
https://github.com/llvm/llvm-project/pull/190083
More information about the lldb-commits
mailing list