[Lldb-commits] [lldb] [LLDB][Part 3] Support enabling/disabling InstrumentationRuntime plugins in an debug session (PR #193334)

Dan Liew via lldb-commits lldb-commits at lists.llvm.org
Thu May 14 17:00:37 PDT 2026


================
@@ -6538,6 +6538,58 @@ Process::GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type) {
     return (*pos).second;
 }
 
+llvm::Error
+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 llvm::Error::success();
+
+  // The requested plugin was never instantiated for this process so we need
+  // to create an instance so we can activate it. This can happen if
+  // `plugin disable instrumentation-runtime.*` is executed (e.g. in .lldbinit).
+
+  // Create the plugin by finding its create callback and calling it.
+  lldb::InstrumentationRuntimeSP new_plugin = nullptr;
+  for (auto &cbs : PluginManager::GetInstrumentationRuntimeCallbacks(
+           /*enabled_only=*/false)) {
+    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 llvm::createStringError("failed to create new instance of plugin");
+
+  m_instrumentation_runtimes[irt] = new_plugin;
----------------
delcypher wrote:

I don't know LLDB's architecture well enough to know the answer to that. @jimingham do you know?

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


More information about the lldb-commits mailing list