[Lldb-commits] [lldb] [lldb] Revert plugin manager changes to investigate failure (PR #134183)
David Peixotto via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 2 17:31:31 PDT 2025
https://github.com/dmpots created https://github.com/llvm/llvm-project/pull/134183
Revert the below two commits while we investigate the test failures.
Revert "[lldb] Fix plugin manager test failure on windows (#134173)"
This reverts commit b55bab229228218341e2f24fc8529c7aaab51e2f.
Revert "Add enable/disable api for SystemRuntime plugins (#133794)"
This reverts commit 2026873fb8a1f654aa920cd5ea8074e55053973b.
>From 34ac1f25634490278de5497b59024b29aeb8557a Mon Sep 17 00:00:00 2001
From: David Peixotto <peix at meta.com>
Date: Wed, 2 Apr 2025 17:26:49 -0700
Subject: [PATCH] [lldb] Revert plugin manager changes to investigate failure
Revert the below two commits while we investigate the test failures.
Revert "[lldb] Fix plugin manager test failure on windows (#134173)"
This reverts commit b55bab229228218341e2f24fc8529c7aaab51e2f.
Revert "Add enable/disable api for SystemRuntime plugins (#133794)"
This reverts commit 2026873fb8a1f654aa920cd5ea8074e55053973b.
---
lldb/include/lldb/Core/PluginManager.h | 13 -
lldb/source/Core/PluginManager.cpp | 55 +---
lldb/unittests/Core/CMakeLists.txt | 1 -
lldb/unittests/Core/PluginManagerTest.cpp | 381 ----------------------
4 files changed, 3 insertions(+), 447 deletions(-)
delete mode 100644 lldb/unittests/Core/PluginManagerTest.cpp
diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h
index a6dab045adf27..e4e0c3eea67f8 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -22,7 +22,6 @@
#include <cstddef>
#include <cstdint>
-#include <vector>
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName) \
namespace lldb_private { \
@@ -48,12 +47,6 @@ class CommandInterpreter;
class Debugger;
class StringList;
-struct RegisteredPluginInfo {
- llvm::StringRef name = "";
- llvm::StringRef description = "";
- bool enabled = false;
-};
-
class PluginManager {
public:
static void Initialize();
@@ -175,12 +168,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,
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index e6cb248ef31ce..95eb940efcef2 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -188,13 +188,11 @@ template <typename Callback> struct PluginInstance {
PluginInstance(llvm::StringRef name, llvm::StringRef description,
Callback create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr)
- : name(name), description(description), enabled(true),
- create_callback(create_callback),
+ : name(name), description(description), create_callback(create_callback),
debugger_init_callback(debugger_init_callback) {}
llvm::StringRef name;
llvm::StringRef description;
- bool enabled;
Callback create_callback;
DebuggerInitializeCallback debugger_init_callback;
};
@@ -252,9 +250,7 @@ template <typename Instance> class PluginInstances {
}
void PerformDebuggerCallback(Debugger &debugger) {
- for (const auto &instance : m_instances) {
- if (!instance.enabled)
- continue;
+ for (auto &instance : m_instances) {
if (instance.debugger_init_callback)
instance.debugger_init_callback(debugger);
}
@@ -264,14 +260,7 @@ template <typename Instance> class PluginInstances {
// Note that this is a copy of the internal state so modifications
// to the returned instances will not be reflected back to instances
// stored by the PluginInstances object.
- std::vector<Instance> GetSnapshot() {
- std::vector<Instance> enabled_instances;
- for (const auto &instance : m_instances) {
- if (instance.enabled)
- enabled_instances.push_back(instance);
- }
- return enabled_instances;
- }
+ std::vector<Instance> GetSnapshot() { return m_instances; }
const Instance *GetInstanceAtIndex(uint32_t idx) {
uint32_t count = 0;
@@ -291,41 +280,12 @@ template <typename Instance> class PluginInstances {
const Instance *
FindEnabledInstance(std::function<bool(const Instance &)> predicate) const {
for (const auto &instance : m_instances) {
- if (!instance.enabled)
- continue;
if (predicate(instance))
return &instance;
}
return nullptr;
}
- // Return a list of all the registered plugin instances. This includes both
- // enabled and disabled instances. The instances are listed in the order they
- // were registered which is the order they would be queried if they were all
- // enabled.
- std::vector<RegisteredPluginInfo> GetPluginInfoForAllInstances() {
- // Lookup the plugin info for each instance in the sorted order.
- std::vector<RegisteredPluginInfo> plugin_infos;
- plugin_infos.reserve(m_instances.size());
- for (const Instance &instance : m_instances)
- plugin_infos.push_back(
- {instance.name, instance.description, instance.enabled});
-
- return plugin_infos;
- }
-
- bool SetInstanceEnabled(llvm::StringRef name, bool enable) {
- auto it = std::find_if(
- m_instances.begin(), m_instances.end(),
- [&](const Instance &instance) { return instance.name == name; });
-
- if (it == m_instances.end())
- return false;
-
- it->enabled = enable;
- return true;
- }
-
private:
std::vector<Instance> m_instances;
};
@@ -667,15 +627,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> {
diff --git a/lldb/unittests/Core/CMakeLists.txt b/lldb/unittests/Core/CMakeLists.txt
index 8580f5887ea2b..60265f794b5e8 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -7,7 +7,6 @@ add_lldb_unittest(LLDBCoreTests
FormatEntityTest.cpp
MangledTest.cpp
ModuleSpecTest.cpp
- PluginManagerTest.cpp
ProgressReportTest.cpp
RichManglingContextTest.cpp
SourceLocationSpecTest.cpp
diff --git a/lldb/unittests/Core/PluginManagerTest.cpp b/lldb/unittests/Core/PluginManagerTest.cpp
deleted file mode 100644
index 9b0ce2286d273..0000000000000
--- a/lldb/unittests/Core/PluginManagerTest.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-
-#include "lldb/Core/PluginManager.h"
-
-#include "gtest/gtest.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// Mock system runtime plugin create functions.
-// Make them all return different values to avoid the ICF optimization
-// from combining them into the same function. The values returned
-// are not valid SystemRuntime pointers, but they are unique and
-// sufficient for testing.
-SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
- return (SystemRuntime *)0x1;
-}
-
-SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
- return (SystemRuntime *)0x2;
-}
-
-SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
- return (SystemRuntime *)0x3;
-}
-
-// Test class for testing the PluginManager.
-// The PluginManager modifies global state when registering new plugins. This
-// class is intended to undo those modifications in the destructor to give each
-// test a clean slate with no registered plugins at the start of a test.
-class PluginManagerTest : public testing::Test {
-public:
- // Remove any pre-registered plugins so we have a known starting point.
- static void SetUpTestSuite() { RemoveAllRegisteredSystemRuntimePlugins(); }
-
- // Add mock system runtime plugins for testing.
- void RegisterMockSystemRuntimePlugins() {
- // Make sure the create functions all have different addresses.
- ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
- ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);
-
- ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
- CreateSystemRuntimePluginA));
- ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",
- CreateSystemRuntimePluginB));
- ASSERT_TRUE(PluginManager::RegisterPlugin("c", "test instance C",
- CreateSystemRuntimePluginC));
- }
-
- // Remove any plugins added during the tests.
- virtual ~PluginManagerTest() override {
- RemoveAllRegisteredSystemRuntimePlugins();
- }
-
-protected:
- std::vector<SystemRuntimeCreateInstance> m_system_runtime_plugins;
-
- static void RemoveAllRegisteredSystemRuntimePlugins() {
- // Enable all currently registered plugins so we can get a handle to
- // their create callbacks in the loop below. Only enabled plugins
- // are returned from the PluginManager Get*CreateCallbackAtIndex apis.
- for (const RegisteredPluginInfo &PluginInfo :
- PluginManager::GetSystemRuntimePluginInfo()) {
- PluginManager::SetSystemRuntimePluginEnabled(PluginInfo.name, true);
- }
-
- // Get a handle to the create call backs for all the registered plugins.
- std::vector<SystemRuntimeCreateInstance> registered_plugin_callbacks;
- SystemRuntimeCreateInstance create_callback = nullptr;
- for (uint32_t idx = 0;
- (create_callback =
- PluginManager::GetSystemRuntimeCreateCallbackAtIndex(idx)) !=
- nullptr;
- ++idx) {
- registered_plugin_callbacks.push_back((create_callback));
- }
-
- // Remove all currently registered plugins.
- for (SystemRuntimeCreateInstance create_callback :
- registered_plugin_callbacks) {
- PluginManager::UnregisterPlugin(create_callback);
- }
- }
-};
-
-// Test basic register functionality.
-TEST_F(PluginManagerTest, RegisterSystemRuntimePlugin) {
- RegisterMockSystemRuntimePlugins();
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginC);
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(3), nullptr);
-}
-
-// Test basic un-register functionality.
-TEST_F(PluginManagerTest, UnRegisterSystemRuntimePlugin) {
- RegisterMockSystemRuntimePlugins();
-
- ASSERT_TRUE(PluginManager::UnregisterPlugin(CreateSystemRuntimePluginB));
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
-
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2), nullptr);
-}
-
-// Test registered plugin info functionality.
-TEST_F(PluginManagerTest, SystemRuntimePluginInfo) {
- RegisterMockSystemRuntimePlugins();
-
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].description, "test instance A");
- ASSERT_EQ(plugin_info[0].enabled, true);
- ASSERT_EQ(plugin_info[1].name, "b");
- ASSERT_EQ(plugin_info[1].description, "test instance B");
- ASSERT_EQ(plugin_info[1].enabled, true);
- ASSERT_EQ(plugin_info[2].name, "c");
- ASSERT_EQ(plugin_info[2].description, "test instance C");
- ASSERT_EQ(plugin_info[2].enabled, true);
-}
-
-// Test basic un-register functionality.
-TEST_F(PluginManagerTest, UnRegisterSystemRuntimePluginInfo) {
- RegisterMockSystemRuntimePlugins();
-
- // Initial plugin info has all three registered plugins.
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
-
- ASSERT_TRUE(PluginManager::UnregisterPlugin(CreateSystemRuntimePluginB));
-
- // After un-registering a plugin it should be removed from plugin info.
- plugin_info = PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 2u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].enabled, true);
- ASSERT_EQ(plugin_info[1].name, "c");
- ASSERT_EQ(plugin_info[1].enabled, true);
-}
-
-// Test plugin disable functionality.
-TEST_F(PluginManagerTest, SystemRuntimePluginDisable) {
- RegisterMockSystemRuntimePlugins();
-
- // Disable plugin should succeed.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
-
- // Disabling a plugin does not remove it from plugin info.
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].enabled, true);
- ASSERT_EQ(plugin_info[1].name, "b");
- ASSERT_EQ(plugin_info[1].enabled, false);
- ASSERT_EQ(plugin_info[2].name, "c");
- ASSERT_EQ(plugin_info[2].enabled, true);
-
- // Disabling a plugin does remove it from available plugins.
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2), nullptr);
-}
-
-// Test plugin disable and enable functionality.
-TEST_F(PluginManagerTest, SystemRuntimePluginDisableThenEnable) {
- RegisterMockSystemRuntimePlugins();
-
- // Initially plugin b is available in slot 1.
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
-
- // Disabling it will remove it from available plugins.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
-
- // We can re-enable the plugin later and it should go back to the original
- // slot.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", true));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginC);
-
- // And show up in the plugin info correctly.
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].enabled, true);
- ASSERT_EQ(plugin_info[1].name, "b");
- ASSERT_EQ(plugin_info[1].enabled, true);
- ASSERT_EQ(plugin_info[2].name, "c");
- ASSERT_EQ(plugin_info[2].enabled, true);
-}
-
-// Test calling disable on an already disabled plugin is ok.
-TEST_F(PluginManagerTest, SystemRuntimePluginDisableDisabled) {
- RegisterMockSystemRuntimePlugins();
-
- // Initial call to disable the plugin should succeed.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
-
- // The second call should also succeed because the plugin is already disabled.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
-
- // The call to re-enable the plugin should succeed.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", true));
-
- // The second call should also succeed since the plugin is already enabled.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", true));
-}
-
-// Test calling disable on an already disabled plugin is ok.
-TEST_F(PluginManagerTest, SystemRuntimePluginDisableNonExistent) {
- RegisterMockSystemRuntimePlugins();
-
- // Both enable and disable should return false for a non-existent plugin.
- ASSERT_FALSE(
- PluginManager::SetSystemRuntimePluginEnabled("does_not_exist", true));
- ASSERT_FALSE(
- PluginManager::SetSystemRuntimePluginEnabled("does_not_exist", false));
-}
-
-// Test disabling all plugins and then re-enabling them in a different
-// order will restore the original plugin order.
-TEST_F(PluginManagerTest, SystemRuntimePluginDisableAll) {
- RegisterMockSystemRuntimePlugins();
-
- // Validate initial state of registered plugins.
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginC);
-
- // Disable all the active plugins.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("a", false));
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("c", false));
-
- // Should have no active plugins.
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0), nullptr);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1), nullptr);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2), nullptr);
-
- // And show up in the plugin info correctly.
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].enabled, false);
- ASSERT_EQ(plugin_info[1].name, "b");
- ASSERT_EQ(plugin_info[1].enabled, false);
- ASSERT_EQ(plugin_info[2].name, "c");
- ASSERT_EQ(plugin_info[2].enabled, false);
-
- // Enable plugins in reverse order and validate expected indicies.
- // They should show up in the original plugin order.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("c", true));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginC);
-
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("a", true));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
-
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", true));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginC);
-}
-
-// Test un-registering a disabled plugin works.
-TEST_F(PluginManagerTest, UnRegisterDisabledSystemRuntimePlugin) {
- RegisterMockSystemRuntimePlugins();
-
- // Initial plugin info has all three registered plugins.
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 3u);
-
- // First disable a plugin, then unregister it. Both should succeed.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("b", false));
- ASSERT_TRUE(PluginManager::UnregisterPlugin(CreateSystemRuntimePluginB));
-
- // After un-registering a plugin it should be removed from plugin info.
- plugin_info = PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(plugin_info.size(), 2u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[0].enabled, true);
- ASSERT_EQ(plugin_info[1].name, "c");
- ASSERT_EQ(plugin_info[1].enabled, true);
-}
-
-// Test un-registering and then re-registering a plugin will change the order of
-// loaded plugins.
-TEST_F(PluginManagerTest, UnRegisterSystemRuntimePluginChangesOrder) {
- RegisterMockSystemRuntimePlugins();
-
- std::vector<RegisteredPluginInfo> plugin_info =
- PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginC);
-
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[1].name, "b");
- ASSERT_EQ(plugin_info[2].name, "c");
-
- // Unregister and then registering a plugin puts it at the end of the order
- // list.
- ASSERT_TRUE(PluginManager::UnregisterPlugin(CreateSystemRuntimePluginB));
- ASSERT_TRUE(PluginManager::RegisterPlugin("b", "New test instance B",
- CreateSystemRuntimePluginB));
-
- // Check the callback indices match as expected.
- plugin_info = PluginManager::GetSystemRuntimePluginInfo();
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginB);
-
- // And plugin info should match as well.
- ASSERT_EQ(plugin_info.size(), 3u);
- ASSERT_EQ(plugin_info[0].name, "a");
- ASSERT_EQ(plugin_info[1].name, "c");
- ASSERT_EQ(plugin_info[2].name, "b");
- ASSERT_EQ(plugin_info[2].description, "New test instance B");
-
- // Disabling and re-enabling the "c" plugin should slot it back
- // into the middle of the order. Originally it was last, but after
- // un-registering and re-registering "b" it should now stay in
- // the middle of the order.
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("c", false));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginB);
-
- // And re-enabling
- ASSERT_TRUE(PluginManager::SetSystemRuntimePluginEnabled("c", true));
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(0),
- CreateSystemRuntimePluginA);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(1),
- CreateSystemRuntimePluginC);
- ASSERT_EQ(PluginManager::GetSystemRuntimeCreateCallbackAtIndex(2),
- CreateSystemRuntimePluginB);
-}
More information about the lldb-commits
mailing list