[Lldb-commits] [lldb] r124080 - in /lldb/trunk/source: Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Target/Process.cpp

Greg Clayton gclayton at apple.com
Sun Jan 23 11:58:50 PST 2011


Author: gclayton
Date: Sun Jan 23 13:58:49 2011
New Revision: 124080

URL: http://llvm.org/viewvc/llvm-project?rev=124080&view=rev
Log:
Improved process logging for both lldb_private::Process and ProcessGDBRemote.


Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=124080&r1=124079&r2=124080&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun Jan 23 13:58:49 2011
@@ -1181,18 +1181,35 @@
 {
     Error error;
 
-    if (m_gdb_comm.IsRunning())
+    LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+    
+    const bool is_running = m_gdb_comm.IsRunning();
+    if (log)
+        log->Printf ("ProcessGDBRemote::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i, resume_private_state_thread=%i) is_running=%i", 
+                     discard_thread_plans, 
+                     catch_stop_event, 
+                     resume_private_state_thread,
+                     is_running);
+
+    if (catch_stop_event)
+    {
+        if (log)
+            log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread");
+        PausePrivateStateThread();
+    }
+    
+    if (discard_thread_plans)
+    {
+        if (log)
+            log->Printf ("ProcessGDBRemote::InterruptIfRunning() discarding all thread plans");
+        m_thread_list.DiscardThreadPlans();
+    }
+    if (is_running)
     {
         bool timed_out = false;
         bool sent_interrupt = false;
         Mutex::Locker locker;
         
-        if (catch_stop_event)
-            PausePrivateStateThread();
-        
-        if (discard_thread_plans)
-            m_thread_list.DiscardThreadPlans();
-
         //m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
         if (!m_gdb_comm.SendInterrupt (locker, 1, sent_interrupt, timed_out))
         {
@@ -1205,20 +1222,27 @@
             return error;
         }
         
-        
         if (catch_stop_event)
         {
             TimeValue timeout_time;
             timeout_time = TimeValue::Now();
             timeout_time.OffsetWithSeconds(1);
             StateType state = WaitForProcessStopPrivate (&timeout_time, stop_event_sp);
+    
+            const bool timed_out = state == eStateInvalid;
+            if (log)
+                log->Printf ("ProcessGDBRemote::InterruptIfRunning() catch stop event: state = %s, timed-out=%i", StateAsCString(state), timed_out);
 
-            if (state == eStateInvalid)
+            if (timed_out)
                 error.SetErrorString("unable to verify target stopped");
         }
         
         if (catch_stop_event && resume_private_state_thread)
+        {
+            if (log)
+                log->Printf ("ProcessGDBRemote::InterruptIfRunning() resuming private state thread");
             ResumePrivateStateThread();
+        }
     }
     return error;
 }
@@ -1226,6 +1250,10 @@
 Error
 ProcessGDBRemote::WillDetach ()
 {
+    LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+    if (log)
+        log->Printf ("ProcessGDBRemote::WillDetach()");
+
     bool discard_thread_plans = true; 
     bool catch_stop_event = true;
     bool resume_private_state_thread = false; // DoDetach will resume the thread
@@ -1269,11 +1297,16 @@
 Error
 ProcessGDBRemote::WillDestroy ()
 {
+    LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+    if (log)
+        log->Printf ("ProcessGDBRemote::WillDestroy()");
     bool discard_thread_plans = true; 
     bool catch_stop_event = true;
     bool resume_private_state_thread = true;
     EventSP event_sp;
-    return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);    
+    return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);
+    
+
 }
 
 Error

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=124080&r1=124079&r2=124080&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sun Jan 23 13:58:49 2011
@@ -1398,13 +1398,31 @@
 {
     // Fixme: we should track the blocks we've allocated, and clean them up...
     // We could even do our own allocator here if that ends up being more efficient.
-    return DoAllocateMemory (size, permissions, error);
+    addr_t allocated_addr = DoAllocateMemory (size, permissions, error);
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+    if (log)
+        log->Printf("Process::AllocateMemory(size = %zu, permissions=%c%c%c) => 0x%16.16llx (m_stop_id = %u)", 
+                    size, 
+                    permissions & ePermissionsReadable ? 'r' : '-',
+                    permissions & ePermissionsWritable ? 'w' : '-',
+                    permissions & ePermissionsExecutable ? 'x' : '-',
+                    (uint64_t)allocated_addr,
+                    m_stop_id);
+    return allocated_addr;
 }
 
 Error
 Process::DeallocateMemory (addr_t ptr)
 {
-    return DoDeallocateMemory (ptr);
+    Error error(DoDeallocateMemory (ptr));
+    
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+    if (log)
+        log->Printf("Process::DeallocateMemory(addr=0x%16.16llx) => err = %s (m_stop_id = %u)", 
+                    ptr, 
+                    error.AsCString("SUCCESS"),
+                    m_stop_id);
+    return error;
 }
 
 





More information about the lldb-commits mailing list