Index: lldb/include/lldb/Host/common/NativeRegisterContext.h =================================================================== --- lldb/include/lldb/Host/common/NativeRegisterContext.h +++ lldb/include/lldb/Host/common/NativeRegisterContext.h @@ -35,6 +35,9 @@ virtual uint32_t GetUserRegisterCount() const = 0; + virtual uint32_t + RegInfosIndexToUserRegIndex(uint32_t user_reg_index) const = 0; + virtual const RegisterInfo *GetRegisterInfoAtIndex(uint32_t reg) const = 0; const char *GetRegisterSetNameForRegisterAtIndex(uint32_t reg_index) const; Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h =================================================================== --- lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h +++ lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h @@ -29,6 +29,8 @@ uint32_t GetUserRegisterCount() const override; + uint32_t RegInfosIndexToUserRegIndex(uint32_t user_reg_index) const override; + const RegisterInfo *GetRegisterInfoAtIndex(uint32_t reg_index) const override; const RegisterInfoInterface &GetRegisterInfoInterface() const; Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp +++ lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp @@ -28,6 +28,11 @@ return m_register_info_interface_up->GetUserRegisterCount(); } +uint32_t NativeRegisterContextRegisterInfo::RegInfosIndexToUserRegIndex( + uint32_t reg_infos_index) const { + return reg_infos_index; +} + const RegisterInfo *NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex( uint32_t reg_index) const { if (reg_index <= GetRegisterCount()) Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -458,15 +458,18 @@ } } -static void CollectRegNums(const uint32_t *reg_num, StreamString &response, +static void CollectRegNums(NativeRegisterContext ®_context, + const uint32_t *reg_num, StreamString &response, bool usehex) { + uint32_t reg_index = 0; for (int i = 0; *reg_num != LLDB_INVALID_REGNUM; ++reg_num, ++i) { + reg_index = reg_context.RegInfosIndexToUserRegIndex(*reg_num); if (i > 0) response.PutChar(','); if (usehex) - response.Printf("%" PRIx32, *reg_num); + response.Printf("%" PRIx32, reg_index); else - response.Printf("%" PRIu32, *reg_num); + response.Printf("%" PRIu32, reg_index); } } @@ -1820,13 +1823,13 @@ if (reg_info->value_regs && reg_info->value_regs[0] != LLDB_INVALID_REGNUM) { response.PutCString("container-regs:"); - CollectRegNums(reg_info->value_regs, response, true); + CollectRegNums(reg_context, reg_info->value_regs, response, true); response.PutChar(';'); } if (reg_info->invalidate_regs && reg_info->invalidate_regs[0]) { response.PutCString("invalidate-regs:"); - CollectRegNums(reg_info->invalidate_regs, response, true); + CollectRegNums(reg_context, reg_info->invalidate_regs, response, true); response.PutChar(';'); } @@ -2811,13 +2814,13 @@ if (reg_info->value_regs && reg_info->value_regs[0] != LLDB_INVALID_REGNUM) { response.PutCString("value_regnums=\""); - CollectRegNums(reg_info->value_regs, response, false); + CollectRegNums(reg_context, reg_info->value_regs, response, false); response.Printf("\" "); } if (reg_info->invalidate_regs && reg_info->invalidate_regs[0]) { response.PutCString("invalidate_regnums=\""); - CollectRegNums(reg_info->invalidate_regs, response, false); + CollectRegNums(reg_context, reg_info->invalidate_regs, response, false); response.Printf("\" "); } Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -242,11 +242,15 @@ // Index of the primordial register. bool success = true; for (uint32_t idx = 0; success; ++idx) { - const uint32_t prim_reg = reg_info->value_regs[idx]; + uint32_t prim_reg = reg_info->value_regs[idx]; if (prim_reg == LLDB_INVALID_REGNUM) break; // We have a valid primordial register as our constituent. Grab the // corresponding register info. + uint32_t regnum = ConvertRegisterKindToRegisterNumber( + eRegisterKindProcessPlugin, prim_reg); + if (regnum != LLDB_INVALID_REGNUM) + prim_reg = regnum; const RegisterInfo *prim_reg_info = GetRegisterInfoAtIndex(prim_reg); if (prim_reg_info == nullptr) success = false; @@ -375,11 +379,15 @@ // Invalidate this composite register first. for (uint32_t idx = 0; success; ++idx) { - const uint32_t reg = reg_info->value_regs[idx]; + uint32_t reg = reg_info->value_regs[idx]; if (reg == LLDB_INVALID_REGNUM) break; // We have a valid primordial register as our constituent. Grab the // corresponding register info. + uint32_t lldb_regnum = ConvertRegisterKindToRegisterNumber( + eRegisterKindProcessPlugin, reg); + if (lldb_regnum != LLDB_INVALID_REGNUM) + reg = lldb_regnum; const RegisterInfo *value_reg_info = GetRegisterInfoAtIndex(reg); if (value_reg_info == nullptr) success = false; @@ -397,6 +405,10 @@ for (uint32_t idx = 0, reg = reg_info->invalidate_regs[0]; reg != LLDB_INVALID_REGNUM; reg = reg_info->invalidate_regs[++idx]) { + uint32_t lldb_regnum = ConvertRegisterKindToRegisterNumber( + eRegisterKindProcessPlugin, reg); + if (lldb_regnum != LLDB_INVALID_REGNUM) + reg = lldb_regnum; SetRegisterIsValid(reg, false); } }