diff options
author | Pavel Labath <labath@google.com> | 2017-02-17 13:27:42 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-02-17 13:27:42 +0000 |
commit | fb0d22d6454a9b55e6c9219c5e06646c9707889a (patch) | |
tree | 46add8c31f16f9e9c2c4f397e17d7fbbc1df56c7 /lldb/source/Core/PluginManager.cpp | |
parent | 38699dbac5b69f8f71718abaecd7bb96f2170f8e (diff) | |
download | bcm5719-llvm-fb0d22d6454a9b55e6c9219c5e06646c9707889a.tar.gz bcm5719-llvm-fb0d22d6454a9b55e6c9219c5e06646c9707889a.zip |
Reapply "Refactor log channel registration mechanism"
Changes wrt. previous version:
- add #include <atomic>: fix build on windows
- add extra {} around the string literals used to initialize
llvm::StringLiteral: fix gcc build
llvm-svn: 295442
Diffstat (limited to 'lldb/source/Core/PluginManager.cpp')
-rw-r--r-- | lldb/source/Core/PluginManager.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 91d640d641d..71a0f6eccea 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -1167,93 +1167,6 @@ PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex( return nullptr; } -#pragma mark LogChannel - -struct LogInstance { - LogInstance() : name(), description(), create_callback(nullptr) {} - - ConstString name; - std::string description; - LogChannelCreateInstance create_callback; -}; - -typedef std::vector<LogInstance> LogInstances; - -static std::recursive_mutex &GetLogMutex() { - static std::recursive_mutex g_instances_mutex; - return g_instances_mutex; -} - -static LogInstances &GetLogInstances() { - static LogInstances g_instances; - return g_instances; -} - -bool PluginManager::RegisterPlugin(const ConstString &name, - const char *description, - LogChannelCreateInstance create_callback) { - if (create_callback) { - LogInstance instance; - assert((bool)name); - instance.name = name; - if (description && description[0]) - instance.description = description; - instance.create_callback = create_callback; - std::lock_guard<std::recursive_mutex> gard(GetLogMutex()); - GetLogInstances().push_back(instance); - } - return false; -} - -bool PluginManager::UnregisterPlugin(LogChannelCreateInstance create_callback) { - if (create_callback) { - std::lock_guard<std::recursive_mutex> gard(GetLogMutex()); - LogInstances &instances = GetLogInstances(); - - LogInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++pos) { - if (pos->create_callback == create_callback) { - instances.erase(pos); - return true; - } - } - } - return false; -} - -const char *PluginManager::GetLogChannelCreateNameAtIndex(uint32_t idx) { - std::lock_guard<std::recursive_mutex> gard(GetLogMutex()); - LogInstances &instances = GetLogInstances(); - if (idx < instances.size()) - return instances[idx].name.GetCString(); - return nullptr; -} - -LogChannelCreateInstance -PluginManager::GetLogChannelCreateCallbackAtIndex(uint32_t idx) { - std::lock_guard<std::recursive_mutex> gard(GetLogMutex()); - LogInstances &instances = GetLogInstances(); - if (idx < instances.size()) - return instances[idx].create_callback; - return nullptr; -} - -LogChannelCreateInstance -PluginManager::GetLogChannelCreateCallbackForPluginName( - const ConstString &name) { - if (name) { - std::lock_guard<std::recursive_mutex> gard(GetLogMutex()); - LogInstances &instances = GetLogInstances(); - - LogInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++pos) { - if (name == pos->name) - return pos->create_callback; - } - } - return nullptr; -} - #pragma mark Platform struct PlatformInstance { |