[Lldb-commits] [lldb] r124024 - in /lldb/trunk: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Symbol/ClangASTContext.cpp source/Symbol/ClangASTType.cpp source/Target/Process.cpp tools/debugserver/source/RNBRemote.cpp

Greg Clayton gclayton at apple.com
Fri Jan 21 23:12:45 PST 2011


Author: gclayton
Date: Sat Jan 22 01:12:45 2011
New Revision: 124024

URL: http://llvm.org/viewvc/llvm-project?rev=124024&view=rev
Log:
Sped up the shutdown time on MacOSX by quite a bit by making sure any
threads that we spawn let us know when they are going away and that we
don't timeout waiting for a message from threads that have gone away.
We also now don't expect the "k" packet (kill) to send a response. This
greatly speeds up debugger shutdown performance. The test suite now runs
quite a bit faster.

Added a fix to the variable display code that fixes the display of
base classes. We were assuming the virtual or normal base class offsets
were being given in bit sizes, but they were being given as character
sizes, so we needed to multiply the offset by 8. This wasn't affecting
the expression parser, but it was affecting the correct display of C++
class base classes and all of their children.


Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Sat Jan 22 01:12:45 2011
@@ -87,15 +87,24 @@
 }
 
 size_t
-GDBRemoteCommunication::SendAck (char ack_char)
+GDBRemoteCommunication::SendAck ()
 {
-    Mutex::Locker locker(m_sequence_mutex);
-    ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: %c", ack_char);
+    ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: +");
     ConnectionStatus status = eConnectionStatusSuccess;
+    char ack_char = '+';
     return Write (&ack_char, 1, status, NULL) == 1;
 }
 
 size_t
