[Lldb-commits] [lldb] r296333 - Remove the callback-based log channel registration mechanism
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 27 04:21:17 PST 2017
Author: labath
Date: Mon Feb 27 06:21:16 2017
New Revision: 296333
URL: http://llvm.org/viewvc/llvm-project?rev=296333&view=rev
Log:
Remove the callback-based log channel registration mechanism
All the existing channels have beens switched to the new mechanism and
this code is now unused.
Modified:
lldb/trunk/include/lldb/Core/Log.h
lldb/trunk/source/API/SBCommandReturnObject.cpp
lldb/trunk/source/Core/Log.cpp
Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=296333&r1=296332&r2=296333&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Mon Feb 27 06:21:16 2017
@@ -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 @@ public:
};
//------------------------------------------------------------------
- // Callback definitions for abstracted plug-in log access.
- //------------------------------------------------------------------
- typedef void (*DisableCallback)(const char **categories,
- Stream *feedback_strm);
- typedef Log *(*EnableCallback)(
- const std::shared_ptr<llvm::raw_ostream> &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<llvm::raw_ostream> &log_stream_sp,
uint32_t log_options, llvm::StringRef channel,
Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=296333&r1=296332&r2=296333&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp Mon Feb 27 06:21:16 2017
@@ -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;
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=296333&r1=296332&r2=296333&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Mon Feb 27 06:21:16 2017
@@ -222,16 +222,6 @@ void Log::Warning(const char *format, ..
free(arg_msg);
}
-typedef std::map<ConstString, Log::Callbacks> 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);
@@ -245,37 +235,10 @@ void Log::Unregister(llvm::StringRef nam
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<llvm::raw_ostream> &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);
@@ -291,12 +254,6 @@ bool Log::EnableLogChannel(
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);
@@ -310,12 +267,6 @@ bool Log::DisableLogChannel(llvm::String
}
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);
@@ -326,29 +277,16 @@ bool Log::ListChannelCategories(llvm::St
}
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);
}
More information about the lldb-commits
mailing list