diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp index 6f5e020e812b6..0d7649a98e8c3 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp @@ -11,17 +11,21 @@ using namespace lldb_private; static constexpr Log::Category g_categories[] = { - {{"break"}, {"log breakpoints"}, WINDOWS_LOG_BREAKPOINTS}, - {{"event"}, {"log low level debugger events"}, WINDOWS_LOG_EVENT}, - {{"exception"}, {"log exception information"}, WINDOWS_LOG_EXCEPTION}, - {{"memory"}, {"log memory reads and writes"}, WINDOWS_LOG_MEMORY}, - {{"process"}, {"log process events and activities"}, WINDOWS_LOG_PROCESS}, - {{"registers"}, {"log register read/writes"}, WINDOWS_LOG_REGISTERS}, - {{"step"}, {"log step related activities"}, WINDOWS_LOG_STEP}, - {{"thread"}, {"log thread events and activities"}, WINDOWS_LOG_THREAD}, + {{"break"}, {"log breakpoints"}, WindowsLog::Breakpoints}, + {{"event"}, {"log low level debugger events"}, WindowsLog::Event}, + {{"exception"}, {"log exception information"}, WindowsLog::Exception}, + {{"memory"}, {"log memory reads and writes"}, WindowsLog::Memory}, + {{"process"}, {"log process events and activities"}, WindowsLog::Process}, + {{"registers"}, {"log register read/writes"}, WindowsLog::Registers}, + {{"step"}, {"log step related activities"}, WindowsLog::Step}, + {{"thread"}, {"log thread events and activities"}, WindowsLog::Thread}, }; -Log::Channel ProcessWindowsLog::g_channel(g_categories, WINDOWS_LOG_PROCESS); +static Log::Channel g_channel(g_categories, WindowsLog::Process); + +template <> Log::Channel &lldb_private::LogChannelFor() { + return g_channel; +} void ProcessWindowsLog::Initialize() { static llvm::once_flag g_once_flag; diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h b/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h index 66ba245c9fa88..68a9d767c227d 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h @@ -11,25 +11,38 @@ #include "lldb/Utility/Log.h" -#define WINDOWS_LOG_PROCESS (1u << 1) // Log process operations -#define WINDOWS_LOG_EXCEPTION (1u << 1) // Log exceptions -#define WINDOWS_LOG_THREAD (1u << 2) // Log thread operations -#define WINDOWS_LOG_MEMORY (1u << 3) // Log memory reads/writes calls -#define WINDOWS_LOG_BREAKPOINTS (1u << 4) // Log breakpoint operations -#define WINDOWS_LOG_STEP (1u << 5) // Log step operations -#define WINDOWS_LOG_REGISTERS (1u << 6) // Log register operations -#define WINDOWS_LOG_EVENT (1u << 7) // Low level debug events - namespace lldb_private { -class ProcessWindowsLog { - static Log::Channel g_channel; +enum class WindowsLog : Log::MaskType { + Breakpoints = Log::ChannelFlag<0>, // Log breakpoint operations + Event = Log::ChannelFlag<1>, // Low level debug events + Exception = Log::ChannelFlag<2>, // Log exceptions + Memory = Log::ChannelFlag<3>, // Log memory reads/writes calls + Process = Log::ChannelFlag<4>, // Log process operations + Registers = Log::ChannelFlag<5>, // Log register operations + Step = Log::ChannelFlag<6>, // Log step operations + Thread = Log::ChannelFlag<7>, // Log thread operations + LLVM_MARK_AS_BITMASK_ENUM(Thread) +}; + +#define WINDOWS_LOG_PROCESS ::lldb_private::WindowsLog::Process +#define WINDOWS_LOG_EXCEPTION ::lldb_private::WindowsLog::Exception +#define WINDOWS_LOG_THREAD ::lldb_private::WindowsLog::Thread +#define WINDOWS_LOG_MEMORY ::lldb_private::WindowsLog::Memory +#define WINDOWS_LOG_BREAKPOINTS ::lldb_private::WindowsLog::Breakpoints +#define WINDOWS_LOG_STEP ::lldb_private::WindowsLog::Step +#define WINDOWS_LOG_REGISTERS ::lldb_private::WindowsLog::Registers +#define WINDOWS_LOG_EVENT ::lldb_private::WindowsLog::Event + +class ProcessWindowsLog { public: static void Initialize(); static void Terminate(); - static Log *GetLogIfAny(uint32_t mask) { return g_channel.GetLogIfAny(mask); } + static Log *GetLogIfAny(WindowsLog mask) { return GetLog(mask); } }; + +template <> Log::Channel &LogChannelFor(); } #endif // liblldb_ProcessWindowsLog_h_