[Lldb-commits] [PATCH] Initialize ProcessPOSIXLog by NativeProcessLinux

Tamas Berghammer tberghammer at google.com
Thu Mar 5 10:22:25 PST 2015


http://reviews.llvm.org/D8080

Files:
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.h
  tools/lldb-server/lldb-gdbserver.cpp

Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1125,6 +1125,27 @@
 // Public Static Methods
 // -----------------------------------------------------------------------------
 
+void
+NativeProcessLinux::Initialize()
+{
+    static ConstString g_name("linux");
+    static bool g_initialized = false;
+
+    if (!g_initialized)
+    {
+        g_initialized = true;
+
+        Log::Callbacks log_callbacks = {
+            ProcessPOSIXLog::DisableLog,
+            ProcessPOSIXLog::EnableLog,
+            ProcessPOSIXLog::ListLogCategories
+        };
+
+        Log::RegisterLogChannel (g_name, log_callbacks);
+        ProcessPOSIXLog::RegisterPluginName (g_name);
+    }
+}
+
 lldb_private::Error
 NativeProcessLinux::LaunchProcess (
     lldb_private::Module *exe_module,
Index: source/Plugins/Process/Linux/NativeProcessLinux.h
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.h
+++ source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -48,6 +48,9 @@
         // ---------------------------------------------------------------------
         // Public Static Methods
         // ---------------------------------------------------------------------
+        static void
+        Initialize();
+
         static lldb_private::Error
         LaunchProcess (
             Module *exe_module,
Index: tools/lldb-server/lldb-gdbserver.cpp
===================================================================
--- tools/lldb-server/lldb-gdbserver.cpp
+++ tools/lldb-server/lldb-gdbserver.cpp
@@ -40,6 +40,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
 #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
+#include "Plugins/Process/Linux/NativeProcessLinux.h"
 
 #ifndef LLGS_PROGRAM_NAME
 #define LLGS_PROGRAM_NAME "lldb-gdbserver"
@@ -481,18 +482,31 @@
     }
 }
 
-//----------------------------------------------------------------------
-// main
-//----------------------------------------------------------------------
-int
-main_gdbserver (int argc, char *argv[])
+static void
+initialize ()
 {
 #ifndef _WIN32
     // Setup signal handlers first thing.
     signal (SIGPIPE, signal_handler);
     signal (SIGHUP, signal_handler);
 #endif
 
+#if defined (__linux__)
+    //----------------------------------------------------------------------
+    // Linux hosted plugins
+    //----------------------------------------------------------------------
+    NativeProcessLinux::Initialize();
+#endif
+}
+
+//----------------------------------------------------------------------
+// main
+//----------------------------------------------------------------------
+int
+main_gdbserver (int argc, char *argv[])
+{
+    initialize ();
+
     const char *progname = argv[0];
     const char *subcommand = argv[1];
     argc--;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8080.21286.patch
Type: text/x-patch
Size: 3080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150305/cd16d3e6/attachment.bin>


More information about the lldb-commits mailing list