}
};
-
- static void Initialize();
-
//------------------------------------------------------------------
// Static accessors for logging channels
//------------------------------------------------------------------
static uint32_t GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry,
llvm::ArrayRef<const char *> categories);
- static void LockAllChannels();
- static void UnlockAllChannels();
-
Log(const Log &) = delete;
void operator=(const Log &) = delete;
};
#include <process.h> // for getpid
#else
#include <unistd.h>
-#include <pthread.h>
#endif
using namespace lldb_private;
Printf("warning: %s", Content.c_str());
}
-void Log::Initialize() {
-#ifdef LLVM_ON_UNIX
- pthread_atfork(&Log::LockAllChannels, &Log::UnlockAllChannels, &Log::UnlockAllChannels);
-#endif
- InitializeLldbChannel();
-}
-
void Log::Register(llvm::StringRef name, Channel &channel) {
auto iter = g_channel_map->try_emplace(name, channel);
assert(iter.second == true);
message << payload << "\n";
WriteMessage(message.str());
}
-
-void Log::LockAllChannels() {
- for (auto &c: *g_channel_map)
- c.second.m_mutex.lock();
-}
-
-void Log::UnlockAllChannels() {
- for (auto &c: *g_channel_map)
- c.second.m_mutex.unlock();
-}
static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT);
-void lldb_private::InitializeLldbChannel() {
+void lldb_private::InitializeLog() {
Log::Register("lldb", g_log_channel);
}