[llvm-branch-commits] [lldb] r270134 - Maintain register numbering across xml include features

Francis Ricci via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 19 14:05:57 PDT 2016

Author: fjricci
Date: Thu May 19 16:05:57 2016
New Revision: 270134

URL: http://llvm.org/viewvc/llvm-project?rev=270134&view=rev
Maintain register numbering across xml include features

If the remote uses include features when communicating
xml register info back to lldb, the existing code would reset the
lldb register index at the beginning of each include node.
This would lead to multiple registers having the same lldb register index.
Since the lldb register numbers should be contiguous and unique,
maintain them accross the parsing of all of the xml feature nodes.

Reviewers: jingham, jasonmolenda, clayborg

Subscribers: lldb-commits, sas

Differential Revision: http://reviews.llvm.org/D19303

This is a cherry-pick of 267468


Modified: lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=270134&r1=270133&r2=270134&view=diff
--- lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu May 19 16:05:57 2016
@@ -4344,14 +4344,11 @@ struct GdbServerTargetInfo
-ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemoteDynamicRegisterInfo &dyn_reg_info, ABISP abi_sp)
+ParseRegisters (XMLNode feature_node, GdbServerTargetInfo &target_info, GDBRemoteDynamicRegisterInfo &dyn_reg_info, ABISP abi_sp, uint32_t &cur_reg_num, uint32_t &reg_offset)
     if (!feature_node)
         return false;
-    uint32_t cur_reg_num = 0;
-    uint32_t reg_offset = 0;
     feature_node.ForEachChildElementWithName("reg", [&target_info, &dyn_reg_info, &cur_reg_num, &reg_offset, &abi_sp](const XMLNode &reg_node) -> bool {
         std::string gdb_group;
         std::string gdb_type;
@@ -4607,12 +4604,16 @@ ProcessGDBRemote::GetGDBServerRegisterIn
                 return true; // Keep iterating through all children of the target_node
+            // Initialize these outside of ParseRegisters, since they should not be reset inside each include feature
+            uint32_t cur_reg_num = 0;
+            uint32_t reg_offset = 0;
             // Don't use Process::GetABI, this code gets called from DidAttach, and in that context we haven't
             // set the Target's architecture yet, so the ABI is also potentially incorrect.
             ABISP abi_to_use_sp = ABI::FindPlugin(arch_to_use);
             if (feature_node)
-                ParseRegisters(feature_node, target_info, this->m_register_info, abi_to_use_sp);
+                ParseRegisters(feature_node, target_info, this->m_register_info, abi_to_use_sp, cur_reg_num, reg_offset);
             for (const auto &include : target_info.includes)
@@ -4630,7 +4631,7 @@ ProcessGDBRemote::GetGDBServerRegisterIn
                 XMLNode include_feature_node = include_xml_document.GetRootElement("feature");
                 if (include_feature_node)
-                    ParseRegisters(include_feature_node, target_info, this->m_register_info, abi_to_use_sp);
+                    ParseRegisters(include_feature_node, target_info, this->m_register_info, abi_to_use_sp, cur_reg_num, reg_offset);

More information about the llvm-branch-commits mailing list