Initialize ProcessPOSIXLog by NativeProcessLinux
authorTamas Berghammer <tberghammer@google.com>
Fri, 6 Mar 2015 15:47:23 +0000 (15:47 +0000)
committerTamas Berghammer <tberghammer@google.com>
Fri, 6 Mar 2015 15:47:23 +0000 (15:47 +0000)
Previously it was initialized by ProcessLinux but lldb-server don't
contain ProcessLinux anymore so it have to be initialized by
NativeProcessLinux also.

Differential revision: http://reviews.llvm.org/D8080

llvm-svn: 231482

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

index 78b98f2..9b91751 100644 (file)
@@ -1125,6 +1125,27 @@ NativeProcessLinux::AttachArgs::~AttachArgs()
 // 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 76aff7d..7484fea 100644 (file)
@@ -48,6 +48,9 @@ namespace lldb_private
         // ---------------------------------------------------------------------
         // Public Static Methods
         // ---------------------------------------------------------------------
+        static void
+        Initialize();
+
         static lldb_private::Error
         LaunchProcess (
             Module *exe_module,
index 076c7c4..dc3f6fa 100644 (file)
@@ -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-server"
@@ -481,11 +482,8 @@ ConnectToRemote (GDBRemoteCommunicationServerLLGS &gdb_server, bool reverse_conn
     }
 }
 
-//----------------------------------------------------------------------
-// main
-//----------------------------------------------------------------------
-int
-main_gdbserver (int argc, char *argv[])
+static void
+initialize ()
 {
 #ifndef _WIN32
     // Setup signal handlers first thing.
@@ -493,6 +491,22 @@ main_gdbserver (int argc, char *argv[])
     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--;