[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)
David Peixotto via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 5 12:43:08 PDT 2025
================
@@ -54,12 +57,67 @@ struct RegisteredPluginInfo {
bool enabled = false;
};
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugins. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "macosx" plugin in the "system-runtime" namespace then we will
+// match a plugin name pattern against the "system-runtime.macosx" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function<std::vector<RegisteredPluginInfo>()>;
+using SetPluginEnabled = std::function<bool(llvm::StringRef, bool)>;
+struct PluginNamespace {
+ llvm::StringRef name;
+ GetPluginInfo get_info;
+ SetPluginEnabled set_enabled;
+};
+
class PluginManager {
public:
static void Initialize();
static void Terminate();
+ // Support for enabling and disabling plugins.
+
+ // Return the plugins that can be enabled or disabled by the user.
+ static llvm::ArrayRef<PluginNamespace> GetPluginNamespaces();
+
+ // Generate a json object that describes the plugins that are available.
+ // This is a json representation of the plugin info returned by
+ // GetPluginNamespaces().
+ //
+ // {
+ // <plugin-namespace>: [
+ // {
+ // "enabled": <bool>,
+ // "name": <plugin-name>,
+ // },
+ // ...
+ // ],
+ // ...
+ // }
+ //
+ // If pattern is given it will be used to filter the plugins that are
+ // are returned. The pattern filters the plugin names using the
+ // PluginManager::MatchPluginName() function.
+ static llvm::json::Object GetJSON(llvm::StringRef pattern = "");
+
+ // Return true if the pattern matches the plugin name.
+ //
+ // The pattern matches the name if it is exactly equal to the namespace name
+ // or if it is equal to the qualified name, which is the namespace name
+ // followed by a dot and the plugin name (e.g. "system-runtime.foo").
+ //
+ // An empty pattern matches all plugins.
+ static bool MatchPluginName(llvm::StringRef pattern,
+ const PluginNamespace &plugin_ns,
+ const RegisteredPluginInfo &plugin);
+
----------------
dmpots wrote:
It is used in [ActOnMatchingPlugins](https://github.com/llvm/llvm-project/pull/134418/files#diff-630b9ff8bd3f2f236eeb85da70c2a3de3284e9aef31882f75e14830088e4ae12R68) so that we do not duplicate the matching logic in multiple places.
https://github.com/llvm/llvm-project/pull/134418
More information about the lldb-commits
mailing list