[Lldb-commits] [lldb] r251301 - [lldb-server] Send PC of every thread along in the stop-reply packet

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 26 09:25:29 PDT 2015


Author: labath
Date: Mon Oct 26 11:25:28 2015
New Revision: 251301

URL: http://llvm.org/viewvc/llvm-project?rev=251301&view=rev
Log:
[lldb-server] Send PC of every thread along in the stop-reply packet

This avoids the need to query the PC for private resume operations (public resumes have the PC
from the bigger jStopInfo packet) and speeds up the stepping on an android target by about 10%
(it some cases even more).

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

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=251301&r1=251300&r2=251301&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Mon Oct 26 11:25:28 2015
@@ -426,7 +426,7 @@ WriteRegisterValueInHexFixedWidth (Strea
 }
 
 static JSONObject::SP
-GetRegistersAsJSON(NativeThreadProtocol &thread)
+GetRegistersAsJSON(NativeThreadProtocol &thread, bool abridged)
 {
     Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_THREAD));
 
@@ -448,11 +448,17 @@ GetRegistersAsJSON(NativeThreadProtocol
     // Expedite only a couple of registers until we figure out why sending registers is
     // expensive.
     static const uint32_t k_expedited_registers[] = {
-        LLDB_REGNUM_GENERIC_PC, LLDB_REGNUM_GENERIC_SP, LLDB_REGNUM_GENERIC_FP, LLDB_REGNUM_GENERIC_RA
+        LLDB_REGNUM_GENERIC_PC, LLDB_REGNUM_GENERIC_SP, LLDB_REGNUM_GENERIC_FP, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM
     };
-    for (uint32_t generic_reg: k_expedited_registers)
+    static const uint32_t k_abridged_expedited_registers[] = {
+        LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM
+    };
+
+    for (const uint32_t *generic_reg_p = abridged ? k_abridged_expedited_registers : k_expedited_registers;
+         *generic_reg_p != LLDB_INVALID_REGNUM;
+         ++generic_reg_p)
     {
-        uint32_t reg_num = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, generic_reg);
+        uint32_t reg_num = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, *generic_reg_p);
         if (reg_num == LLDB_INVALID_REGNUM)
             continue; // Target does not support the given register.
 #endif
@@ -518,7 +524,7 @@ GetStopReasonString(StopReason stop_reas
 }
 
 static JSONArray::SP
-GetJSONThreadsInfo(NativeProcessProtocol &process, bool threads_with_valid_stop_info_only)
+GetJSONThreadsInfo(NativeProcessProtocol &process, bool abridged)
 {
     Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
 
@@ -551,12 +557,12 @@ GetJSONThreadsInfo(NativeProcessProtocol
                     tid_stop_info.details.exception.type);
         }
 
-        if (threads_with_valid_stop_info_only && tid_stop_info.reason == eStopReasonNone)
-            continue; // No stop reason, skip this thread completely.
-
         JSONObject::SP thread_obj_sp = std::make_shared<JSONObject>();
         threads_array_sp->AppendObject(thread_obj_sp);
 
+        if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
+            thread_obj_sp->SetObject("registers", registers_sp);
+
         thread_obj_sp->SetObject("tid", std::make_shared<JSONNumber>(tid));
         if (signum != 0)
             thread_obj_sp->SetObject("signal", std::make_shared<JSONNumber>(uint64_t(signum)));
@@ -585,12 +591,6 @@ GetJSONThreadsInfo(NativeProcessProtocol
             thread_obj_sp->SetObject("medata", medata_array_sp);
         }
 
-        if (threads_with_valid_stop_info_only)
-            continue; // Only send the abridged stop info.
-
-        if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp))
-            thread_obj_sp->SetObject("registers", registers_sp);
-
         // TODO: Expedite interesting regions of inferior memory
     }
 




More information about the lldb-commits mailing list