[Lldb-commits] [lldb] r178242 - Fix the Linux build issues introduced by r178191.

Ashok Thirumurthi ashok.thirumurthi at intel.com
Thu Mar 28 09:02:32 PDT 2013


Author: athirumu
Date: Thu Mar 28 11:02:31 2013
New Revision: 178242

URL: http://llvm.org/viewvc/llvm-project?rev=178242&view=rev
Log:
Fix the Linux build issues introduced by r178191.

- All Linux logging channels now use a single global instance of lldb_private::Log, to handle the case of logging during process tear down.
- Also removed a single use of LogSP in FreeBSD and fixed a typo in a comment while reading through ProcessKDPLog.

Reviewed by Daniel Malea.

Modified:
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
    lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
    lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
    lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Thu Mar 28 11:02:31 2013
@@ -66,7 +66,7 @@ PtraceWrapper(int req, lldb::pid_t pid,
 {
     long int result;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
 
     if (log) {
         log->Printf("ptrace(%s, %u, %p, %x) called from file %s line %d",

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Thu Mar 28 11:02:31 2013
@@ -74,7 +74,7 @@ DisplayBytes (lldb_private::StreamString
 static void PtraceDisplayBytes(int &req, void *data, size_t data_size)
 {
     StreamString buf;
-    LogSP verbose_log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (
+    Log *verbose_log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (
                                         POSIX_LOG_PTRACE | POSIX_LOG_VERBOSE));
 
     if (verbose_log)
@@ -139,7 +139,7 @@ PtraceWrapper(int req, lldb::pid_t pid,
 {
     long int result;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PTRACE));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PTRACE));
 
     if (log)
         log->Printf("ptrace(%s, %lu, %p, %p, %zu) called from file %s line %d",
@@ -208,7 +208,7 @@ DoReadMemory(lldb::pid_t pid,
     size_t remainder;
     long data;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
     if (log)
         ProcessPOSIXLog::IncNestLevel();
     if (log && ProcessPOSIXLog::AtTopNestLevel() && log->GetMask().Test(POSIX_LOG_MEMORY))
@@ -267,7 +267,7 @@ DoWriteMemory(lldb::pid_t pid,
     size_t bytes_written = 0;
     size_t remainder;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
     if (log)
         ProcessPOSIXLog::IncNestLevel();
     if (log && ProcessPOSIXLog::AtTopNestLevel() && log->GetMask().Test(POSIX_LOG_MEMORY))
@@ -462,7 +462,7 @@ private:
 void
 ReadRegOperation::Execute(ProcessMonitor *monitor)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
 
     // Set errno to zero so that we can detect a failed peek.
     errno = 0;
@@ -504,7 +504,7 @@ void
 WriteRegOperation::Execute(ProcessMonitor *monitor)
 {
     void* buf;
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
 
 #if __WORDSIZE == 32
     buf = (void*) m_value.GetAsUInt32();
@@ -1083,7 +1083,7 @@ ProcessMonitor::Launch(LaunchArgs *args)
     long ptrace_opts = 0;
 
     lldb::ThreadSP inferior;
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
 
     // Propagate the environment if one is not supplied.
     if (envp == NULL || envp[0] == NULL)
@@ -1282,7 +1282,7 @@ ProcessMonitor::Attach(AttachArgs *args)
     ProcessMonitor *monitor = args->m_monitor;
     ProcessLinux &process = monitor->GetProcess();
     lldb::ThreadSP inferior;
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
 
     if (pid <= 1)
     {

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp Thu Mar 28 11:02:31 2013
@@ -20,7 +20,7 @@ using namespace lldb_private;
 
 // We want to avoid global constructors where code needs to be run so here we
 // control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_lob_sp the first time this function is 
+// that will construct the static g_log_sp the first time this function is 
 // called.
 static bool g_log_enabled = false;
 static Log * g_log = NULL;

Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp Thu Mar 28 11:02:31 2013
@@ -39,7 +39,7 @@ POSIXThread::POSIXThread(Process &proces
     : Thread(process, tid),
       m_frame_ap(0)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("POSIXThread::%s (tid = %" PRIi64 ")", __FUNCTION__, tid);
 }
@@ -60,7 +60,7 @@ POSIXThread::GetMonitor()
 void
 POSIXThread::RefreshStateAfterStop()
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("POSIXThread::%s ()", __FUNCTION__);
 
@@ -110,7 +110,7 @@ POSIXThread::CreateRegisterContextForFra
     lldb::RegisterContextSP reg_ctx_sp;
     uint32_t concrete_frame_idx = 0;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("POSIXThread::%s ()", __FUNCTION__);
 
@@ -165,7 +165,7 @@ POSIXThread::Resume()
     ProcessMonitor &monitor = GetMonitor();
     bool status;
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("POSIXThread::%s ()", __FUNCTION__);
 
@@ -197,7 +197,7 @@ POSIXThread::Resume()
 void
 POSIXThread::Notify(const ProcessMessage &message)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log)
         log->Printf ("POSIXThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind());
 
@@ -241,7 +241,7 @@ void
 POSIXThread::BreakNotify(const ProcessMessage &message)
 {
     bool status;
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
 
     assert(GetRegisterContext());
     status = GetRegisterContextPOSIX()->UpdateAfterBreakpoint();
@@ -300,7 +300,7 @@ POSIXThread::CrashNotify(const ProcessMe
 
     assert(message.GetKind() == ProcessMessage::eCrashMessage);
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log)
         log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason());
 

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Thu Mar 28 11:02:31 2013
@@ -107,7 +107,7 @@ ProcessPOSIX::DoAttachToProcessWithID(ll
     Error error;
     assert(m_monitor == NULL);
 
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessPOSIX::%s(pid = %" PRIi64 ")", __FUNCTION__, GetID());
 
@@ -390,7 +390,7 @@ ProcessPOSIX::SendMessage(const ProcessM
 void
 ProcessPOSIX::RefreshStateAfterStop()
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessPOSIX::%s()", __FUNCTION__);
 
@@ -546,7 +546,7 @@ ProcessPOSIX::UpdateThreadListIfNeeded()
 bool
 ProcessPOSIX::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessPOSIX::%s() (pid = %" PRIi64 ")", __FUNCTION__, GetID());
 

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp Thu Mar 28 11:02:31 2013
@@ -21,24 +21,28 @@ using namespace lldb_private;
 
 // We want to avoid global constructors where code needs to be run so here we
 // control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_lob_sp the first time this function is 
+// that will construct the static g_log_sp the first time this function is 
 // called.
-static LogSP &
+static bool g_log_enabled = false;
+static Log * g_log = NULL;
+static Log *
 GetLog ()
 {
-    static LogSP g_log_sp;
-    return g_log_sp;
+    if (!g_log_enabled)
+        return NULL;
+    return g_log;
 }
 
-LogSP
+
+Log *
 ProcessPOSIXLog::GetLogIfAllCategoriesSet (uint32_t mask)
 {
-    LogSP log(GetLog ());
+    Log *log(GetLog ());
     if (log && mask)
     {
         uint32_t log_mask = log->GetMask().Get();
         if ((log_mask & mask) != mask)
-            return LogSP();
+            return NULL;
     }
     return log;
 }
@@ -46,7 +50,7 @@ ProcessPOSIXLog::GetLogIfAllCategoriesSe
 void
 ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm)
 {
-    LogSP log (GetLog ());
+    Log *log (GetLog ());
     if (log)
     {
         uint32_t flag_bits = 0;
@@ -79,33 +83,33 @@ ProcessPOSIXLog::DisableLog (const char
             }
         }
         
+        log->GetMask().Reset (flag_bits);
         if (flag_bits == 0)
-            GetLog ().reset();
-        else
-            log->GetMask().Reset (flag_bits);
+            g_log_enabled = false;
     }
     
     return;
 }
 
-LogSP
+Log *
 ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **args, Stream *feedback_strm)
 {
     // Try see if there already is a log - that way we can reuse its settings.
     // We could reuse the log in toto, but we don't know that the stream is the same.
     uint32_t flag_bits = 0;
-    LogSP log(GetLog ());
-    if (log)
-        flag_bits = log->GetMask().Get();
+    if (g_log)
+        flag_bits = g_log->GetMask().Get();
 
     // Now make a new log with this stream if one was provided
     if (log_stream_sp)
     {
-        log = LogSP(new Log(log_stream_sp));
-        GetLog () = log;
+        if (g_log)
+            g_log->SetStream(log_stream_sp);
+        else
+            g_log = new Log(log_stream_sp);
     }
 
-    if (log)
+    if (g_log)
     {
         bool got_unknown_category = false;
         for (; args[0]; args++)
@@ -140,10 +144,11 @@ ProcessPOSIXLog::EnableLog (StreamSP &lo
         }
         if (flag_bits == 0)
             flag_bits = POSIX_LOG_DEFAULT;
-        log->GetMask().Reset(flag_bits);
-        log->GetOptions().Reset(log_options);
+        g_log->GetMask().Reset(flag_bits);
+        g_log->GetOptions().Reset(log_options);
+        g_log_enabled = true;
     }
-    return log;
+    return g_log;
 }
 
 void
@@ -174,7 +179,7 @@ ProcessPOSIXLog::ListLogCategories (Stre
 void
 ProcessPOSIXLog::LogIf (uint32_t mask, const char *format, ...)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (mask));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (mask));
     if (log)
     {
         va_list args;

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h Thu Mar 28 11:02:31 2013
@@ -50,13 +50,13 @@ public:
     }
 
 
-    static lldb::LogSP
+    static lldb_private::Log *
     GetLogIfAllCategoriesSet(uint32_t mask = 0);
 
     static void
     DisableLog (const char **args, lldb_private::Stream *feedback_strm);
 
-    static lldb::LogSP
+    static lldb_private::Log *
     EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options,
                const char **args, lldb_private::Stream *feedback_strm);
 

Modified: lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp?rev=178242&r1=178241&r2=178242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp Thu Mar 28 11:02:31 2013
@@ -516,7 +516,7 @@ RegisterContext_i386::HardwareSingleStep
 void
 RegisterContext_i386::LogGPR(const char *title)
 {
-    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
     if (log)
     {
         if (title)





More information about the lldb-commits mailing list