This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b4db10f3492: [lldb] Actually support more than 32 logging 
categories (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D134245?vs=461420&id=461466#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134245/new/

https://reviews.llvm.org/D134245

Files:
  lldb/include/lldb/Utility/LLDBLog.h
  lldb/include/lldb/Utility/Log.h
  lldb/source/Utility/Log.cpp
  lldb/unittests/Utility/LogTest.cpp

Index: lldb/unittests/Utility/LogTest.cpp
===================================================================
--- lldb/unittests/Utility/LogTest.cpp
+++ 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();
 
Index: lldb/source/Utility/Log.cpp
===================================================================
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -60,13 +60,14 @@
                   });
 }
 
-uint32_t Log::GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry,
-                         llvm::ArrayRef<const char *> categories) {
+Log::MaskType Log::GetFlags(llvm::raw_ostream &stream,
+                            const ChannelMap::value_type &entry,
+                            llvm::ArrayRef<const char *> 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<Log::MaskType>::max();
       continue;
     }
     if (llvm::StringRef("default").equals_insensitive(category)) {
@@ -91,7 +92,7 @@
 }
 
 void Log::Enable(const std::shared_ptr<LogHandler> &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<MaskType>::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<MaskType>::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<MaskType>::max());
 }
 
 void Log::ForEachChannelCategory(
Index: lldb/include/lldb/Utility/Log.h
===================================================================
--- lldb/include/lldb/Utility/Log.h
+++ 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<LogHandler> &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<const char *> categories);
+  static Log::MaskType GetFlags(llvm::raw_ostream &stream,
+                                const ChannelMap::value_type &entry,
+                                llvm::ArrayRef<const char *> categories);
 
   Log(const Log &) = delete;
   void operator=(const Log &) = delete;
Index: lldb/include/lldb/Utility/LLDBLog.h
===================================================================
--- lldb/include/lldb/Utility/LLDBLog.h
+++ 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();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] ... Jonas Devlieghere via Phabricator via lldb-commits
    • [Lldb-commits] [PA... Jonas Devlieghere via Phabricator via lldb-commits

Reply via email to