[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 15 16:36:13 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcf18e4757b2: [debugserver] Initialize logging earlier in the startup sequence (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144142

Files:
  lldb/tools/debugserver/source/debugserver.cpp


Index: lldb/tools/debugserver/source/debugserver.cpp
===================================================================
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+    // if os_log() support is available, log through that.
+    DNBLogSetLogCallback(log_callback, nullptr);
+    DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+    // Fall back to ASL support.
+    DNBLogSetLogCallback(ASLLogCallback, nullptr);
+    DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared<RNBRemote>();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+    DNBLog("debugserver is switching to logging to a file.");
     DNBLogSetLogCallback(FileLogCallback, log_file);
     // If our log file was set, yet we have no log flags, log everything!
     if (log_flags == 0)
       log_flags = LOG_ALL | LOG_RNB_ALL;
-
-    DNBLogSetLogMask(log_flags);
-  } else {
-    // Enable DNB logging
-
-    // if os_log() support is available, log through that.
-    auto log_callback = OsLogger::GetLogFunction();
-    if (log_callback) {
-      DNBLogSetLogCallback(log_callback, nullptr);
-      DNBLog("debugserver will use os_log for internal logging.");
-    } else {
-      // Fall back to ASL support.
-      DNBLogSetLogCallback(ASLLogCallback, NULL);
-      DNBLog("debugserver will use ASL for internal logging.");
-    }
-    DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
     for (i = 0; i < argc; i++)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144142.497843.patch
Type: text/x-patch
Size: 2076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230216/a6ba0711/attachment-0001.bin>


More information about the lldb-commits mailing list