[Lldb-commits] [PATCH] D121161: [lldb] Avoid global constructor in LLDBLog.cpp

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 7 13:53:43 PST 2022


JDevlieghere created this revision.
JDevlieghere added a reviewer: labath.
Herald added a project: All.
JDevlieghere requested review of this revision.

Avoid a static initializer for Log::Channel in LLDBLog.cpp


https://reviews.llvm.org/D121161

Files:
  lldb/source/Utility/LLDBLog.cpp


Index: lldb/source/Utility/LLDBLog.cpp
===================================================================
--- lldb/source/Utility/LLDBLog.cpp
+++ lldb/source/Utility/LLDBLog.cpp
@@ -62,18 +62,16 @@
     {{"watch"}, {"log watchpoint related activities"}, LLDBLog::Watchpoints},
 };
 
-static Log::Channel g_log_channel(g_categories,
-                                  LLDBLog::Process | LLDBLog::Thread |
-                                      LLDBLog::DynamicLoader |
-                                      LLDBLog::Breakpoints |
-                                      LLDBLog::Watchpoints | LLDBLog::Step |
-                                      LLDBLog::State | LLDBLog::Symbols |
-                                      LLDBLog::Target | LLDBLog::Commands);
 
 template <> Log::Channel &lldb_private::LogChannelFor<LLDBLog>() {
+  static Log::Channel g_log_channel(
+      g_categories, LLDBLog::Process | LLDBLog::Thread |
+                        LLDBLog::DynamicLoader | LLDBLog::Breakpoints |
+                        LLDBLog::Watchpoints | LLDBLog::Step | LLDBLog::State |
+                        LLDBLog::Symbols | LLDBLog::Target | LLDBLog::Commands);
   return g_log_channel;
 }
 
 void lldb_private::InitializeLldbChannel() {
-  Log::Register("lldb", g_log_channel);
+  Log::Register("lldb", lldb_private::LogChannelFor<LLDBLog>());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121161.413624.patch
Type: text/x-patch
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220307/8ea567e3/attachment.bin>


More information about the lldb-commits mailing list