[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:29 PDT 2026
================
@@ -6266,6 +6266,45 @@ Process::GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type) {
return (*pos).second;
}
+bool Process::SetInstrumentationRuntimeEnabled(InstrumentationRuntimeType irt,
+ bool enabled) {
+ assert(IsAlive());
+
+ if (auto instrumentation_runtime = GetInstrumentationRuntime(irt)) {
+ // This process already has an instance of this plugin so just
+ // enable/disable it
+ if (enabled)
+ return instrumentation_runtime->Enable();
+ return instrumentation_runtime->Disable();
+ }
+
+ // There's no instance of this plugin for this process.
+
+ if (!enabled)
+ return true; // nothing to do
+
+ // We need to make an instance of this plugin for this process.
+ // This could happen because `plugin disable instrumentation-runtime.*`
+ // was in `.lldbinit` and so the plugin was never created until the user asked
+ // to enable it now.
+
+ // Create the plugin by finding its create callback and calling it.
+ lldb::InstrumentationRuntimeSP new_plugin = nullptr;
+ for (auto &cbs : PluginManager::GetInstrumentationRuntimeCallbacks()) {
+ InstrumentationRuntimeType other_irt = cbs.get_type_callback();
+ if (other_irt != irt)
+ continue;
+
+ new_plugin = cbs.create_callback(shared_from_this());
+ break;
+ }
+ if (!new_plugin)
+ return false;
+
+ m_instrumentation_runtimes[irt] = new_plugin;
+ return new_plugin->Enable(); // Now try to enable it
----------------
JDevlieghere wrote:
Similar to the periods, please do your own pass over this review to find and remove low value comments like this.
```suggestion
return new_plugin->Enable();
```
https://github.com/llvm/llvm-project/pull/190083
More information about the lldb-commits
mailing list