Index: include/lldb/Core/Log.h =================================================================== --- include/lldb/Core/Log.h +++ include/lldb/Core/Log.h @@ -12,7 +12,6 @@ // Project includes #include "lldb/Core/Logging.h" -#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" #include "lldb/lldb-private.h" @@ -93,35 +92,11 @@ }; //------------------------------------------------------------------ - // Callback definitions for abstracted plug-in log access. - //------------------------------------------------------------------ - typedef void (*DisableCallback)(const char **categories, - Stream *feedback_strm); - typedef Log *(*EnableCallback)( - const std::shared_ptr &log_stream_sp, - uint32_t log_options, const char **categories, Stream *feedback_strm); - typedef void (*ListCategoriesCallback)(Stream *strm); - - struct Callbacks { - DisableCallback disable; - EnableCallback enable; - ListCategoriesCallback list_categories; - }; - - //------------------------------------------------------------------ // Static accessors for logging channels //------------------------------------------------------------------ static void Register(llvm::StringRef name, Channel &channel); static void Unregister(llvm::StringRef name); - static void RegisterLogChannel(const ConstString &channel, - const Log::Callbacks &log_callbacks); - - static bool UnregisterLogChannel(const ConstString &channel); - - static bool GetLogChannelCallbacks(const ConstString &channel, - Log::Callbacks &log_callbacks); - static bool EnableLogChannel(const std::shared_ptr &log_stream_sp, uint32_t log_options, llvm::StringRef channel, Index: source/API/SBCommandReturnObject.cpp =================================================================== --- source/API/SBCommandReturnObject.cpp +++ source/API/SBCommandReturnObject.cpp @@ -17,6 +17,7 @@ #include "lldb/Core/Log.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Error.h" using namespace lldb; Index: source/Core/Log.cpp =================================================================== --- source/Core/Log.cpp +++ source/Core/Log.cpp @@ -221,16 +221,6 @@ free(arg_msg); } -typedef std::map CallbackMap; -typedef CallbackMap::iterator CallbackMapIter; - -// Surround our callback map with a singleton function so we don't have any -// global initializers. -static CallbackMap &GetCallbackMap() { - static CallbackMap g_callback_map; - return g_callback_map; -} - void Log::Register(llvm::StringRef name, Channel &channel) { auto iter = g_channel_map->try_emplace(name, channel); assert(iter.second == true); @@ -244,37 +234,10 @@ g_channel_map->erase(iter); } -void Log::RegisterLogChannel(const ConstString &channel, - const Log::Callbacks &log_callbacks) { - GetCallbackMap().insert(std::make_pair(channel, log_callbacks)); -} - -bool Log::UnregisterLogChannel(const ConstString &channel) { - return GetCallbackMap().erase(channel) != 0; -} - -bool Log::GetLogChannelCallbacks(const ConstString &channel, - Log::Callbacks &log_callbacks) { - CallbackMap &callback_map = GetCallbackMap(); - CallbackMapIter pos = callback_map.find(channel); - if (pos != callback_map.end()) { - log_callbacks = pos->second; - return true; - } - ::memset(&log_callbacks, 0, sizeof(log_callbacks)); - return false; -} - bool Log::EnableLogChannel( const std::shared_ptr &log_stream_sp, uint32_t log_options, llvm::StringRef channel, const char **categories, Stream &error_stream) { - Log::Callbacks log_callbacks; - if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) { - log_callbacks.enable(log_stream_sp, log_options, categories, &error_stream); - return true; - } - auto iter = g_channel_map->find(channel); if (iter == g_channel_map->end()) { error_stream.Format("Invalid log channel '{0}'.\n", channel); @@ -289,12 +252,6 @@ bool Log::DisableLogChannel(llvm::StringRef channel, const char **categories, Stream &error_stream) { - Log::Callbacks log_callbacks; - if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) { - log_callbacks.disable(categories, &error_stream); - return true; - } - auto iter = g_channel_map->find(channel); if (iter == g_channel_map->end()) { error_stream.Format("Invalid log channel '{0}'.\n", channel); @@ -308,12 +265,6 @@ } bool Log::ListChannelCategories(llvm::StringRef channel, Stream &stream) { - Log::Callbacks log_callbacks; - if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) { - log_callbacks.list_categories(&stream); - return true; - } - auto ch = g_channel_map->find(channel); if (ch == g_channel_map->end()) { stream.Format("Invalid log channel '{0}'.\n", channel); @@ -324,29 +275,16 @@ } void Log::DisableAllLogChannels(Stream *feedback_strm) { - CallbackMap &callback_map = GetCallbackMap(); - CallbackMapIter pos, end = callback_map.end(); - const char *categories[] = {"all", nullptr}; - - for (pos = callback_map.begin(); pos != end; ++pos) - pos->second.disable(categories, feedback_strm); - for (auto &entry : *g_channel_map) entry.second.channel.Disable(UINT32_MAX); } void Log::ListAllLogChannels(Stream *strm) { - CallbackMap &callback_map = GetCallbackMap(); - - if (callback_map.empty() && g_channel_map->empty()) { + if (g_channel_map->empty()) { strm->PutCString("No logging channels are currently registered.\n"); return; } - CallbackMapIter pos, end = callback_map.end(); - for (pos = callback_map.begin(); pos != end; ++pos) - pos->second.list_categories(strm); - for (const auto &channel : *g_channel_map) ListCategories(*strm, channel); }