+GDBRemoteCommunication::SendNack ()
+{
+    ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: -");
+    ConnectionStatus status = eConnectionStatusSuccess;
+    char nack_char = '-';
+    return Write (&nack_char, 1, status, NULL) == 1;
+}
+
+size_t
 GDBRemoteCommunication::SendPacketAndWaitForResponse
 (
     const char *payload,
@@ -141,7 +150,8 @@
             m_async_packet_predicate.SetValue (true, eBroadcastNever);
             
             bool timed_out = false;
-            if (SendInterrupt(locker, 1, &timed_out))
+            bool sent_interrupt = false;
+            if (SendInterrupt(locker, 1, sent_interrupt, timed_out))
             {
                 if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out))
                 {
@@ -443,8 +453,9 @@
 {
     m_async_signal = signo;
     bool timed_out = false;
+    bool sent_interrupt = false;
     Mutex::Locker locker;
-    if (SendInterrupt (locker, 1, &timed_out))
+    if (SendInterrupt (locker, 1, sent_interrupt, timed_out))
         return true;
     m_async_signal = -1;
     return false;
@@ -461,10 +472,16 @@
 // (gdb remote protocol requires this), and do what we need to do, then resume.
 
 bool
-GDBRemoteCommunication::SendInterrupt (Mutex::Locker& locker, uint32_t seconds_to_wait_for_stop, bool *timed_out)
+GDBRemoteCommunication::SendInterrupt 
+(
+    Mutex::Locker& locker, 
+    uint32_t seconds_to_wait_for_stop,             
+    bool &sent_interrupt,
+    bool &timed_out
+)
 {
-    if (timed_out)
-        *timed_out = false;
+    sent_interrupt = false;
+    timed_out = false;
 
     if (IsConnected() && IsRunning())
     {
@@ -484,8 +501,9 @@
             ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: \\x03");
             if (Write (&ctrl_c, 1, status, NULL) > 0)
             {
+                sent_interrupt = true;
                 if (seconds_to_wait_for_stop)
-                    m_private_is_running.WaitForValueEqualTo (false, &timeout, timed_out);
+                    m_private_is_running.WaitForValueEqualTo (false, &timeout, &timed_out);
                 return true;
             }
         }
@@ -553,9 +571,9 @@
                             checksum_error = packet_checksum != actual_checksum;
                             // Send the ack or nack if needed
                             if (checksum_error || !success)
-                                SendAck('-');
+                                SendNack();
                             else
-                                SendAck('+');
+                                SendAck();
                         }
                     }
                     else

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Sat Jan 22 01:12:45 2011
@@ -87,7 +87,11 @@
     GetAck (uint32_t timeout_seconds);
 
     size_t
-    SendAck (char ack_char);
+    SendAck ();
+
+    size_t
+    SendNack ();
+
 
     char
     CalculcateChecksum (const char *payload,
@@ -117,7 +121,8 @@
     bool
     SendInterrupt (lldb_private::Mutex::Locker &locker, 
                    uint32_t seconds_to_wait_for_stop, 
-                   bool *timed_out = NULL);
+                   bool &sent_interrupt, 
+                   bool &timed_out);
 
     bool
     GetSequenceMutex(lldb_private::Mutex::Locker& locker);

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=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sat Jan 22 01:12:45 2011
@@ -541,7 +541,7 @@
     if (m_gdb_comm.StartReadThread(&error))
     {
         // Send an initial ack
-        m_gdb_comm.SendAck('+');
+        m_gdb_comm.SendAck();
 
         if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
             m_debugserver_thread = Host::StartMonitoringChildProcess (MonitorDebugserverProcess,
@@ -1141,24 +1141,16 @@
 ProcessGDBRemote::DoHalt (bool &caused_stop)
 {
     Error error;
-    
-    if (m_gdb_comm.IsRunning())
-    {
-        caused_stop = true;
-        bool timed_out = false;
-        Mutex::Locker locker;
 
-        if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
-        {
-            if (timed_out)
-                error.SetErrorString("timed out sending interrupt packet");
-            else
-                error.SetErrorString("unknown error sending interrupt packet");
-        }
-    }
-    else
+    bool timed_out = false;
+    Mutex::Locker locker;
+
+    if (!m_gdb_comm.SendInterrupt (locker, 2, caused_stop, timed_out))
     {
-        caused_stop = false;
+        if (timed_out)
+            error.SetErrorString("timed out sending interrupt packet");
+        else
+            error.SetErrorString("unknown error sending interrupt packet");
     }
 
     return error;
@@ -1172,11 +1164,12 @@
     if (m_gdb_comm.IsRunning())
     {
         bool timed_out = false;
+        bool sent_interrupt = false;
         Mutex::Locker locker;
         PausePrivateStateThread();
         m_thread_list.DiscardThreadPlans();
         m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
-        if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
+        if (!m_gdb_comm.SendInterrupt (locker, 2, sent_interrupt, timed_out))
         {
             if (timed_out)
                 error.SetErrorString("timed out sending interrupt packet");
@@ -1238,22 +1231,10 @@
         log->Printf ("ProcessGDBRemote::DoDestroy()");
 
     // Interrupt if our inferior is running...
-    Mutex::Locker locker;
-    m_gdb_comm.SendInterrupt (locker, 1);
-    DisableAllBreakpointSites ();
-    SetExitStatus(-1, "process killed");
-
-    StringExtractorGDBRemote response;
-    if (m_gdb_comm.SendPacketAndWaitForResponse("k", response, 1, false))
+    if (m_gdb_comm.IsConnected())
     {
-        log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
-        if (log)
-        {
-            if (response.IsOKPacket())
-                log->Printf ("ProcessGDBRemote::DoDestroy() kill was successful");
-            else
-                log->Printf ("ProcessGDBRemote::DoDestroy() kill failed: %s", response.GetStringRef().c_str());
-        }
+        // Don't get a response when killing our
+        m_gdb_comm.SendPacket ("k", 1);
     }
 
     StopAsyncThread ();

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sat Jan 22 01:12:45 2011
@@ -2475,9 +2475,9 @@
 
 
                             if (base_class->isVirtual())
-                                bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity();
+                                bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
                             else
-                                bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity();
+                                bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
 
                             // Base classes should be a multiple of 8 bits in size
                             assert (bit_offset % 8 == 0);

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Sat Jan 22 01:12:45 2011
@@ -392,9 +392,9 @@
                         continue;
 
                     if (base_class->isVirtual())
-                        field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity();
+                        field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
                     else
-                        field_bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity();
+                        field_bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
                     field_byte_offset = field_bit_offset / 8;
                     assert (field_bit_offset % 8 == 0);
                     if (child_idx == 0)

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sat Jan 22 01:12:45 2011
@@ -407,7 +407,6 @@
                                                        event_sp))
         state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
 
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
     if (log)
         log->Printf ("Process::%s (timeout = %p, event_sp) => %s",
                      __FUNCTION__,
@@ -427,7 +426,6 @@
     Event *event_ptr;
     event_ptr = m_listener.PeekAtNextEventForBroadcasterWithType (this,
                                                                   eBroadcastBitStateChanged);
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
     if (log)
     {
         if (event_ptr)
@@ -463,7 +461,6 @@
     // This is a bit of a hack, but when we wait here we could very well return
     // to the command-line, and that could disable the log, which would render the
     // log we got above invalid.
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
     if (log)
         log->Printf ("Process::%s (timeout = %p, event_sp) => %s", __FUNCTION__, timeout, StateAsCString(state));
     return state;
@@ -2140,7 +2137,6 @@
                 break;
             }
             
-            log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
             if (log)
                 log->Printf ("Process::%s (arg = %p, pid = %i) got a control event: %d", __FUNCTION__, this, GetID(), event_sp->GetType());
 
@@ -2160,7 +2156,6 @@
             internal_state == eStateExited  ||
             internal_state == eStateDetached )
         {
-            log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
             if (log)
                 log->Printf ("Process::%s (arg = %p, pid = %i) about to exit with internal state %s...", __FUNCTION__, this, GetID(), StateAsCString(internal_state));
 
@@ -2169,10 +2164,11 @@
     }
 
     // Verify log is still enabled before attempting to write to it...
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
     if (log)
         log->Printf ("Process::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, this, GetID());
 
+    m_private_state_control_wait.SetValue (true, eBroadcastAlways);
+    m_private_state_thread = LLDB_INVALID_HOST_THREAD;
     return NULL;
 }
 

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=124024&r1=124023&r2=124024&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Sat Jan 22 01:12:45 2011
@@ -3123,11 +3123,10 @@
 rnb_err_t
 RNBRemote::HandlePacket_k (const char *p)
 {
-    if (!m_ctx.HasValidProcessID())
-        return SendPacket ("E26");
-    if (!DNBProcessKill (m_ctx.ProcessID()))
-        return SendPacket ("E27");
-    return SendPacket ("OK");
+    // No response to should be sent to the kill packet
+    if (m_ctx.HasValidProcessID())
+        DNBProcessKill (m_ctx.ProcessID());
+    return rnb_success;
 }
 
 rnb_err_t





More information about the lldb-commits mailing list