[Lldb-commits] [lldb] r131628 - in /lldb/trunk/source: Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Target/Thread.cpp Target/ThreadPlanCallFunction.cpp

Greg Clayton gclayton at apple.com
Wed May 18 20:54:16 PDT 2011


Author: gclayton
Date: Wed May 18 22:54:16 2011
New Revision: 131628

URL: http://llvm.org/viewvc/llvm-project?rev=131628&view=rev
Log:
Fixed a crasher that was happened when a log shared pointer wasn't valid.

Fixed ThreadPlanCallFunction::ReportRegisterState(...) to only dump when
verbose logging is enabled and fixed the function to use the new
RegisterValue method of reading registers.

Fixed the GDB remote client to not send a continue packet after receiving
stdout or stderr from the inferior process.


Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanCallFunction.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131628&r1=131627&r2=131628&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Wed May 18 22:54:16 2011
@@ -361,14 +361,21 @@
     // make change if we are interrupted and we continue after an async packet...
     std::string continue_packet(payload, packet_length);
     
+    bool got_stdout = false;
+    
     while (state == eStateRunning)
     {
-        if (log)
-            log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str());
-        if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0)
-            state = eStateInvalid;
+        if (!got_stdout)
+        {
+            if (log)
+                log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str());
+            if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0)
+                state = eStateInvalid;
+        
+            m_private_is_running.SetValue (true, eBroadcastNever);
+        }
         
-        m_private_is_running.SetValue (true, eBroadcastNever);
+        got_stdout = false;
 
         if (log)
             log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__);
@@ -489,6 +496,7 @@
                 case 'O':
                     // STDOUT
                     {
+                        got_stdout = true;
                         std::string inferior_stdout;
                         inferior_stdout.reserve(response.GetBytesLeft () / 2);
                         char ch;

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=131628&r1=131627&r2=131628&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Wed May 18 22:54:16 2011
@@ -266,7 +266,7 @@
         {
             should_stop = current_plan->ShouldStop (event_ptr);
             if (log)
-                log->Printf("Base plan says should stop: %d.", current_plan->GetName(), should_stop);
+                log->Printf("Base plan says should stop: %i.", should_stop);
         }
         else
         {

Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131628&r1=131627&r2=131628&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed May 18 22:54:16 2011
@@ -197,8 +197,9 @@
         m_start_addr = objectFile->GetEntryPointAddress();
         if (!m_start_addr.IsValid())
         {
-            log->Printf ("Could not find entry point address for executable module \"%s\".", 
-                         executableModuleSP->GetFileSpec().GetFilename().AsCString());
+            if (log)
+                log->Printf ("Could not find entry point address for executable module \"%s\".", 
+                             executableModuleSP->GetFileSpec().GetFilename().AsCString());
             return;
         }
     }
@@ -247,22 +248,28 @@
 void
 ThreadPlanCallFunction::ReportRegisterState (const char *message)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
     if (log)
     {
+        StreamString strm;
         RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
 
         log->PutCString(message);
 
-        for (uint32_t register_index = 0, num_registers = reg_ctx->GetRegisterCount();
-             register_index < num_registers;
-             ++register_index)
+        RegisterValue reg_value;
+
+        for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
+             reg_idx < num_registers;
+             ++reg_idx)
         {
-            const char *register_name = reg_ctx->GetRegisterName(register_index);
-            uint64_t register_value = reg_ctx->ReadRegisterAsUnsigned(register_index, LLDB_INVALID_ADDRESS);
-            
-            log->Printf("  %s = 0x%llx", register_name, register_value);
+            const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
+            if (reg_ctx->ReadRegister(reg_info, reg_value))
+            {
+                reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
+                strm.EOL();
+            }
         }
+        log->PutCString(strm.GetData());
     }
 }
 





More information about the lldb-commits mailing list