https://github.com/dmpots updated https://github.com/llvm/llvm-project/pull/143970
>From 10f527ddd5b3defc3e7ceef8c5a00ffba9f77b74 Mon Sep 17 00:00:00 2001 From: David Peixotto <p...@meta.com> Date: Thu, 12 Jun 2025 11:17:53 -0700 Subject: [PATCH 1/4] Use PluginInstances instead of vector for Architecuture plugins This was the only plugin type that was not using the PluginInstance wrapper. It needs to use the PluginInstances to hook into the enable/disable support. --- lldb/source/Core/PluginManager.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 5d44434033c55..07bbc332b5d10 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -407,7 +407,7 @@ ABICreateInstance PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) { #pragma mark Architecture typedef PluginInstance<ArchitectureCreateInstance> ArchitectureInstance; -typedef std::vector<ArchitectureInstance> ArchitectureInstances; +typedef PluginInstances<ArchitectureInstance> ArchitectureInstances; static ArchitectureInstances &GetArchitectureInstances() { static ArchitectureInstances g_instances; @@ -417,25 +417,18 @@ static ArchitectureInstances &GetArchitectureInstances() { void PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ArchitectureCreateInstance create_callback) { - GetArchitectureInstances().push_back({name, description, create_callback}); + GetArchitectureInstances().RegisterPlugin(name, description, create_callback); } void PluginManager::UnregisterPlugin( ArchitectureCreateInstance create_callback) { auto &instances = GetArchitectureInstances(); - - for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) { - if (pos->create_callback == create_callback) { - instances.erase(pos); - return; - } - } - llvm_unreachable("Plugin not found"); + instances.UnregisterPlugin(create_callback); } std::unique_ptr<Architecture> PluginManager::CreateArchitectureInstance(const ArchSpec &arch) { - for (const auto &instances : GetArchitectureInstances()) { + for (const auto &instances : GetArchitectureInstances().GetSnapshot()) { if (auto plugin_up = instances.create_callback(arch)) return plugin_up; } >From 07e945682c32e0946d5fe7017ae8d90152136a87 Mon Sep 17 00:00:00 2001 From: David Peixotto <p...@meta.com> Date: Wed, 11 Jun 2025 21:49:39 -0700 Subject: [PATCH 2/4] [lldb] Add support to list/enable/disable remaining plugin types. In #134418 we added support to list/enable/disable SystemRuntime and InstrumentationRuntime plugins. We limited it to those two plugin types to flesh out the idea with a smaller change. This PR adds support for the remaining plugin types. We now support all the plugins that can be registered directly with the plugin manager. Plugins that are added by loading shared objects are still not supported. --- lldb/include/lldb/Core/PluginManager.h | 108 ++++- lldb/source/Core/PluginManager.cpp | 426 ++++++++++++++++-- lldb/test/API/commands/plugin/TestPlugin.py | 62 +++ .../Shell/Commands/command-plugin-list.test | 4 +- 4 files changed, 560 insertions(+), 40 deletions(-) create mode 100644 lldb/test/API/commands/plugin/TestPlugin.py diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index e7b1691031111..1d7c976f3c382 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -236,12 +236,6 @@ class PluginManager { static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx); - static std::vector<RegisteredPluginInfo> GetSystemRuntimePluginInfo(); - - // Modify the enabled state of a SystemRuntime plugin. - // Returns false if the plugin name is not found. - static bool SetSystemRuntimePluginEnabled(llvm::StringRef name, bool enabled); - // ObjectFile static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, @@ -549,12 +543,6 @@ class PluginManager { static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx); - static std::vector<RegisteredPluginInfo> - GetInstrumentationRuntimePluginInfo(); - - static bool SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, - bool enabled); - // TypeSystem static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, TypeSystemCreateInstance create_callback, @@ -690,6 +678,102 @@ class PluginManager { static bool CreateSettingForCPlusPlusLanguagePlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property); + + // + // Plugin Info+Enable Declarations + // + static std::vector<RegisteredPluginInfo> GetABIPluginInfo(); + static bool SetABIPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetArchitecturePluginInfo(); + static bool SetArchitecturePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetDisassemblerPluginInfo(); + static bool SetDisassemblerPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetDynamicLoaderPluginInfo(); + static bool SetDynamicLoaderPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetEmulateInstructionPluginInfo(); + static bool SetEmulateInstructionPluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> + GetInstrumentationRuntimePluginInfo(); + static bool SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetJITLoaderPluginInfo(); + static bool SetJITLoaderPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetLanguagePluginInfo(); + static bool SetLanguagePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetLanguageRuntimePluginInfo(); + static bool SetLanguageRuntimePluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetMemoryHistoryPluginInfo(); + static bool SetMemoryHistoryPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetObjectContainerPluginInfo(); + static bool SetObjectContainerPluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetObjectFilePluginInfo(); + static bool SetObjectFilePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetOperatingSystemPluginInfo(); + static bool SetOperatingSystemPluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetPlatformPluginInfo(); + static bool SetPlatformPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetProcessPluginInfo(); + static bool SetProcessPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetREPLPluginInfo(); + static bool SetREPLPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetRegisterTypeBuilderPluginInfo(); + static bool SetRegisterTypeBuilderPluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetScriptInterpreterPluginInfo(); + static bool SetScriptInterpreterPluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetScriptedInterfacePluginInfo(); + static bool SetScriptedInterfacePluginEnabled(llvm::StringRef name, + bool enable); + + static std::vector<RegisteredPluginInfo> GetStructuredDataPluginInfo(); + static bool SetStructuredDataPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetSymbolFilePluginInfo(); + static bool SetSymbolFilePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetSymbolLocatorPluginInfo(); + static bool SetSymbolLocatorPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetSymbolVendorPluginInfo(); + static bool SetSymbolVendorPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetSystemRuntimePluginInfo(); + static bool SetSystemRuntimePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetTracePluginInfo(); + static bool SetTracePluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetTraceExporterPluginInfo(); + static bool SetTraceExporterPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetTypeSystemPluginInfo(); + static bool SetTypeSystemPluginEnabled(llvm::StringRef name, bool enable); + + static std::vector<RegisteredPluginInfo> GetUnwindAssemblyPluginInfo(); + static bool SetUnwindAssemblyPluginEnabled(llvm::StringRef name, bool enable); }; } // namespace lldb_private diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 07bbc332b5d10..dfa865929b64f 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -182,14 +182,176 @@ void PluginManager::Terminate() { } llvm::ArrayRef<PluginNamespace> PluginManager::GetPluginNamespaces() { - // Currently supported set of plugin namespaces. This will be expanded - // over time. static PluginNamespace PluginNamespaces[] = { - {"system-runtime", PluginManager::GetSystemRuntimePluginInfo, - PluginManager::SetSystemRuntimePluginEnabled}, - {"instrumentation-runtime", - PluginManager::GetInstrumentationRuntimePluginInfo, - PluginManager::SetInstrumentationRuntimePluginEnabled}}; + + { + "abi", + PluginManager::GetABIPluginInfo, + PluginManager::SetABIPluginEnabled, + }, + + { + "architecture", + PluginManager::GetArchitecturePluginInfo, + PluginManager::SetArchitecturePluginEnabled, + }, + + { + "disassembler", + PluginManager::GetDisassemblerPluginInfo, + PluginManager::SetDisassemblerPluginEnabled, + }, + + { + "dynamic-loader", + PluginManager::GetDynamicLoaderPluginInfo, + PluginManager::SetDynamicLoaderPluginEnabled, + }, + + { + "emulate-instruction", + PluginManager::GetEmulateInstructionPluginInfo, + PluginManager::SetEmulateInstructionPluginEnabled, + }, + + { + "instrumentation-runtime", + PluginManager::GetInstrumentationRuntimePluginInfo, + PluginManager::SetInstrumentationRuntimePluginEnabled, + }, + + { + "jit-loader", + PluginManager::GetJITLoaderPluginInfo, + PluginManager::SetJITLoaderPluginEnabled, + }, + + { + "language", + PluginManager::GetLanguagePluginInfo, + PluginManager::SetLanguagePluginEnabled, + }, + + { + "language-runtime", + PluginManager::GetLanguageRuntimePluginInfo, + PluginManager::SetLanguageRuntimePluginEnabled, + }, + + { + "memory-history", + PluginManager::GetMemoryHistoryPluginInfo, + PluginManager::SetMemoryHistoryPluginEnabled, + }, + + { + "object-container", + PluginManager::GetObjectContainerPluginInfo, + PluginManager::SetObjectContainerPluginEnabled, + }, + + { + "object-file", + PluginManager::GetObjectFilePluginInfo, + PluginManager::SetObjectFilePluginEnabled, + }, + + { + "operating-system", + PluginManager::GetOperatingSystemPluginInfo, + PluginManager::SetOperatingSystemPluginEnabled, + }, + + { + "platform", + PluginManager::GetPlatformPluginInfo, + PluginManager::SetPlatformPluginEnabled, + }, + + { + "process", + PluginManager::GetProcessPluginInfo, + PluginManager::SetProcessPluginEnabled, + }, + + { + "repl", + PluginManager::GetREPLPluginInfo, + PluginManager::SetREPLPluginEnabled, + }, + + { + "register-type-builder", + PluginManager::GetRegisterTypeBuilderPluginInfo, + PluginManager::SetRegisterTypeBuilderPluginEnabled, + }, + + { + "script-interpreter", + PluginManager::GetScriptInterpreterPluginInfo, + PluginManager::SetScriptInterpreterPluginEnabled, + }, + + { + "scripted-interface", + PluginManager::GetScriptedInterfacePluginInfo, + PluginManager::SetScriptedInterfacePluginEnabled, + }, + + { + "structured-data", + PluginManager::GetStructuredDataPluginInfo, + PluginManager::SetStructuredDataPluginEnabled, + }, + + { + "symbol-file", + PluginManager::GetSymbolFilePluginInfo, + PluginManager::SetSymbolFilePluginEnabled, + }, + + { + "symbol-locator", + PluginManager::GetSymbolLocatorPluginInfo, + PluginManager::SetSymbolLocatorPluginEnabled, + }, + + { + "symbol-vendor", + PluginManager::GetSymbolVendorPluginInfo, + PluginManager::SetSymbolVendorPluginEnabled, + }, + + { + "system-runtime", + PluginManager::GetSystemRuntimePluginInfo, + PluginManager::SetSystemRuntimePluginEnabled, + }, + + { + "trace", + PluginManager::GetTracePluginInfo, + PluginManager::SetTracePluginEnabled, + }, + + { + "trace-exporter", + PluginManager::GetTraceExporterPluginInfo, + PluginManager::SetTraceExporterPluginEnabled, + }, + + { + "type-system", + PluginManager::GetTypeSystemPluginInfo, + PluginManager::SetTypeSystemPluginEnabled, + }, + + { + "unwind-assembly", + PluginManager::GetUnwindAssemblyPluginInfo, + PluginManager::SetUnwindAssemblyPluginEnabled, + }, + }; return PluginNamespaces; } @@ -711,15 +873,6 @@ PluginManager::GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx) { return GetSystemRuntimeInstances().GetCallbackAtIndex(idx); } -std::vector<RegisteredPluginInfo> PluginManager::GetSystemRuntimePluginInfo() { - return GetSystemRuntimeInstances().GetPluginInfoForAllInstances(); -} - -bool PluginManager::SetSystemRuntimePluginEnabled(llvm::StringRef name, - bool enable) { - return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable); -} - #pragma mark ObjectFile struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> { @@ -1556,16 +1709,6 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) { return GetInstrumentationRuntimeInstances().GetCallbackAtIndex(idx); } -std::vector<RegisteredPluginInfo> -PluginManager::GetInstrumentationRuntimePluginInfo() { - return GetInstrumentationRuntimeInstances().GetPluginInfoForAllInstances(); -} - -bool PluginManager::SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, - bool enable) { - return GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable); -} - #pragma mark TypeSystem struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> { @@ -2050,3 +2193,234 @@ bool PluginManager::CreateSettingForCPlusPlusLanguagePlugin( "Settings for CPlusPlus language plug-ins", properties_sp, description, is_global_property); } + +// +// Plugin Info+Enable Implementations +// +std::vector<RegisteredPluginInfo> PluginManager::GetABIPluginInfo() { + return GetABIInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetABIPluginEnabled(llvm::StringRef name, bool enable) { + return GetABIInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetArchitecturePluginInfo() { + return GetArchitectureInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetArchitecturePluginEnabled(llvm::StringRef name, + bool enable) { + return GetArchitectureInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetDisassemblerPluginInfo() { + return GetDisassemblerInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetDisassemblerPluginEnabled(llvm::StringRef name, + bool enable) { + return GetDisassemblerInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetDynamicLoaderPluginInfo() { + return GetDynamicLoaderInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetDynamicLoaderPluginEnabled(llvm::StringRef name, + bool enable) { + return GetDynamicLoaderInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetEmulateInstructionPluginInfo() { + return GetEmulateInstructionInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetEmulateInstructionPluginEnabled(llvm::StringRef name, + bool enable) { + return GetEmulateInstructionInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetInstrumentationRuntimePluginInfo() { + return GetInstrumentationRuntimeInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetInstrumentationRuntimePluginEnabled(llvm::StringRef name, + bool enable) { + return GetInstrumentationRuntimeInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetJITLoaderPluginInfo() { + return GetJITLoaderInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetJITLoaderPluginEnabled(llvm::StringRef name, + bool enable) { + return GetJITLoaderInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetLanguagePluginInfo() { + return GetLanguageInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetLanguagePluginEnabled(llvm::StringRef name, + bool enable) { + return GetLanguageInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetLanguageRuntimePluginInfo() { + return GetLanguageRuntimeInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetLanguageRuntimePluginEnabled(llvm::StringRef name, + bool enable) { + return GetLanguageRuntimeInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetMemoryHistoryPluginInfo() { + return GetMemoryHistoryInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetMemoryHistoryPluginEnabled(llvm::StringRef name, + bool enable) { + return GetMemoryHistoryInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetObjectContainerPluginInfo() { + return GetObjectContainerInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetObjectContainerPluginEnabled(llvm::StringRef name, + bool enable) { + return GetObjectContainerInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetObjectFilePluginInfo() { + return GetObjectFileInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetObjectFilePluginEnabled(llvm::StringRef name, + bool enable) { + return GetObjectFileInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetOperatingSystemPluginInfo() { + return GetOperatingSystemInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetOperatingSystemPluginEnabled(llvm::StringRef name, + bool enable) { + return GetOperatingSystemInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetPlatformPluginInfo() { + return GetPlatformInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetPlatformPluginEnabled(llvm::StringRef name, + bool enable) { + return GetPlatformInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetProcessPluginInfo() { + return GetProcessInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetProcessPluginEnabled(llvm::StringRef name, bool enable) { + return GetProcessInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetREPLPluginInfo() { + return GetREPLInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetREPLPluginEnabled(llvm::StringRef name, bool enable) { + return GetREPLInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetRegisterTypeBuilderPluginInfo() { + return GetRegisterTypeBuilderInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetRegisterTypeBuilderPluginEnabled(llvm::StringRef name, + bool enable) { + return GetRegisterTypeBuilderInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetScriptInterpreterPluginInfo() { + return GetScriptInterpreterInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetScriptInterpreterPluginEnabled(llvm::StringRef name, + bool enable) { + return GetScriptInterpreterInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> +PluginManager::GetScriptedInterfacePluginInfo() { + return GetScriptedInterfaceInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetScriptedInterfacePluginEnabled(llvm::StringRef name, + bool enable) { + return GetScriptedInterfaceInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetStructuredDataPluginInfo() { + return GetStructuredDataPluginInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetStructuredDataPluginEnabled(llvm::StringRef name, + bool enable) { + return GetStructuredDataPluginInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetSymbolFilePluginInfo() { + return GetSymbolFileInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetSymbolFilePluginEnabled(llvm::StringRef name, + bool enable) { + return GetSymbolFileInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetSymbolLocatorPluginInfo() { + return GetSymbolLocatorInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetSymbolLocatorPluginEnabled(llvm::StringRef name, + bool enable) { + return GetSymbolLocatorInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetSymbolVendorPluginInfo() { + return GetSymbolVendorInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetSymbolVendorPluginEnabled(llvm::StringRef name, + bool enable) { + return GetSymbolVendorInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetSystemRuntimePluginInfo() { + return GetSystemRuntimeInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetSystemRuntimePluginEnabled(llvm::StringRef name, + bool enable) { + return GetSystemRuntimeInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetTracePluginInfo() { + return GetTracePluginInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetTracePluginEnabled(llvm::StringRef name, bool enable) { + return GetTracePluginInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetTraceExporterPluginInfo() { + return GetTraceExporterInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetTraceExporterPluginEnabled(llvm::StringRef name, + bool enable) { + return GetTraceExporterInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetTypeSystemPluginInfo() { + return GetTypeSystemInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetTypeSystemPluginEnabled(llvm::StringRef name, + bool enable) { + return GetTypeSystemInstances().SetInstanceEnabled(name, enable); +} + +std::vector<RegisteredPluginInfo> PluginManager::GetUnwindAssemblyPluginInfo() { + return GetUnwindAssemblyInstances().GetPluginInfoForAllInstances(); +} +bool PluginManager::SetUnwindAssemblyPluginEnabled(llvm::StringRef name, + bool enable) { + return GetUnwindAssemblyInstances().SetInstanceEnabled(name, enable); +} diff --git a/lldb/test/API/commands/plugin/TestPlugin.py b/lldb/test/API/commands/plugin/TestPlugin.py new file mode 100644 index 0000000000000..566f355e2fb7c --- /dev/null +++ b/lldb/test/API/commands/plugin/TestPlugin.py @@ -0,0 +1,62 @@ +""" +Make sure the plugin list, enable, and disable commands work. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +class TestFrameVar(TestBase): + # If your test case doesn't stress debug info, then + # set this to true. That way it won't be run once for + # each debug info format. + NO_DEBUG_INFO_TESTCASE = True + + def test_plugin_list_enable_disable_commands(self): + for plugin_namespace in [ + 'abi', + 'architecture', + 'disassembler', + 'dynamic-loader', + 'emulate-instruction', + 'instrumentation-runtime', + 'jit-loader', + 'language', + 'language-runtime', + 'memory-history', + 'object-container', + 'object-file', + 'operating-system', + 'platform', + 'process', + 'repl', + 'register-type-builder', + 'script-interpreter', + 'scripted-interface', + 'structured-data', + 'symbol-file', + 'symbol-locator', + 'symbol-vendor', + 'system-runtime', + # 'trace', # No trace plugin is registered by default. + 'trace-exporter', + 'type-system', + 'unwind-assembly', + ]: + self.do_list_disable_enable_test(plugin_namespace) + + def do_list_disable_enable_test(self, plugin_namespace): + # Plugins are enabled by default. + self.expect( + f"plugin list {plugin_namespace}", substrs=[plugin_namespace, "[+]"] + ) + + # Plugins can be disabled. + self.expect( + f"plugin disable {plugin_namespace}", substrs=[plugin_namespace, "[-]"] + ) + + # Plugins can be enabled. + self.expect( + f"plugin enable {plugin_namespace}", substrs=[plugin_namespace, "[+]"] + ) diff --git a/lldb/test/Shell/Commands/command-plugin-list.test b/lldb/test/Shell/Commands/command-plugin-list.test index 9d3680d48cdd0..d74c4d9c8dcea 100644 --- a/lldb/test/Shell/Commands/command-plugin-list.test +++ b/lldb/test/Shell/Commands/command-plugin-list.test @@ -10,10 +10,10 @@ # Test plugin list without an argument will list all plugins. plugin list # CHECK-LABEL: plugin list -# CHECK: system-runtime -# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries # CHECK: instrumentation-runtime # CHECK: [+] AddressSanitizer AddressSanitizer instrumentation runtime plugin. +# CHECK: system-runtime +# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries # Test plugin list works with fully qualified name. plugin list system-runtime.systemruntime-macosx >From bcf876f6b43b0a3db041b7d0719692d8b5e38828 Mon Sep 17 00:00:00 2001 From: David Peixotto <p...@meta.com> Date: Thu, 12 Jun 2025 13:54:28 -0700 Subject: [PATCH 3/4] formatting --- lldb/test/API/commands/plugin/TestPlugin.py | 54 ++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lldb/test/API/commands/plugin/TestPlugin.py b/lldb/test/API/commands/plugin/TestPlugin.py index 566f355e2fb7c..fdfb14bfcc24e 100644 --- a/lldb/test/API/commands/plugin/TestPlugin.py +++ b/lldb/test/API/commands/plugin/TestPlugin.py @@ -14,34 +14,34 @@ class TestFrameVar(TestBase): def test_plugin_list_enable_disable_commands(self): for plugin_namespace in [ - 'abi', - 'architecture', - 'disassembler', - 'dynamic-loader', - 'emulate-instruction', - 'instrumentation-runtime', - 'jit-loader', - 'language', - 'language-runtime', - 'memory-history', - 'object-container', - 'object-file', - 'operating-system', - 'platform', - 'process', - 'repl', - 'register-type-builder', - 'script-interpreter', - 'scripted-interface', - 'structured-data', - 'symbol-file', - 'symbol-locator', - 'symbol-vendor', - 'system-runtime', + "abi", + "architecture", + "disassembler", + "dynamic-loader", + "emulate-instruction", + "instrumentation-runtime", + "jit-loader", + "language", + "language-runtime", + "memory-history", + "object-container", + "object-file", + "operating-system", + "platform", + "process", + "repl", + "register-type-builder", + "script-interpreter", + "scripted-interface", + "structured-data", + "symbol-file", + "symbol-locator", + "symbol-vendor", + "system-runtime", # 'trace', # No trace plugin is registered by default. - 'trace-exporter', - 'type-system', - 'unwind-assembly', + "trace-exporter", + "type-system", + "unwind-assembly", ]: self.do_list_disable_enable_test(plugin_namespace) >From a5d305efcdfb646879579e92c807a2b416e32fa8 Mon Sep 17 00:00:00 2001 From: David Peixotto <p...@meta.com> Date: Fri, 13 Jun 2025 14:57:49 -0700 Subject: [PATCH 4/4] Use CHECK-DAG --- lldb/test/Shell/Commands/command-plugin-list.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lldb/test/Shell/Commands/command-plugin-list.test b/lldb/test/Shell/Commands/command-plugin-list.test index d74c4d9c8dcea..3f02157665bb2 100644 --- a/lldb/test/Shell/Commands/command-plugin-list.test +++ b/lldb/test/Shell/Commands/command-plugin-list.test @@ -10,10 +10,10 @@ # Test plugin list without an argument will list all plugins. plugin list # CHECK-LABEL: plugin list -# CHECK: instrumentation-runtime -# CHECK: [+] AddressSanitizer AddressSanitizer instrumentation runtime plugin. -# CHECK: system-runtime -# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries +# CHECK-DAG: instrumentation-runtime +# CHECK-DAG: [+] AddressSanitizer AddressSanitizer instrumentation runtime plugin. +# CHECK-DAG: system-runtime +# CHECK-DAG: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries # Test plugin list works with fully qualified name. plugin list system-runtime.systemruntime-macosx _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits