diff --git a/lldb/include/lldb/Utility/LLDBLog.h b/lldb/include/lldb/Utility/LLDBLog.h --- a/lldb/include/lldb/Utility/LLDBLog.h +++ b/lldb/include/lldb/Utility/LLDBLog.h @@ -48,7 +48,7 @@ Unwind = Log::ChannelFlag<29>, Watchpoints = Log::ChannelFlag<30>, OnDemand = Log::ChannelFlag<31>, - LLVM_MARK_AS_BITMASK_ENUM(Watchpoints), + LLVM_MARK_AS_BITMASK_ENUM(OnDemand), }; LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -166,7 +166,7 @@ // output will be discarded. Log *GetLog(MaskType mask) { Log *log = log_ptr.load(std::memory_order_relaxed); - if (log && log->GetMask().AnySet(mask)) + if (log && ((log->GetMask() & mask) != 0)) return log; return nullptr; } @@ -243,7 +243,7 @@ const Flags GetOptions() const; - const Flags GetMask() const; + MaskType GetMask() const; bool GetVerbose() const; @@ -276,9 +276,9 @@ } void Enable(const std::shared_ptr &handler_sp, uint32_t options, - uint32_t flags); + MaskType flags); - void Disable(uint32_t flags); + void Disable(MaskType flags); bool Dump(llvm::raw_ostream &stream); @@ -291,8 +291,9 @@ static void ListCategories(llvm::raw_ostream &stream, const ChannelMap::value_type &entry); - static uint32_t GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry, - llvm::ArrayRef categories); + static Log::MaskType GetFlags(llvm::raw_ostream &stream, + const ChannelMap::value_type &entry, + llvm::ArrayRef categories); Log(const Log &) = delete; void operator=(const Log &) = delete; diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -60,13 +60,14 @@ }); } -uint32_t Log::GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry, - llvm::ArrayRef categories) { +Log::MaskType Log::GetFlags(llvm::raw_ostream &stream, + const ChannelMap::value_type &entry, + llvm::ArrayRef categories) { bool list_categories = false; - uint32_t flags = 0; + Log::MaskType flags = 0; for (const char *category : categories) { if (llvm::StringRef("all").equals_insensitive(category)) { - flags |= UINT32_MAX; + flags |= std::numeric_limits::max(); continue; } if (llvm::StringRef("default").equals_insensitive(category)) { @@ -91,7 +92,7 @@ } void Log::Enable(const std::shared_ptr &handler_sp, - uint32_t options, uint32_t flags) { + uint32_t options, Log::MaskType flags) { llvm::sys::ScopedWriter lock(m_mutex); MaskType mask = m_mask.fetch_or(flags, std::memory_order_relaxed); @@ -102,7 +103,7 @@ } } -void Log::Disable(uint32_t flags) { +void Log::Disable(Log::MaskType flags) { llvm::sys::ScopedWriter lock(m_mutex); MaskType mask = m_mask.fetch_and(~flags, std::memory_order_relaxed); @@ -126,7 +127,7 @@ return m_options.load(std::memory_order_relaxed); } -const Flags Log::GetMask() const { +Log::MaskType Log::GetMask() const { return m_mask.load(std::memory_order_relaxed); } @@ -203,7 +204,7 @@ void Log::Unregister(llvm::StringRef name) { auto iter = g_channel_map->find(name); assert(iter != g_channel_map->end()); - iter->second.Disable(UINT32_MAX); + iter->second.Disable(std::numeric_limits::max()); g_channel_map->erase(iter); } @@ -216,7 +217,7 @@ error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel); return false; } - uint32_t flags = categories.empty() + MaskType flags = categories.empty() ? iter->second.m_channel.default_flags : GetFlags(error_stream, *iter, categories); iter->second.Enable(log_handler_sp, log_options, flags); @@ -231,8 +232,8 @@ error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel); return false; } - uint32_t flags = categories.empty() - ? UINT32_MAX + MaskType flags = categories.empty() + ? std::numeric_limits::max() : GetFlags(error_stream, *iter, categories); iter->second.Disable(flags); return true; @@ -267,7 +268,7 @@ void Log::DisableAllLogChannels() { for (auto &entry : *g_channel_map) - entry.second.Disable(UINT32_MAX); + entry.second.Disable(std::numeric_limits::max()); } void Log::ForEachChannelCategory( diff --git a/lldb/unittests/Utility/LogTest.cpp b/lldb/unittests/Utility/LogTest.cpp --- a/lldb/unittests/Utility/LogTest.cpp +++ b/lldb/unittests/Utility/LogTest.cpp @@ -363,8 +363,8 @@ // Try fetching the log mask on one thread. Concurrently, try disabling the // log channel. - uint32_t mask; - std::thread log_thread([this, &mask] { mask = getLog()->GetMask().Get(); }); + uint64_t mask; + std::thread log_thread([this, &mask] { mask = getLog()->GetMask(); }); EXPECT_TRUE(DisableChannel("chan", {}, err)); log_thread.join();