xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (revision 9dba64be9536c28e4800e06512b7f29b43ade345)
10b57cec5SDimitry Andric //===-- GDBRemoteRegisterContext.cpp ----------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "GDBRemoteRegisterContext.h"
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #include "lldb/Target/ExecutionContext.h"
120b57cec5SDimitry Andric #include "lldb/Target/Target.h"
130b57cec5SDimitry Andric #include "lldb/Utility/DataBufferHeap.h"
140b57cec5SDimitry Andric #include "lldb/Utility/DataExtractor.h"
150b57cec5SDimitry Andric #include "lldb/Utility/RegisterValue.h"
160b57cec5SDimitry Andric #include "lldb/Utility/Scalar.h"
170b57cec5SDimitry Andric #include "lldb/Utility/StreamString.h"
180b57cec5SDimitry Andric #include "ProcessGDBRemote.h"
190b57cec5SDimitry Andric #include "ProcessGDBRemoteLog.h"
200b57cec5SDimitry Andric #include "ThreadGDBRemote.h"
210b57cec5SDimitry Andric #include "Utility/ARM_DWARF_Registers.h"
220b57cec5SDimitry Andric #include "Utility/ARM_ehframe_Registers.h"
230b57cec5SDimitry Andric #include "lldb/Utility/StringExtractorGDBRemote.h"
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric #include <memory>
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric using namespace lldb;
280b57cec5SDimitry Andric using namespace lldb_private;
290b57cec5SDimitry Andric using namespace lldb_private::process_gdb_remote;
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric // GDBRemoteRegisterContext constructor
320b57cec5SDimitry Andric GDBRemoteRegisterContext::GDBRemoteRegisterContext(
330b57cec5SDimitry Andric     ThreadGDBRemote &thread, uint32_t concrete_frame_idx,
340b57cec5SDimitry Andric     GDBRemoteDynamicRegisterInfo &reg_info, bool read_all_at_once)
350b57cec5SDimitry Andric     : RegisterContext(thread, concrete_frame_idx), m_reg_info(reg_info),
360b57cec5SDimitry Andric       m_reg_valid(), m_reg_data(), m_read_all_at_once(read_all_at_once) {
370b57cec5SDimitry Andric   // Resize our vector of bools to contain one bool for every register. We will
380b57cec5SDimitry Andric   // use these boolean values to know when a register value is valid in
390b57cec5SDimitry Andric   // m_reg_data.
400b57cec5SDimitry Andric   m_reg_valid.resize(reg_info.GetNumRegisters());
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric   // Make a heap based buffer that is big enough to store all registers
430b57cec5SDimitry Andric   DataBufferSP reg_data_sp(
440b57cec5SDimitry Andric       new DataBufferHeap(reg_info.GetRegisterDataByteSize(), 0));
450b57cec5SDimitry Andric   m_reg_data.SetData(reg_data_sp);
460b57cec5SDimitry Andric   m_reg_data.SetByteOrder(thread.GetProcess()->GetByteOrder());
470b57cec5SDimitry Andric }
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric // Destructor
500b57cec5SDimitry Andric GDBRemoteRegisterContext::~GDBRemoteRegisterContext() {}
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric void GDBRemoteRegisterContext::InvalidateAllRegisters() {
530b57cec5SDimitry Andric   SetAllRegisterValid(false);
540b57cec5SDimitry Andric }
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric void GDBRemoteRegisterContext::SetAllRegisterValid(bool b) {
570b57cec5SDimitry Andric   std::vector<bool>::iterator pos, end = m_reg_valid.end();
580b57cec5SDimitry Andric   for (pos = m_reg_valid.begin(); pos != end; ++pos)
590b57cec5SDimitry Andric     *pos = b;
600b57cec5SDimitry Andric }
610b57cec5SDimitry Andric 
620b57cec5SDimitry Andric size_t GDBRemoteRegisterContext::GetRegisterCount() {
630b57cec5SDimitry Andric   return m_reg_info.GetNumRegisters();
640b57cec5SDimitry Andric }
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric const RegisterInfo *
670b57cec5SDimitry Andric GDBRemoteRegisterContext::GetRegisterInfoAtIndex(size_t reg) {
680b57cec5SDimitry Andric   RegisterInfo *reg_info = m_reg_info.GetRegisterInfoAtIndex(reg);
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric   if (reg_info && reg_info->dynamic_size_dwarf_expr_bytes) {
710b57cec5SDimitry Andric     const ArchSpec &arch = m_thread.GetProcess()->GetTarget().GetArchitecture();
720b57cec5SDimitry Andric     uint8_t reg_size = UpdateDynamicRegisterSize(arch, reg_info);
730b57cec5SDimitry Andric     reg_info->byte_size = reg_size;
740b57cec5SDimitry Andric   }
750b57cec5SDimitry Andric   return reg_info;
760b57cec5SDimitry Andric }
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric size_t GDBRemoteRegisterContext::GetRegisterSetCount() {
790b57cec5SDimitry Andric   return m_reg_info.GetNumRegisterSets();
800b57cec5SDimitry Andric }
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric const RegisterSet *GDBRemoteRegisterContext::GetRegisterSet(size_t reg_set) {
830b57cec5SDimitry Andric   return m_reg_info.GetRegisterSet(reg_set);
840b57cec5SDimitry Andric }
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info,
870b57cec5SDimitry Andric                                             RegisterValue &value) {
880b57cec5SDimitry Andric   // Read the register
890b57cec5SDimitry Andric   if (ReadRegisterBytes(reg_info, m_reg_data)) {
900b57cec5SDimitry Andric     const bool partial_data_ok = false;
910b57cec5SDimitry Andric     Status error(value.SetValueFromData(
920b57cec5SDimitry Andric         reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok));
930b57cec5SDimitry Andric     return error.Success();
940b57cec5SDimitry Andric   }
950b57cec5SDimitry Andric   return false;
960b57cec5SDimitry Andric }
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric bool GDBRemoteRegisterContext::PrivateSetRegisterValue(
990b57cec5SDimitry Andric     uint32_t reg, llvm::ArrayRef<uint8_t> data) {
1000b57cec5SDimitry Andric   const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
1010b57cec5SDimitry Andric   if (reg_info == nullptr)
1020b57cec5SDimitry Andric     return false;
1030b57cec5SDimitry Andric 
1040b57cec5SDimitry Andric   // Invalidate if needed
1050b57cec5SDimitry Andric   InvalidateIfNeeded(false);
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric   const size_t reg_byte_size = reg_info->byte_size;
1080b57cec5SDimitry Andric   memcpy(const_cast<uint8_t *>(
1090b57cec5SDimitry Andric              m_reg_data.PeekData(reg_info->byte_offset, reg_byte_size)),
1100b57cec5SDimitry Andric          data.data(), std::min(data.size(), reg_byte_size));
1110b57cec5SDimitry Andric   bool success = data.size() >= reg_byte_size;
1120b57cec5SDimitry Andric   if (success) {
1130b57cec5SDimitry Andric     SetRegisterIsValid(reg, true);
1140b57cec5SDimitry Andric   } else if (data.size() > 0) {
1150b57cec5SDimitry Andric     // Only set register is valid to false if we copied some bytes, else leave
1160b57cec5SDimitry Andric     // it as it was.
1170b57cec5SDimitry Andric     SetRegisterIsValid(reg, false);
1180b57cec5SDimitry Andric   }
1190b57cec5SDimitry Andric   return success;
1200b57cec5SDimitry Andric }
1210b57cec5SDimitry Andric 
1220b57cec5SDimitry Andric bool GDBRemoteRegisterContext::PrivateSetRegisterValue(uint32_t reg,
1230b57cec5SDimitry Andric                                                        uint64_t new_reg_val) {
1240b57cec5SDimitry Andric   const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
1250b57cec5SDimitry Andric   if (reg_info == nullptr)
1260b57cec5SDimitry Andric     return false;
1270b57cec5SDimitry Andric 
1280b57cec5SDimitry Andric   // Early in process startup, we can get a thread that has an invalid byte
1290b57cec5SDimitry Andric   // order because the process hasn't been completely set up yet (see the ctor
1300b57cec5SDimitry Andric   // where the byte order is setfrom the process).  If that's the case, we
1310b57cec5SDimitry Andric   // can't set the value here.
1320b57cec5SDimitry Andric   if (m_reg_data.GetByteOrder() == eByteOrderInvalid) {
1330b57cec5SDimitry Andric     return false;
1340b57cec5SDimitry Andric   }
1350b57cec5SDimitry Andric 
1360b57cec5SDimitry Andric   // Invalidate if needed
1370b57cec5SDimitry Andric   InvalidateIfNeeded(false);
1380b57cec5SDimitry Andric 
1390b57cec5SDimitry Andric   DataBufferSP buffer_sp(new DataBufferHeap(&new_reg_val, sizeof(new_reg_val)));
1400b57cec5SDimitry Andric   DataExtractor data(buffer_sp, endian::InlHostByteOrder(), sizeof(void *));
1410b57cec5SDimitry Andric 
1420b57cec5SDimitry Andric   // If our register context and our register info disagree, which should never
1430b57cec5SDimitry Andric   // happen, don't overwrite past the end of the buffer.
1440b57cec5SDimitry Andric   if (m_reg_data.GetByteSize() < reg_info->byte_offset + reg_info->byte_size)
1450b57cec5SDimitry Andric     return false;
1460b57cec5SDimitry Andric 
1470b57cec5SDimitry Andric   // Grab a pointer to where we are going to put this register
1480b57cec5SDimitry Andric   uint8_t *dst = const_cast<uint8_t *>(
1490b57cec5SDimitry Andric       m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
1500b57cec5SDimitry Andric 
1510b57cec5SDimitry Andric   if (dst == nullptr)
1520b57cec5SDimitry Andric     return false;
1530b57cec5SDimitry Andric 
1540b57cec5SDimitry Andric   if (data.CopyByteOrderedData(0,                          // src offset
1550b57cec5SDimitry Andric                                reg_info->byte_size,        // src length
1560b57cec5SDimitry Andric                                dst,                        // dst
1570b57cec5SDimitry Andric                                reg_info->byte_size,        // dst length
1580b57cec5SDimitry Andric                                m_reg_data.GetByteOrder())) // dst byte order
1590b57cec5SDimitry Andric   {
1600b57cec5SDimitry Andric     SetRegisterIsValid(reg, true);
1610b57cec5SDimitry Andric     return true;
1620b57cec5SDimitry Andric   }
1630b57cec5SDimitry Andric   return false;
1640b57cec5SDimitry Andric }
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric // Helper function for GDBRemoteRegisterContext::ReadRegisterBytes().
1670b57cec5SDimitry Andric bool GDBRemoteRegisterContext::GetPrimordialRegister(
1680b57cec5SDimitry Andric     const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm) {
1690b57cec5SDimitry Andric   const uint32_t lldb_reg = reg_info->kinds[eRegisterKindLLDB];
1700b57cec5SDimitry Andric   const uint32_t remote_reg = reg_info->kinds[eRegisterKindProcessPlugin];
1710b57cec5SDimitry Andric 
1720b57cec5SDimitry Andric   if (DataBufferSP buffer_sp =
1730b57cec5SDimitry Andric           gdb_comm.ReadRegister(m_thread.GetProtocolID(), remote_reg))
1740b57cec5SDimitry Andric     return PrivateSetRegisterValue(
1750b57cec5SDimitry Andric         lldb_reg, llvm::ArrayRef<uint8_t>(buffer_sp->GetBytes(),
1760b57cec5SDimitry Andric                                           buffer_sp->GetByteSize()));
1770b57cec5SDimitry Andric   return false;
1780b57cec5SDimitry Andric }
1790b57cec5SDimitry Andric 
1800b57cec5SDimitry Andric bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info,
1810b57cec5SDimitry Andric                                                  DataExtractor &data) {
1820b57cec5SDimitry Andric   ExecutionContext exe_ctx(CalculateThread());
1830b57cec5SDimitry Andric 
1840b57cec5SDimitry Andric   Process *process = exe_ctx.GetProcessPtr();
1850b57cec5SDimitry Andric   Thread *thread = exe_ctx.GetThreadPtr();
1860b57cec5SDimitry Andric   if (process == nullptr || thread == nullptr)
1870b57cec5SDimitry Andric     return false;
1880b57cec5SDimitry Andric 
1890b57cec5SDimitry Andric   GDBRemoteCommunicationClient &gdb_comm(
1900b57cec5SDimitry Andric       ((ProcessGDBRemote *)process)->GetGDBRemote());
1910b57cec5SDimitry Andric 
1920b57cec5SDimitry Andric   InvalidateIfNeeded(false);
1930b57cec5SDimitry Andric 
1940b57cec5SDimitry Andric   const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
1950b57cec5SDimitry Andric 
1960b57cec5SDimitry Andric   if (!GetRegisterIsValid(reg)) {
1970b57cec5SDimitry Andric     if (m_read_all_at_once) {
1980b57cec5SDimitry Andric       if (DataBufferSP buffer_sp =
1990b57cec5SDimitry Andric               gdb_comm.ReadAllRegisters(m_thread.GetProtocolID())) {
2000b57cec5SDimitry Andric         memcpy(const_cast<uint8_t *>(m_reg_data.GetDataStart()),
2010b57cec5SDimitry Andric                buffer_sp->GetBytes(),
2020b57cec5SDimitry Andric                std::min(buffer_sp->GetByteSize(), m_reg_data.GetByteSize()));
2030b57cec5SDimitry Andric         if (buffer_sp->GetByteSize() >= m_reg_data.GetByteSize()) {
2040b57cec5SDimitry Andric           SetAllRegisterValid(true);
2050b57cec5SDimitry Andric           return true;
2060b57cec5SDimitry Andric         } else {
2070b57cec5SDimitry Andric           Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
2080b57cec5SDimitry Andric                                                                 GDBR_LOG_PACKETS));
209*9dba64beSDimitry Andric           LLDB_LOGF(
210*9dba64beSDimitry Andric               log,
211*9dba64beSDimitry Andric               "error: GDBRemoteRegisterContext::ReadRegisterBytes tried "
212*9dba64beSDimitry Andric               "to read the "
213*9dba64beSDimitry Andric               "entire register context at once, expected at least %" PRId64
214*9dba64beSDimitry Andric               " bytes "
215*9dba64beSDimitry Andric               "but only got %" PRId64 " bytes.",
216*9dba64beSDimitry Andric               m_reg_data.GetByteSize(), buffer_sp->GetByteSize());
2170b57cec5SDimitry Andric         }
2180b57cec5SDimitry Andric       }
2190b57cec5SDimitry Andric       return false;
2200b57cec5SDimitry Andric     }
2210b57cec5SDimitry Andric     if (reg_info->value_regs) {
2220b57cec5SDimitry Andric       // Process this composite register request by delegating to the
2230b57cec5SDimitry Andric       // constituent primordial registers.
2240b57cec5SDimitry Andric 
2250b57cec5SDimitry Andric       // Index of the primordial register.
2260b57cec5SDimitry Andric       bool success = true;
2270b57cec5SDimitry Andric       for (uint32_t idx = 0; success; ++idx) {
2280b57cec5SDimitry Andric         const uint32_t prim_reg = reg_info->value_regs[idx];
2290b57cec5SDimitry Andric         if (prim_reg == LLDB_INVALID_REGNUM)
2300b57cec5SDimitry Andric           break;
2310b57cec5SDimitry Andric         // We have a valid primordial register as our constituent. Grab the
2320b57cec5SDimitry Andric         // corresponding register info.
2330b57cec5SDimitry Andric         const RegisterInfo *prim_reg_info = GetRegisterInfoAtIndex(prim_reg);
2340b57cec5SDimitry Andric         if (prim_reg_info == nullptr)
2350b57cec5SDimitry Andric           success = false;
2360b57cec5SDimitry Andric         else {
2370b57cec5SDimitry Andric           // Read the containing register if it hasn't already been read
2380b57cec5SDimitry Andric           if (!GetRegisterIsValid(prim_reg))
2390b57cec5SDimitry Andric             success = GetPrimordialRegister(prim_reg_info, gdb_comm);
2400b57cec5SDimitry Andric         }
2410b57cec5SDimitry Andric       }
2420b57cec5SDimitry Andric 
2430b57cec5SDimitry Andric       if (success) {
2440b57cec5SDimitry Andric         // If we reach this point, all primordial register requests have
2450b57cec5SDimitry Andric         // succeeded. Validate this composite register.
2460b57cec5SDimitry Andric         SetRegisterIsValid(reg_info, true);
2470b57cec5SDimitry Andric       }
2480b57cec5SDimitry Andric     } else {
2490b57cec5SDimitry Andric       // Get each register individually
2500b57cec5SDimitry Andric       GetPrimordialRegister(reg_info, gdb_comm);
2510b57cec5SDimitry Andric     }
2520b57cec5SDimitry Andric 
2530b57cec5SDimitry Andric     // Make sure we got a valid register value after reading it
2540b57cec5SDimitry Andric     if (!GetRegisterIsValid(reg))
2550b57cec5SDimitry Andric       return false;
2560b57cec5SDimitry Andric   }
2570b57cec5SDimitry Andric 
2580b57cec5SDimitry Andric   if (&data != &m_reg_data) {
2590b57cec5SDimitry Andric     assert(m_reg_data.GetByteSize() >=
2600b57cec5SDimitry Andric            reg_info->byte_offset + reg_info->byte_size);
2610b57cec5SDimitry Andric     // If our register context and our register info disagree, which should
2620b57cec5SDimitry Andric     // never happen, don't read past the end of the buffer.
2630b57cec5SDimitry Andric     if (m_reg_data.GetByteSize() < reg_info->byte_offset + reg_info->byte_size)
2640b57cec5SDimitry Andric       return false;
2650b57cec5SDimitry Andric 
2660b57cec5SDimitry Andric     // If we aren't extracting into our own buffer (which only happens when
2670b57cec5SDimitry Andric     // this function is called from ReadRegisterValue(uint32_t, Scalar&)) then
2680b57cec5SDimitry Andric     // we transfer bytes from our buffer into the data buffer that was passed
2690b57cec5SDimitry Andric     // in
2700b57cec5SDimitry Andric 
2710b57cec5SDimitry Andric     data.SetByteOrder(m_reg_data.GetByteOrder());
2720b57cec5SDimitry Andric     data.SetData(m_reg_data, reg_info->byte_offset, reg_info->byte_size);
2730b57cec5SDimitry Andric   }
2740b57cec5SDimitry Andric   return true;
2750b57cec5SDimitry Andric }
2760b57cec5SDimitry Andric 
2770b57cec5SDimitry Andric bool GDBRemoteRegisterContext::WriteRegister(const RegisterInfo *reg_info,
2780b57cec5SDimitry Andric                                              const RegisterValue &value) {
2790b57cec5SDimitry Andric   DataExtractor data;
2800b57cec5SDimitry Andric   if (value.GetData(data))
2810b57cec5SDimitry Andric     return WriteRegisterBytes(reg_info, data, 0);
2820b57cec5SDimitry Andric   return false;
2830b57cec5SDimitry Andric }
2840b57cec5SDimitry Andric 
2850b57cec5SDimitry Andric // Helper function for GDBRemoteRegisterContext::WriteRegisterBytes().
2860b57cec5SDimitry Andric bool GDBRemoteRegisterContext::SetPrimordialRegister(
2870b57cec5SDimitry Andric     const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm) {
2880b57cec5SDimitry Andric   StreamString packet;
2890b57cec5SDimitry Andric   StringExtractorGDBRemote response;
2900b57cec5SDimitry Andric   const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
2910b57cec5SDimitry Andric   // Invalidate just this register
2920b57cec5SDimitry Andric   SetRegisterIsValid(reg, false);
2930b57cec5SDimitry Andric 
2940b57cec5SDimitry Andric   return gdb_comm.WriteRegister(
2950b57cec5SDimitry Andric       m_thread.GetProtocolID(), reg_info->kinds[eRegisterKindProcessPlugin],
2960b57cec5SDimitry Andric       {m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size),
2970b57cec5SDimitry Andric        reg_info->byte_size});
2980b57cec5SDimitry Andric }
2990b57cec5SDimitry Andric 
3000b57cec5SDimitry Andric bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
3010b57cec5SDimitry Andric                                                   DataExtractor &data,
3020b57cec5SDimitry Andric                                                   uint32_t data_offset) {
3030b57cec5SDimitry Andric   ExecutionContext exe_ctx(CalculateThread());
3040b57cec5SDimitry Andric 
3050b57cec5SDimitry Andric   Process *process = exe_ctx.GetProcessPtr();
3060b57cec5SDimitry Andric   Thread *thread = exe_ctx.GetThreadPtr();
3070b57cec5SDimitry Andric   if (process == nullptr || thread == nullptr)
3080b57cec5SDimitry Andric     return false;
3090b57cec5SDimitry Andric 
3100b57cec5SDimitry Andric   GDBRemoteCommunicationClient &gdb_comm(
3110b57cec5SDimitry Andric       ((ProcessGDBRemote *)process)->GetGDBRemote());
3120b57cec5SDimitry Andric 
3130b57cec5SDimitry Andric   assert(m_reg_data.GetByteSize() >=
3140b57cec5SDimitry Andric          reg_info->byte_offset + reg_info->byte_size);
3150b57cec5SDimitry Andric 
3160b57cec5SDimitry Andric   // If our register context and our register info disagree, which should never
3170b57cec5SDimitry Andric   // happen, don't overwrite past the end of the buffer.
3180b57cec5SDimitry Andric   if (m_reg_data.GetByteSize() < reg_info->byte_offset + reg_info->byte_size)
3190b57cec5SDimitry Andric     return false;
3200b57cec5SDimitry Andric 
3210b57cec5SDimitry Andric   // Grab a pointer to where we are going to put this register
3220b57cec5SDimitry Andric   uint8_t *dst = const_cast<uint8_t *>(
3230b57cec5SDimitry Andric       m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
3240b57cec5SDimitry Andric 
3250b57cec5SDimitry Andric   if (dst == nullptr)
3260b57cec5SDimitry Andric     return false;
3270b57cec5SDimitry Andric 
3280b57cec5SDimitry Andric   if (data.CopyByteOrderedData(data_offset,                // src offset
3290b57cec5SDimitry Andric                                reg_info->byte_size,        // src length
3300b57cec5SDimitry Andric                                dst,                        // dst
3310b57cec5SDimitry Andric                                reg_info->byte_size,        // dst length
3320b57cec5SDimitry Andric                                m_reg_data.GetByteOrder())) // dst byte order
3330b57cec5SDimitry Andric   {
3340b57cec5SDimitry Andric     GDBRemoteClientBase::Lock lock(gdb_comm, false);
3350b57cec5SDimitry Andric     if (lock) {
3360b57cec5SDimitry Andric       if (m_read_all_at_once) {
3370b57cec5SDimitry Andric         // Invalidate all register values
3380b57cec5SDimitry Andric         InvalidateIfNeeded(true);
3390b57cec5SDimitry Andric 
3400b57cec5SDimitry Andric         // Set all registers in one packet
3410b57cec5SDimitry Andric         if (gdb_comm.WriteAllRegisters(
3420b57cec5SDimitry Andric                 m_thread.GetProtocolID(),
3430b57cec5SDimitry Andric                 {m_reg_data.GetDataStart(), size_t(m_reg_data.GetByteSize())}))
3440b57cec5SDimitry Andric 
3450b57cec5SDimitry Andric         {
3460b57cec5SDimitry Andric           SetAllRegisterValid(false);
3470b57cec5SDimitry Andric           return true;
3480b57cec5SDimitry Andric         }
3490b57cec5SDimitry Andric       } else {
3500b57cec5SDimitry Andric         bool success = true;
3510b57cec5SDimitry Andric 
3520b57cec5SDimitry Andric         if (reg_info->value_regs) {
3530b57cec5SDimitry Andric           // This register is part of another register. In this case we read
3540b57cec5SDimitry Andric           // the actual register data for any "value_regs", and once all that
3550b57cec5SDimitry Andric           // data is read, we will have enough data in our register context
3560b57cec5SDimitry Andric           // bytes for the value of this register
3570b57cec5SDimitry Andric 
3580b57cec5SDimitry Andric           // Invalidate this composite register first.
3590b57cec5SDimitry Andric 
3600b57cec5SDimitry Andric           for (uint32_t idx = 0; success; ++idx) {
3610b57cec5SDimitry Andric             const uint32_t reg = reg_info->value_regs[idx];
3620b57cec5SDimitry Andric             if (reg == LLDB_INVALID_REGNUM)
3630b57cec5SDimitry Andric               break;
3640b57cec5SDimitry Andric             // We have a valid primordial register as our constituent. Grab the
3650b57cec5SDimitry Andric             // corresponding register info.
3660b57cec5SDimitry Andric             const RegisterInfo *value_reg_info = GetRegisterInfoAtIndex(reg);
3670b57cec5SDimitry Andric             if (value_reg_info == nullptr)
3680b57cec5SDimitry Andric               success = false;
3690b57cec5SDimitry Andric             else
3700b57cec5SDimitry Andric               success = SetPrimordialRegister(value_reg_info, gdb_comm);
3710b57cec5SDimitry Andric           }
3720b57cec5SDimitry Andric         } else {
3730b57cec5SDimitry Andric           // This is an actual register, write it
3740b57cec5SDimitry Andric           success = SetPrimordialRegister(reg_info, gdb_comm);
3750b57cec5SDimitry Andric         }
3760b57cec5SDimitry Andric 
3770b57cec5SDimitry Andric         // Check if writing this register will invalidate any other register
3780b57cec5SDimitry Andric         // values? If so, invalidate them
3790b57cec5SDimitry Andric         if (reg_info->invalidate_regs) {
3800b57cec5SDimitry Andric           for (uint32_t idx = 0, reg = reg_info->invalidate_regs[0];
3810b57cec5SDimitry Andric                reg != LLDB_INVALID_REGNUM;
3820b57cec5SDimitry Andric                reg = reg_info->invalidate_regs[++idx]) {
3830b57cec5SDimitry Andric             SetRegisterIsValid(reg, false);
3840b57cec5SDimitry Andric           }
3850b57cec5SDimitry Andric         }
3860b57cec5SDimitry Andric 
3870b57cec5SDimitry Andric         return success;
3880b57cec5SDimitry Andric       }
3890b57cec5SDimitry Andric     } else {
3900b57cec5SDimitry Andric       Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
3910b57cec5SDimitry Andric                                                              GDBR_LOG_PACKETS));
3920b57cec5SDimitry Andric       if (log) {
3930b57cec5SDimitry Andric         if (log->GetVerbose()) {
3940b57cec5SDimitry Andric           StreamString strm;
3950b57cec5SDimitry Andric           gdb_comm.DumpHistory(strm);
396*9dba64beSDimitry Andric           LLDB_LOGF(log,
397*9dba64beSDimitry Andric                     "error: failed to get packet sequence mutex, not sending "
3980b57cec5SDimitry Andric                     "write register for \"%s\":\n%s",
3990b57cec5SDimitry Andric                     reg_info->name, strm.GetData());
4000b57cec5SDimitry Andric         } else
401*9dba64beSDimitry Andric           LLDB_LOGF(log,
402*9dba64beSDimitry Andric                     "error: failed to get packet sequence mutex, not sending "
4030b57cec5SDimitry Andric                     "write register for \"%s\"",
4040b57cec5SDimitry Andric                     reg_info->name);
4050b57cec5SDimitry Andric       }
4060b57cec5SDimitry Andric     }
4070b57cec5SDimitry Andric   }
4080b57cec5SDimitry Andric   return false;
4090b57cec5SDimitry Andric }
4100b57cec5SDimitry Andric 
4110b57cec5SDimitry Andric bool GDBRemoteRegisterContext::ReadAllRegisterValues(
4120b57cec5SDimitry Andric     RegisterCheckpoint &reg_checkpoint) {
4130b57cec5SDimitry Andric   ExecutionContext exe_ctx(CalculateThread());
4140b57cec5SDimitry Andric 
4150b57cec5SDimitry Andric   Process *process = exe_ctx.GetProcessPtr();
4160b57cec5SDimitry Andric   Thread *thread = exe_ctx.GetThreadPtr();
4170b57cec5SDimitry Andric   if (process == nullptr || thread == nullptr)
4180b57cec5SDimitry Andric     return false;
4190b57cec5SDimitry Andric 
4200b57cec5SDimitry Andric   GDBRemoteCommunicationClient &gdb_comm(
4210b57cec5SDimitry Andric       ((ProcessGDBRemote *)process)->GetGDBRemote());
4220b57cec5SDimitry Andric 
4230b57cec5SDimitry Andric   uint32_t save_id = 0;
4240b57cec5SDimitry Andric   if (gdb_comm.SaveRegisterState(thread->GetProtocolID(), save_id)) {
4250b57cec5SDimitry Andric     reg_checkpoint.SetID(save_id);
4260b57cec5SDimitry Andric     reg_checkpoint.GetData().reset();
4270b57cec5SDimitry Andric     return true;
4280b57cec5SDimitry Andric   } else {
4290b57cec5SDimitry Andric     reg_checkpoint.SetID(0); // Invalid save ID is zero
4300b57cec5SDimitry Andric     return ReadAllRegisterValues(reg_checkpoint.GetData());
4310b57cec5SDimitry Andric   }
4320b57cec5SDimitry Andric }
4330b57cec5SDimitry Andric 
4340b57cec5SDimitry Andric bool GDBRemoteRegisterContext::WriteAllRegisterValues(
4350b57cec5SDimitry Andric     const RegisterCheckpoint &reg_checkpoint) {
4360b57cec5SDimitry Andric   uint32_t save_id = reg_checkpoint.GetID();
4370b57cec5SDimitry Andric   if (save_id != 0) {
4380b57cec5SDimitry Andric     ExecutionContext exe_ctx(CalculateThread());
4390b57cec5SDimitry Andric 
4400b57cec5SDimitry Andric     Process *process = exe_ctx.GetProcessPtr();
4410b57cec5SDimitry Andric     Thread *thread = exe_ctx.GetThreadPtr();
4420b57cec5SDimitry Andric     if (process == nullptr || thread == nullptr)
4430b57cec5SDimitry Andric       return false;
4440b57cec5SDimitry Andric 
4450b57cec5SDimitry Andric     GDBRemoteCommunicationClient &gdb_comm(
4460b57cec5SDimitry Andric         ((ProcessGDBRemote *)process)->GetGDBRemote());
4470b57cec5SDimitry Andric 
4480b57cec5SDimitry Andric     return gdb_comm.RestoreRegisterState(m_thread.GetProtocolID(), save_id);
4490b57cec5SDimitry Andric   } else {
4500b57cec5SDimitry Andric     return WriteAllRegisterValues(reg_checkpoint.GetData());
4510b57cec5SDimitry Andric   }
4520b57cec5SDimitry Andric }
4530b57cec5SDimitry Andric 
4540b57cec5SDimitry Andric bool GDBRemoteRegisterContext::ReadAllRegisterValues(
4550b57cec5SDimitry Andric     lldb::DataBufferSP &data_sp) {
4560b57cec5SDimitry Andric   ExecutionContext exe_ctx(CalculateThread());
4570b57cec5SDimitry Andric 
4580b57cec5SDimitry Andric   Process *process = exe_ctx.GetProcessPtr();
4590b57cec5SDimitry Andric   Thread *thread = exe_ctx.GetThreadPtr();
4600b57cec5SDimitry Andric   if (process == nullptr || thread == nullptr)
4610b57cec5SDimitry Andric     return false;
4620b57cec5SDimitry Andric 
4630b57cec5SDimitry Andric   GDBRemoteCommunicationClient &gdb_comm(
4640b57cec5SDimitry Andric       ((ProcessGDBRemote *)process)->GetGDBRemote());
4650b57cec5SDimitry Andric 
4660b57cec5SDimitry Andric   const bool use_g_packet =
4670b57cec5SDimitry Andric       !gdb_comm.AvoidGPackets((ProcessGDBRemote *)process);
4680b57cec5SDimitry Andric 
4690b57cec5SDimitry Andric   GDBRemoteClientBase::Lock lock(gdb_comm, false);
4700b57cec5SDimitry Andric   if (lock) {
4710b57cec5SDimitry Andric     if (gdb_comm.SyncThreadState(m_thread.GetProtocolID()))
4720b57cec5SDimitry Andric       InvalidateAllRegisters();
4730b57cec5SDimitry Andric 
4740b57cec5SDimitry Andric     if (use_g_packet &&
4750b57cec5SDimitry Andric         (data_sp = gdb_comm.ReadAllRegisters(m_thread.GetProtocolID())))
4760b57cec5SDimitry Andric       return true;
4770b57cec5SDimitry Andric 
4780b57cec5SDimitry Andric     // We're going to read each register
4790b57cec5SDimitry Andric     // individually and store them as binary data in a buffer.
4800b57cec5SDimitry Andric     const RegisterInfo *reg_info;
4810b57cec5SDimitry Andric 
4820b57cec5SDimitry Andric     for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != nullptr;
4830b57cec5SDimitry Andric          i++) {
4840b57cec5SDimitry Andric       if (reg_info
4850b57cec5SDimitry Andric               ->value_regs) // skip registers that are slices of real registers
4860b57cec5SDimitry Andric         continue;
4870b57cec5SDimitry Andric       ReadRegisterBytes(reg_info, m_reg_data);
4880b57cec5SDimitry Andric       // ReadRegisterBytes saves the contents of the register in to the
4890b57cec5SDimitry Andric       // m_reg_data buffer
4900b57cec5SDimitry Andric     }
4910b57cec5SDimitry Andric     data_sp = std::make_shared<DataBufferHeap>(
4920b57cec5SDimitry Andric         m_reg_data.GetDataStart(), m_reg_info.GetRegisterDataByteSize());
4930b57cec5SDimitry Andric     return true;
4940b57cec5SDimitry Andric   } else {
4950b57cec5SDimitry Andric 
4960b57cec5SDimitry Andric     Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
4970b57cec5SDimitry Andric                                                            GDBR_LOG_PACKETS));
4980b57cec5SDimitry Andric     if (log) {
4990b57cec5SDimitry Andric       if (log->GetVerbose()) {
5000b57cec5SDimitry Andric         StreamString strm;
5010b57cec5SDimitry Andric         gdb_comm.DumpHistory(strm);
502*9dba64beSDimitry Andric         LLDB_LOGF(log,
503*9dba64beSDimitry Andric                   "error: failed to get packet sequence mutex, not sending "
5040b57cec5SDimitry Andric                   "read all registers:\n%s",
5050b57cec5SDimitry Andric                   strm.GetData());
5060b57cec5SDimitry Andric       } else
507*9dba64beSDimitry Andric         LLDB_LOGF(log,
508*9dba64beSDimitry Andric                   "error: failed to get packet sequence mutex, not sending "
5090b57cec5SDimitry Andric                   "read all registers");
5100b57cec5SDimitry Andric     }
5110b57cec5SDimitry Andric   }
5120b57cec5SDimitry Andric 
5130b57cec5SDimitry Andric   data_sp.reset();
5140b57cec5SDimitry Andric   return false;
5150b57cec5SDimitry Andric }
5160b57cec5SDimitry Andric 
5170b57cec5SDimitry Andric bool GDBRemoteRegisterContext::WriteAllRegisterValues(
5180b57cec5SDimitry Andric     const lldb::DataBufferSP &data_sp) {
5190b57cec5SDimitry Andric   if (!data_sp || data_sp->GetBytes() == nullptr || data_sp->GetByteSize() == 0)
5200b57cec5SDimitry Andric     return false;
5210b57cec5SDimitry Andric 
5220b57cec5SDimitry Andric   ExecutionContext exe_ctx(CalculateThread());
5230b57cec5SDimitry Andric 
5240b57cec5SDimitry Andric   Process *process = exe_ctx.GetProcessPtr();
5250b57cec5SDimitry Andric   Thread *thread = exe_ctx.GetThreadPtr();
5260b57cec5SDimitry Andric   if (process == nullptr || thread == nullptr)
5270b57cec5SDimitry Andric     return false;
5280b57cec5SDimitry Andric 
5290b57cec5SDimitry Andric   GDBRemoteCommunicationClient &gdb_comm(
5300b57cec5SDimitry Andric       ((ProcessGDBRemote *)process)->GetGDBRemote());
5310b57cec5SDimitry Andric 
5320b57cec5SDimitry Andric   const bool use_g_packet =
5330b57cec5SDimitry Andric       !gdb_comm.AvoidGPackets((ProcessGDBRemote *)process);
5340b57cec5SDimitry Andric 
5350b57cec5SDimitry Andric   GDBRemoteClientBase::Lock lock(gdb_comm, false);
5360b57cec5SDimitry Andric   if (lock) {
5370b57cec5SDimitry Andric     // The data_sp contains the G response packet.
5380b57cec5SDimitry Andric     if (use_g_packet) {
5390b57cec5SDimitry Andric       if (gdb_comm.WriteAllRegisters(
5400b57cec5SDimitry Andric               m_thread.GetProtocolID(),
5410b57cec5SDimitry Andric               {data_sp->GetBytes(), size_t(data_sp->GetByteSize())}))
5420b57cec5SDimitry Andric         return true;
5430b57cec5SDimitry Andric 
5440b57cec5SDimitry Andric       uint32_t num_restored = 0;
5450b57cec5SDimitry Andric       // We need to manually go through all of the registers and restore them
5460b57cec5SDimitry Andric       // manually
5470b57cec5SDimitry Andric       DataExtractor restore_data(data_sp, m_reg_data.GetByteOrder(),
5480b57cec5SDimitry Andric                                  m_reg_data.GetAddressByteSize());
5490b57cec5SDimitry Andric 
5500b57cec5SDimitry Andric       const RegisterInfo *reg_info;
5510b57cec5SDimitry Andric 
5520b57cec5SDimitry Andric       // The g packet contents may either include the slice registers
5530b57cec5SDimitry Andric       // (registers defined in terms of other registers, e.g. eax is a subset
5540b57cec5SDimitry Andric       // of rax) or not.  The slice registers should NOT be in the g packet,
5550b57cec5SDimitry Andric       // but some implementations may incorrectly include them.
5560b57cec5SDimitry Andric       //
5570b57cec5SDimitry Andric       // If the slice registers are included in the packet, we must step over
5580b57cec5SDimitry Andric       // the slice registers when parsing the packet -- relying on the
5590b57cec5SDimitry Andric       // RegisterInfo byte_offset field would be incorrect. If the slice
5600b57cec5SDimitry Andric       // registers are not included, then using the byte_offset values into the
5610b57cec5SDimitry Andric       // data buffer is the best way to find individual register values.
5620b57cec5SDimitry Andric 
5630b57cec5SDimitry Andric       uint64_t size_including_slice_registers = 0;
5640b57cec5SDimitry Andric       uint64_t size_not_including_slice_registers = 0;
5650b57cec5SDimitry Andric       uint64_t size_by_highest_offset = 0;
5660b57cec5SDimitry Andric 
5670b57cec5SDimitry Andric       for (uint32_t reg_idx = 0;
5680b57cec5SDimitry Andric            (reg_info = GetRegisterInfoAtIndex(reg_idx)) != nullptr; ++reg_idx) {
5690b57cec5SDimitry Andric         size_including_slice_registers += reg_info->byte_size;
5700b57cec5SDimitry Andric         if (reg_info->value_regs == nullptr)
5710b57cec5SDimitry Andric           size_not_including_slice_registers += reg_info->byte_size;
5720b57cec5SDimitry Andric         if (reg_info->byte_offset >= size_by_highest_offset)
5730b57cec5SDimitry Andric           size_by_highest_offset = reg_info->byte_offset + reg_info->byte_size;
5740b57cec5SDimitry Andric       }
5750b57cec5SDimitry Andric 
5760b57cec5SDimitry Andric       bool use_byte_offset_into_buffer;
5770b57cec5SDimitry Andric       if (size_by_highest_offset == restore_data.GetByteSize()) {
5780b57cec5SDimitry Andric         // The size of the packet agrees with the highest offset: + size in the
5790b57cec5SDimitry Andric         // register file
5800b57cec5SDimitry Andric         use_byte_offset_into_buffer = true;
5810b57cec5SDimitry Andric       } else if (size_not_including_slice_registers ==
5820b57cec5SDimitry Andric                  restore_data.GetByteSize()) {
5830b57cec5SDimitry Andric         // The size of the packet is the same as concatenating all of the
5840b57cec5SDimitry Andric         // registers sequentially, skipping the slice registers
5850b57cec5SDimitry Andric         use_byte_offset_into_buffer = true;
5860b57cec5SDimitry Andric       } else if (size_including_slice_registers == restore_data.GetByteSize()) {
5870b57cec5SDimitry Andric         // The slice registers are present in the packet (when they shouldn't
5880b57cec5SDimitry Andric         // be). Don't try to use the RegisterInfo byte_offset into the
5890b57cec5SDimitry Andric         // restore_data, it will point to the wrong place.
5900b57cec5SDimitry Andric         use_byte_offset_into_buffer = false;
5910b57cec5SDimitry Andric       } else {
5920b57cec5SDimitry Andric         // None of our expected sizes match the actual g packet data we're
5930b57cec5SDimitry Andric         // looking at. The most conservative approach here is to use the
5940b57cec5SDimitry Andric         // running total byte offset.
5950b57cec5SDimitry Andric         use_byte_offset_into_buffer = false;
5960b57cec5SDimitry Andric       }
5970b57cec5SDimitry Andric 
5980b57cec5SDimitry Andric       // In case our register definitions don't include the correct offsets,
5990b57cec5SDimitry Andric       // keep track of the size of each reg & compute offset based on that.
6000b57cec5SDimitry Andric       uint32_t running_byte_offset = 0;
6010b57cec5SDimitry Andric       for (uint32_t reg_idx = 0;
6020b57cec5SDimitry Andric            (reg_info = GetRegisterInfoAtIndex(reg_idx)) != nullptr;
6030b57cec5SDimitry Andric            ++reg_idx, running_byte_offset += reg_info->byte_size) {
6040b57cec5SDimitry Andric         // Skip composite aka slice registers (e.g. eax is a slice of rax).
6050b57cec5SDimitry Andric         if (reg_info->value_regs)
6060b57cec5SDimitry Andric           continue;
6070b57cec5SDimitry Andric 
6080b57cec5SDimitry Andric         const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
6090b57cec5SDimitry Andric 
6100b57cec5SDimitry Andric         uint32_t register_offset;
6110b57cec5SDimitry Andric         if (use_byte_offset_into_buffer) {
6120b57cec5SDimitry Andric           register_offset = reg_info->byte_offset;
6130b57cec5SDimitry Andric         } else {
6140b57cec5SDimitry Andric           register_offset = running_byte_offset;
6150b57cec5SDimitry Andric         }
6160b57cec5SDimitry Andric 
6170b57cec5SDimitry Andric         const uint32_t reg_byte_size = reg_info->byte_size;
6180b57cec5SDimitry Andric 
6190b57cec5SDimitry Andric         const uint8_t *restore_src =
6200b57cec5SDimitry Andric             restore_data.PeekData(register_offset, reg_byte_size);
6210b57cec5SDimitry Andric         if (restore_src) {
6220b57cec5SDimitry Andric           SetRegisterIsValid(reg, false);
6230b57cec5SDimitry Andric           if (gdb_comm.WriteRegister(
6240b57cec5SDimitry Andric                   m_thread.GetProtocolID(),
6250b57cec5SDimitry Andric                   reg_info->kinds[eRegisterKindProcessPlugin],
6260b57cec5SDimitry Andric                   {restore_src, reg_byte_size}))
6270b57cec5SDimitry Andric             ++num_restored;
6280b57cec5SDimitry Andric         }
6290b57cec5SDimitry Andric       }
6300b57cec5SDimitry Andric       return num_restored > 0;
6310b57cec5SDimitry Andric     } else {
6320b57cec5SDimitry Andric       // For the use_g_packet == false case, we're going to write each register
6330b57cec5SDimitry Andric       // individually.  The data buffer is binary data in this case, instead of
6340b57cec5SDimitry Andric       // ascii characters.
6350b57cec5SDimitry Andric 
6360b57cec5SDimitry Andric       bool arm64_debugserver = false;
6370b57cec5SDimitry Andric       if (m_thread.GetProcess().get()) {
6380b57cec5SDimitry Andric         const ArchSpec &arch =
6390b57cec5SDimitry Andric             m_thread.GetProcess()->GetTarget().GetArchitecture();
640*9dba64beSDimitry Andric         if (arch.IsValid() &&
641*9dba64beSDimitry Andric             (arch.GetMachine() == llvm::Triple::aarch64 ||
642*9dba64beSDimitry Andric              arch.GetMachine() == llvm::Triple::aarch64_32) &&
6430b57cec5SDimitry Andric             arch.GetTriple().getVendor() == llvm::Triple::Apple &&
6440b57cec5SDimitry Andric             arch.GetTriple().getOS() == llvm::Triple::IOS) {
6450b57cec5SDimitry Andric           arm64_debugserver = true;
6460b57cec5SDimitry Andric         }
6470b57cec5SDimitry Andric       }
6480b57cec5SDimitry Andric       uint32_t num_restored = 0;
6490b57cec5SDimitry Andric       const RegisterInfo *reg_info;
6500b57cec5SDimitry Andric       for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != nullptr;
6510b57cec5SDimitry Andric            i++) {
6520b57cec5SDimitry Andric         if (reg_info->value_regs) // skip registers that are slices of real
6530b57cec5SDimitry Andric                                   // registers
6540b57cec5SDimitry Andric           continue;
6550b57cec5SDimitry Andric         // Skip the fpsr and fpcr floating point status/control register
6560b57cec5SDimitry Andric         // writing to work around a bug in an older version of debugserver that
6570b57cec5SDimitry Andric         // would lead to register context corruption when writing fpsr/fpcr.
6580b57cec5SDimitry Andric         if (arm64_debugserver && (strcmp(reg_info->name, "fpsr") == 0 ||
6590b57cec5SDimitry Andric                                   strcmp(reg_info->name, "fpcr") == 0)) {
6600b57cec5SDimitry Andric           continue;
6610b57cec5SDimitry Andric         }
6620b57cec5SDimitry Andric 
6630b57cec5SDimitry Andric         SetRegisterIsValid(reg_info, false);
6640b57cec5SDimitry Andric         if (gdb_comm.WriteRegister(m_thread.GetProtocolID(),
6650b57cec5SDimitry Andric                                    reg_info->kinds[eRegisterKindProcessPlugin],
6660b57cec5SDimitry Andric                                    {data_sp->GetBytes() + reg_info->byte_offset,
6670b57cec5SDimitry Andric                                     reg_info->byte_size}))
6680b57cec5SDimitry Andric           ++num_restored;
6690b57cec5SDimitry Andric       }
6700b57cec5SDimitry Andric       return num_restored > 0;
6710b57cec5SDimitry Andric     }
6720b57cec5SDimitry Andric   } else {
6730b57cec5SDimitry Andric     Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
6740b57cec5SDimitry Andric                                                            GDBR_LOG_PACKETS));
6750b57cec5SDimitry Andric     if (log) {
6760b57cec5SDimitry Andric       if (log->GetVerbose()) {
6770b57cec5SDimitry Andric         StreamString strm;
6780b57cec5SDimitry Andric         gdb_comm.DumpHistory(strm);
679*9dba64beSDimitry Andric         LLDB_LOGF(log,
680*9dba64beSDimitry Andric                   "error: failed to get packet sequence mutex, not sending "
6810b57cec5SDimitry Andric                   "write all registers:\n%s",
6820b57cec5SDimitry Andric                   strm.GetData());
6830b57cec5SDimitry Andric       } else
684*9dba64beSDimitry Andric         LLDB_LOGF(log,
685*9dba64beSDimitry Andric                   "error: failed to get packet sequence mutex, not sending "
6860b57cec5SDimitry Andric                   "write all registers");
6870b57cec5SDimitry Andric     }
6880b57cec5SDimitry Andric   }
6890b57cec5SDimitry Andric   return false;
6900b57cec5SDimitry Andric }
6910b57cec5SDimitry Andric 
6920b57cec5SDimitry Andric uint32_t GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber(
6930b57cec5SDimitry Andric     lldb::RegisterKind kind, uint32_t num) {
6940b57cec5SDimitry Andric   return m_reg_info.ConvertRegisterKindToRegisterNumber(kind, num);
6950b57cec5SDimitry Andric }
6960b57cec5SDimitry Andric 
6970b57cec5SDimitry Andric void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
6980b57cec5SDimitry Andric   // For Advanced SIMD and VFP register mapping.
6990b57cec5SDimitry Andric   static uint32_t g_d0_regs[] = {26, 27, LLDB_INVALID_REGNUM};  // (s0, s1)
7000b57cec5SDimitry Andric   static uint32_t g_d1_regs[] = {28, 29, LLDB_INVALID_REGNUM};  // (s2, s3)
7010b57cec5SDimitry Andric   static uint32_t g_d2_regs[] = {30, 31, LLDB_INVALID_REGNUM};  // (s4, s5)
7020b57cec5SDimitry Andric   static uint32_t g_d3_regs[] = {32, 33, LLDB_INVALID_REGNUM};  // (s6, s7)
7030b57cec5SDimitry Andric   static uint32_t g_d4_regs[] = {34, 35, LLDB_INVALID_REGNUM};  // (s8, s9)
7040b57cec5SDimitry Andric   static uint32_t g_d5_regs[] = {36, 37, LLDB_INVALID_REGNUM};  // (s10, s11)
7050b57cec5SDimitry Andric   static uint32_t g_d6_regs[] = {38, 39, LLDB_INVALID_REGNUM};  // (s12, s13)
7060b57cec5SDimitry Andric   static uint32_t g_d7_regs[] = {40, 41, LLDB_INVALID_REGNUM};  // (s14, s15)
7070b57cec5SDimitry Andric   static uint32_t g_d8_regs[] = {42, 43, LLDB_INVALID_REGNUM};  // (s16, s17)
7080b57cec5SDimitry Andric   static uint32_t g_d9_regs[] = {44, 45, LLDB_INVALID_REGNUM};  // (s18, s19)
7090b57cec5SDimitry Andric   static uint32_t g_d10_regs[] = {46, 47, LLDB_INVALID_REGNUM}; // (s20, s21)
7100b57cec5SDimitry Andric   static uint32_t g_d11_regs[] = {48, 49, LLDB_INVALID_REGNUM}; // (s22, s23)
7110b57cec5SDimitry Andric   static uint32_t g_d12_regs[] = {50, 51, LLDB_INVALID_REGNUM}; // (s24, s25)
7120b57cec5SDimitry Andric   static uint32_t g_d13_regs[] = {52, 53, LLDB_INVALID_REGNUM}; // (s26, s27)
7130b57cec5SDimitry Andric   static uint32_t g_d14_regs[] = {54, 55, LLDB_INVALID_REGNUM}; // (s28, s29)
7140b57cec5SDimitry Andric   static uint32_t g_d15_regs[] = {56, 57, LLDB_INVALID_REGNUM}; // (s30, s31)
7150b57cec5SDimitry Andric   static uint32_t g_q0_regs[] = {
7160b57cec5SDimitry Andric       26, 27, 28, 29, LLDB_INVALID_REGNUM}; // (d0, d1) -> (s0, s1, s2, s3)
7170b57cec5SDimitry Andric   static uint32_t g_q1_regs[] = {
7180b57cec5SDimitry Andric       30, 31, 32, 33, LLDB_INVALID_REGNUM}; // (d2, d3) -> (s4, s5, s6, s7)
7190b57cec5SDimitry Andric   static uint32_t g_q2_regs[] = {
7200b57cec5SDimitry Andric       34, 35, 36, 37, LLDB_INVALID_REGNUM}; // (d4, d5) -> (s8, s9, s10, s11)
7210b57cec5SDimitry Andric   static uint32_t g_q3_regs[] = {
7220b57cec5SDimitry Andric       38, 39, 40, 41, LLDB_INVALID_REGNUM}; // (d6, d7) -> (s12, s13, s14, s15)
7230b57cec5SDimitry Andric   static uint32_t g_q4_regs[] = {
7240b57cec5SDimitry Andric       42, 43, 44, 45, LLDB_INVALID_REGNUM}; // (d8, d9) -> (s16, s17, s18, s19)
7250b57cec5SDimitry Andric   static uint32_t g_q5_regs[] = {
7260b57cec5SDimitry Andric       46, 47, 48, 49,
7270b57cec5SDimitry Andric       LLDB_INVALID_REGNUM}; // (d10, d11) -> (s20, s21, s22, s23)
7280b57cec5SDimitry Andric   static uint32_t g_q6_regs[] = {
7290b57cec5SDimitry Andric       50, 51, 52, 53,
7300b57cec5SDimitry Andric       LLDB_INVALID_REGNUM}; // (d12, d13) -> (s24, s25, s26, s27)
7310b57cec5SDimitry Andric   static uint32_t g_q7_regs[] = {
7320b57cec5SDimitry Andric       54, 55, 56, 57,
7330b57cec5SDimitry Andric       LLDB_INVALID_REGNUM}; // (d14, d15) -> (s28, s29, s30, s31)
7340b57cec5SDimitry Andric   static uint32_t g_q8_regs[] = {59, 60, LLDB_INVALID_REGNUM};  // (d16, d17)
7350b57cec5SDimitry Andric   static uint32_t g_q9_regs[] = {61, 62, LLDB_INVALID_REGNUM};  // (d18, d19)
7360b57cec5SDimitry Andric   static uint32_t g_q10_regs[] = {63, 64, LLDB_INVALID_REGNUM}; // (d20, d21)
7370b57cec5SDimitry Andric   static uint32_t g_q11_regs[] = {65, 66, LLDB_INVALID_REGNUM}; // (d22, d23)
7380b57cec5SDimitry Andric   static uint32_t g_q12_regs[] = {67, 68, LLDB_INVALID_REGNUM}; // (d24, d25)
7390b57cec5SDimitry Andric   static uint32_t g_q13_regs[] = {69, 70, LLDB_INVALID_REGNUM}; // (d26, d27)
7400b57cec5SDimitry Andric   static uint32_t g_q14_regs[] = {71, 72, LLDB_INVALID_REGNUM}; // (d28, d29)
7410b57cec5SDimitry Andric   static uint32_t g_q15_regs[] = {73, 74, LLDB_INVALID_REGNUM}; // (d30, d31)
7420b57cec5SDimitry Andric 
7430b57cec5SDimitry Andric   // This is our array of composite registers, with each element coming from
7440b57cec5SDimitry Andric   // the above register mappings.
7450b57cec5SDimitry Andric   static uint32_t *g_composites[] = {
7460b57cec5SDimitry Andric       g_d0_regs,  g_d1_regs,  g_d2_regs,  g_d3_regs,  g_d4_regs,  g_d5_regs,
7470b57cec5SDimitry Andric       g_d6_regs,  g_d7_regs,  g_d8_regs,  g_d9_regs,  g_d10_regs, g_d11_regs,
7480b57cec5SDimitry Andric       g_d12_regs, g_d13_regs, g_d14_regs, g_d15_regs, g_q0_regs,  g_q1_regs,
7490b57cec5SDimitry Andric       g_q2_regs,  g_q3_regs,  g_q4_regs,  g_q5_regs,  g_q6_regs,  g_q7_regs,
7500b57cec5SDimitry Andric       g_q8_regs,  g_q9_regs,  g_q10_regs, g_q11_regs, g_q12_regs, g_q13_regs,
7510b57cec5SDimitry Andric       g_q14_regs, g_q15_regs};
7520b57cec5SDimitry Andric 
7530b57cec5SDimitry Andric   // clang-format off
7540b57cec5SDimitry Andric     static RegisterInfo g_register_infos[] = {
7550b57cec5SDimitry Andric //   NAME     ALT     SZ   OFF  ENCODING          FORMAT          EH_FRAME             DWARF                GENERIC                 PROCESS PLUGIN  LLDB    VALUE REGS    INVALIDATE REGS SIZE EXPR SIZE LEN
7560b57cec5SDimitry Andric //   ======   ======  ===  ===  =============     ==========      ===================  ===================  ======================  =============   ====    ==========    =============== ========= ========
7570b57cec5SDimitry Andric     { "r0",   "arg1",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r0,          dwarf_r0,            LLDB_REGNUM_GENERIC_ARG1,0,               0 },     nullptr,           nullptr,  nullptr,       0 },
7580b57cec5SDimitry Andric     { "r1",   "arg2",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r1,          dwarf_r1,            LLDB_REGNUM_GENERIC_ARG2,1,               1 },     nullptr,           nullptr,  nullptr,       0 },
7590b57cec5SDimitry Andric     { "r2",   "arg3",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r2,          dwarf_r2,            LLDB_REGNUM_GENERIC_ARG3,2,               2 },     nullptr,           nullptr,  nullptr,       0 },
7600b57cec5SDimitry Andric     { "r3",   "arg4",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r3,          dwarf_r3,            LLDB_REGNUM_GENERIC_ARG4,3,               3 },     nullptr,           nullptr,  nullptr,       0 },
7610b57cec5SDimitry Andric     { "r4",  nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r4,          dwarf_r4,            LLDB_INVALID_REGNUM,     4,               4 },     nullptr,           nullptr,  nullptr,       0 },
7620b57cec5SDimitry Andric     { "r5",  nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r5,          dwarf_r5,            LLDB_INVALID_REGNUM,     5,               5 },     nullptr,           nullptr,  nullptr,       0 },
7630b57cec5SDimitry Andric     { "r6",  nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r6,          dwarf_r6,            LLDB_INVALID_REGNUM,     6,               6 },     nullptr,           nullptr,  nullptr,       0 },
7640b57cec5SDimitry Andric     { "r7",     "fp",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r7,          dwarf_r7,            LLDB_REGNUM_GENERIC_FP,  7,               7 },     nullptr,           nullptr,  nullptr,       0 },
7650b57cec5SDimitry Andric     { "r8",  nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r8,          dwarf_r8,            LLDB_INVALID_REGNUM,     8,               8 },     nullptr,           nullptr,  nullptr,       0 },
7660b57cec5SDimitry Andric     { "r9",  nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r9,          dwarf_r9,            LLDB_INVALID_REGNUM,     9,               9 },     nullptr,           nullptr,  nullptr,       0 },
7670b57cec5SDimitry Andric     { "r10", nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r10,         dwarf_r10,           LLDB_INVALID_REGNUM,    10,              10 },     nullptr,           nullptr,  nullptr,       0 },
7680b57cec5SDimitry Andric     { "r11", nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r11,         dwarf_r11,           LLDB_INVALID_REGNUM,    11,              11 },     nullptr,           nullptr,  nullptr,       0 },
7690b57cec5SDimitry Andric     { "r12", nullptr,   4,   0, eEncodingUint,    eFormatHex,   { ehframe_r12,         dwarf_r12,           LLDB_INVALID_REGNUM,    12,              12 },     nullptr,           nullptr,  nullptr,       0 },
7700b57cec5SDimitry Andric     { "sp",     "r13",  4,   0, eEncodingUint,    eFormatHex,   { ehframe_sp,          dwarf_sp,            LLDB_REGNUM_GENERIC_SP, 13,              13 },     nullptr,           nullptr,  nullptr,       0 },
7710b57cec5SDimitry Andric     { "lr",     "r14",  4,   0, eEncodingUint,    eFormatHex,   { ehframe_lr,          dwarf_lr,            LLDB_REGNUM_GENERIC_RA, 14,              14 },     nullptr,           nullptr,  nullptr,       0 },
7720b57cec5SDimitry Andric     { "pc",     "r15",  4,   0, eEncodingUint,    eFormatHex,   { ehframe_pc,          dwarf_pc,            LLDB_REGNUM_GENERIC_PC, 15,              15 },     nullptr,           nullptr,  nullptr,       0 },
7730b57cec5SDimitry Andric     { "f0",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    16,              16 },     nullptr,           nullptr,  nullptr,       0 },
7740b57cec5SDimitry Andric     { "f1",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    17,              17 },     nullptr,           nullptr,  nullptr,       0 },
7750b57cec5SDimitry Andric     { "f2",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    18,              18 },     nullptr,           nullptr,  nullptr,       0 },
7760b57cec5SDimitry Andric     { "f3",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    19,              19 },     nullptr,           nullptr,  nullptr,       0 },
7770b57cec5SDimitry Andric     { "f4",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    20,              20 },     nullptr,           nullptr,  nullptr,       0 },
7780b57cec5SDimitry Andric     { "f5",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    21,              21 },     nullptr,           nullptr,  nullptr,       0 },
7790b57cec5SDimitry Andric     { "f6",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    22,              22 },     nullptr,           nullptr,  nullptr,       0 },
7800b57cec5SDimitry Andric     { "f7",  nullptr,  12,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    23,              23 },     nullptr,           nullptr,  nullptr,       0 },
7810b57cec5SDimitry Andric     { "fps", nullptr,   4,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    24,              24 },     nullptr,           nullptr,  nullptr,       0 },
7820b57cec5SDimitry Andric     { "cpsr","flags",   4,   0, eEncodingUint,    eFormatHex,   { ehframe_cpsr,        dwarf_cpsr,          LLDB_INVALID_REGNUM,    25,              25 },     nullptr,           nullptr,  nullptr,       0 },
7830b57cec5SDimitry Andric     { "s0",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0,            LLDB_INVALID_REGNUM,    26,              26 },     nullptr,           nullptr,  nullptr,       0 },
7840b57cec5SDimitry Andric     { "s1",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1,            LLDB_INVALID_REGNUM,    27,              27 },     nullptr,           nullptr,  nullptr,       0 },
7850b57cec5SDimitry Andric     { "s2",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2,            LLDB_INVALID_REGNUM,    28,              28 },     nullptr,           nullptr,  nullptr,       0 },
7860b57cec5SDimitry Andric     { "s3",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3,            LLDB_INVALID_REGNUM,    29,              29 },     nullptr,           nullptr,  nullptr,       0 },
7870b57cec5SDimitry Andric     { "s4",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4,            LLDB_INVALID_REGNUM,    30,              30 },     nullptr,           nullptr,  nullptr,       0 },
7880b57cec5SDimitry Andric     { "s5",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5,            LLDB_INVALID_REGNUM,    31,              31 },     nullptr,           nullptr,  nullptr,       0 },
7890b57cec5SDimitry Andric     { "s6",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6,            LLDB_INVALID_REGNUM,    32,              32 },     nullptr,           nullptr,  nullptr,       0 },
7900b57cec5SDimitry Andric     { "s7",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7,            LLDB_INVALID_REGNUM,    33,              33 },     nullptr,           nullptr,  nullptr,       0 },
7910b57cec5SDimitry Andric     { "s8",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8,            LLDB_INVALID_REGNUM,    34,              34 },     nullptr,           nullptr,  nullptr,       0 },
7920b57cec5SDimitry Andric     { "s9",  nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9,            LLDB_INVALID_REGNUM,    35,              35 },     nullptr,           nullptr,  nullptr,       0 },
7930b57cec5SDimitry Andric     { "s10", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10,           LLDB_INVALID_REGNUM,    36,              36 },     nullptr,           nullptr,  nullptr,       0 },
7940b57cec5SDimitry Andric     { "s11", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11,           LLDB_INVALID_REGNUM,    37,              37 },     nullptr,           nullptr,  nullptr,       0 },
7950b57cec5SDimitry Andric     { "s12", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12,           LLDB_INVALID_REGNUM,    38,              38 },     nullptr,           nullptr,  nullptr,       0 },
7960b57cec5SDimitry Andric     { "s13", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13,           LLDB_INVALID_REGNUM,    39,              39 },     nullptr,           nullptr,  nullptr,       0 },
7970b57cec5SDimitry Andric     { "s14", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14,           LLDB_INVALID_REGNUM,    40,              40 },     nullptr,           nullptr,  nullptr,       0 },
7980b57cec5SDimitry Andric     { "s15", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15,           LLDB_INVALID_REGNUM,    41,              41 },     nullptr,           nullptr,  nullptr,       0 },
7990b57cec5SDimitry Andric     { "s16", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16,           LLDB_INVALID_REGNUM,    42,              42 },     nullptr,           nullptr,  nullptr,       0 },
8000b57cec5SDimitry Andric     { "s17", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17,           LLDB_INVALID_REGNUM,    43,              43 },     nullptr,           nullptr,  nullptr,       0 },
8010b57cec5SDimitry Andric     { "s18", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18,           LLDB_INVALID_REGNUM,    44,              44 },     nullptr,           nullptr,  nullptr,       0 },
8020b57cec5SDimitry Andric     { "s19", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19,           LLDB_INVALID_REGNUM,    45,              45 },     nullptr,           nullptr,  nullptr,       0 },
8030b57cec5SDimitry Andric     { "s20", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20,           LLDB_INVALID_REGNUM,    46,              46 },     nullptr,           nullptr,  nullptr,       0 },
8040b57cec5SDimitry Andric     { "s21", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21,           LLDB_INVALID_REGNUM,    47,              47 },     nullptr,           nullptr,  nullptr,       0 },
8050b57cec5SDimitry Andric     { "s22", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22,           LLDB_INVALID_REGNUM,    48,              48 },     nullptr,           nullptr,  nullptr,       0 },
8060b57cec5SDimitry Andric     { "s23", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23,           LLDB_INVALID_REGNUM,    49,              49 },     nullptr,           nullptr,  nullptr,       0 },
8070b57cec5SDimitry Andric     { "s24", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24,           LLDB_INVALID_REGNUM,    50,              50 },     nullptr,           nullptr,  nullptr,       0 },
8080b57cec5SDimitry Andric     { "s25", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25,           LLDB_INVALID_REGNUM,    51,              51 },     nullptr,           nullptr,  nullptr,       0 },
8090b57cec5SDimitry Andric     { "s26", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26,           LLDB_INVALID_REGNUM,    52,              52 },     nullptr,           nullptr,  nullptr,       0 },
8100b57cec5SDimitry Andric     { "s27", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27,           LLDB_INVALID_REGNUM,    53,              53 },     nullptr,           nullptr,  nullptr,       0 },
8110b57cec5SDimitry Andric     { "s28", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28,           LLDB_INVALID_REGNUM,    54,              54 },     nullptr,           nullptr,  nullptr,       0 },
8120b57cec5SDimitry Andric     { "s29", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29,           LLDB_INVALID_REGNUM,    55,              55 },     nullptr,           nullptr,  nullptr,       0 },
8130b57cec5SDimitry Andric     { "s30", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30,           LLDB_INVALID_REGNUM,    56,              56 },     nullptr,           nullptr,  nullptr,       0 },
8140b57cec5SDimitry Andric     { "s31", nullptr,   4,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31,           LLDB_INVALID_REGNUM,    57,              57 },     nullptr,           nullptr,  nullptr,       0 },
8150b57cec5SDimitry Andric     { "fpscr",nullptr,  4,   0, eEncodingUint,    eFormatHex,   { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    58,              58 },     nullptr,           nullptr,  nullptr,       0 },
8160b57cec5SDimitry Andric     { "d16", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16,           LLDB_INVALID_REGNUM,    59,              59 },     nullptr,           nullptr,  nullptr,       0 },
8170b57cec5SDimitry Andric     { "d17", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17,           LLDB_INVALID_REGNUM,    60,              60 },     nullptr,           nullptr,  nullptr,       0 },
8180b57cec5SDimitry Andric     { "d18", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18,           LLDB_INVALID_REGNUM,    61,              61 },     nullptr,           nullptr,  nullptr,       0 },
8190b57cec5SDimitry Andric     { "d19", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19,           LLDB_INVALID_REGNUM,    62,              62 },     nullptr,           nullptr,  nullptr,       0 },
8200b57cec5SDimitry Andric     { "d20", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20,           LLDB_INVALID_REGNUM,    63,              63 },     nullptr,           nullptr,  nullptr,       0 },
8210b57cec5SDimitry Andric     { "d21", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21,           LLDB_INVALID_REGNUM,    64,              64 },     nullptr,           nullptr,  nullptr,       0 },
8220b57cec5SDimitry Andric     { "d22", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22,           LLDB_INVALID_REGNUM,    65,              65 },     nullptr,           nullptr,  nullptr,       0 },
8230b57cec5SDimitry Andric     { "d23", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23,           LLDB_INVALID_REGNUM,    66,              66 },     nullptr,           nullptr,  nullptr,       0 },
8240b57cec5SDimitry Andric     { "d24", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24,           LLDB_INVALID_REGNUM,    67,              67 },     nullptr,           nullptr,  nullptr,       0 },
8250b57cec5SDimitry Andric     { "d25", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25,           LLDB_INVALID_REGNUM,    68,              68 },     nullptr,           nullptr,  nullptr,       0 },
8260b57cec5SDimitry Andric     { "d26", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26,           LLDB_INVALID_REGNUM,    69,              69 },     nullptr,           nullptr,  nullptr,       0 },
8270b57cec5SDimitry Andric     { "d27", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27,           LLDB_INVALID_REGNUM,    70,              70 },     nullptr,           nullptr,  nullptr,       0 },
8280b57cec5SDimitry Andric     { "d28", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28,           LLDB_INVALID_REGNUM,    71,              71 },     nullptr,           nullptr,  nullptr,       0 },
8290b57cec5SDimitry Andric     { "d29", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29,           LLDB_INVALID_REGNUM,    72,              72 },     nullptr,           nullptr,  nullptr,       0 },
8300b57cec5SDimitry Andric     { "d30", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30,           LLDB_INVALID_REGNUM,    73,              73 },     nullptr,           nullptr,  nullptr,       0 },
8310b57cec5SDimitry Andric     { "d31", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31,           LLDB_INVALID_REGNUM,    74,              74 },     nullptr,           nullptr,  nullptr,       0 },
8320b57cec5SDimitry Andric     { "d0",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0,            LLDB_INVALID_REGNUM,    75,              75 },   g_d0_regs,           nullptr,  nullptr,       0 },
8330b57cec5SDimitry Andric     { "d1",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1,            LLDB_INVALID_REGNUM,    76,              76 },   g_d1_regs,           nullptr,  nullptr,       0 },
8340b57cec5SDimitry Andric     { "d2",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2,            LLDB_INVALID_REGNUM,    77,              77 },   g_d2_regs,           nullptr,  nullptr,       0 },
8350b57cec5SDimitry Andric     { "d3",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3,            LLDB_INVALID_REGNUM,    78,              78 },   g_d3_regs,           nullptr,  nullptr,       0 },
8360b57cec5SDimitry Andric     { "d4",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4,            LLDB_INVALID_REGNUM,    79,              79 },   g_d4_regs,           nullptr,  nullptr,       0 },
8370b57cec5SDimitry Andric     { "d5",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5,            LLDB_INVALID_REGNUM,    80,              80 },   g_d5_regs,           nullptr,  nullptr,       0 },
8380b57cec5SDimitry Andric     { "d6",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6,            LLDB_INVALID_REGNUM,    81,              81 },   g_d6_regs,           nullptr,  nullptr,       0 },
8390b57cec5SDimitry Andric     { "d7",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7,            LLDB_INVALID_REGNUM,    82,              82 },   g_d7_regs,           nullptr,  nullptr,       0 },
8400b57cec5SDimitry Andric     { "d8",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8,            LLDB_INVALID_REGNUM,    83,              83 },   g_d8_regs,           nullptr,  nullptr,       0 },
8410b57cec5SDimitry Andric     { "d9",  nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9,            LLDB_INVALID_REGNUM,    84,              84 },   g_d9_regs,           nullptr,  nullptr,       0 },
8420b57cec5SDimitry Andric     { "d10", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10,           LLDB_INVALID_REGNUM,    85,              85 },  g_d10_regs,           nullptr,  nullptr,       0 },
8430b57cec5SDimitry Andric     { "d11", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11,           LLDB_INVALID_REGNUM,    86,              86 },  g_d11_regs,           nullptr,  nullptr,       0 },
8440b57cec5SDimitry Andric     { "d12", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12,           LLDB_INVALID_REGNUM,    87,              87 },  g_d12_regs,           nullptr,  nullptr,       0 },
8450b57cec5SDimitry Andric     { "d13", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13,           LLDB_INVALID_REGNUM,    88,              88 },  g_d13_regs,           nullptr,  nullptr,       0 },
8460b57cec5SDimitry Andric     { "d14", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14,           LLDB_INVALID_REGNUM,    89,              89 },  g_d14_regs,           nullptr,  nullptr,       0 },
8470b57cec5SDimitry Andric     { "d15", nullptr,   8,   0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15,           LLDB_INVALID_REGNUM,    90,              90 },  g_d15_regs,           nullptr,  nullptr,       0 },
8480b57cec5SDimitry Andric     { "q0",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q0,    LLDB_INVALID_REGNUM,    91,              91 },   g_q0_regs,           nullptr,  nullptr,       0 },
8490b57cec5SDimitry Andric     { "q1",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q1,    LLDB_INVALID_REGNUM,    92,              92 },   g_q1_regs,           nullptr,  nullptr,       0 },
8500b57cec5SDimitry Andric     { "q2",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q2,    LLDB_INVALID_REGNUM,    93,              93 },   g_q2_regs,           nullptr,  nullptr,       0 },
8510b57cec5SDimitry Andric     { "q3",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q3,    LLDB_INVALID_REGNUM,    94,              94 },   g_q3_regs,           nullptr,  nullptr,       0 },
8520b57cec5SDimitry Andric     { "q4",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q4,    LLDB_INVALID_REGNUM,    95,              95 },   g_q4_regs,           nullptr,  nullptr,       0 },
8530b57cec5SDimitry Andric     { "q5",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q5,    LLDB_INVALID_REGNUM,    96,              96 },   g_q5_regs,           nullptr,  nullptr,       0 },
8540b57cec5SDimitry Andric     { "q6",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q6,    LLDB_INVALID_REGNUM,    97,              97 },   g_q6_regs,           nullptr,  nullptr,       0 },
8550b57cec5SDimitry Andric     { "q7",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q7,    LLDB_INVALID_REGNUM,    98,              98 },   g_q7_regs,           nullptr,  nullptr,       0 },
8560b57cec5SDimitry Andric     { "q8",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q8,    LLDB_INVALID_REGNUM,    99,              99 },   g_q8_regs,           nullptr,  nullptr,       0 },
8570b57cec5SDimitry Andric     { "q9",  nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q9,    LLDB_INVALID_REGNUM,   100,             100 },   g_q9_regs,           nullptr,  nullptr,       0 },
8580b57cec5SDimitry Andric     { "q10", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q10,   LLDB_INVALID_REGNUM,   101,             101 },  g_q10_regs,           nullptr,  nullptr,       0 },
8590b57cec5SDimitry Andric     { "q11", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q11,   LLDB_INVALID_REGNUM,   102,             102 },  g_q11_regs,           nullptr,  nullptr,       0 },
8600b57cec5SDimitry Andric     { "q12", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q12,   LLDB_INVALID_REGNUM,   103,             103 },  g_q12_regs,           nullptr,  nullptr,       0 },
8610b57cec5SDimitry Andric     { "q13", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q13,   LLDB_INVALID_REGNUM,   104,             104 },  g_q13_regs,           nullptr,  nullptr,       0 },
8620b57cec5SDimitry Andric     { "q14", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q14,   LLDB_INVALID_REGNUM,   105,             105 },  g_q14_regs,           nullptr,  nullptr,       0 },
8630b57cec5SDimitry Andric     { "q15", nullptr,   16,  0, eEncodingVector,  eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_q15,   LLDB_INVALID_REGNUM,   106,             106 },  g_q15_regs,           nullptr,  nullptr,       0 }
8640b57cec5SDimitry Andric     };
8650b57cec5SDimitry Andric   // clang-format on
8660b57cec5SDimitry Andric 
8670b57cec5SDimitry Andric   static const uint32_t num_registers = llvm::array_lengthof(g_register_infos);
8680b57cec5SDimitry Andric   static ConstString gpr_reg_set("General Purpose Registers");
8690b57cec5SDimitry Andric   static ConstString sfp_reg_set("Software Floating Point Registers");
8700b57cec5SDimitry Andric   static ConstString vfp_reg_set("Floating Point Registers");
8710b57cec5SDimitry Andric   size_t i;
8720b57cec5SDimitry Andric   if (from_scratch) {
8730b57cec5SDimitry Andric     // Calculate the offsets of the registers
8740b57cec5SDimitry Andric     // Note that the layout of the "composite" registers (d0-d15 and q0-q15)
8750b57cec5SDimitry Andric     // which comes after the "primordial" registers is important.  This enables
8760b57cec5SDimitry Andric     // us to calculate the offset of the composite register by using the offset
8770b57cec5SDimitry Andric     // of its first primordial register.  For example, to calculate the offset
8780b57cec5SDimitry Andric     // of q0, use s0's offset.
8790b57cec5SDimitry Andric     if (g_register_infos[2].byte_offset == 0) {
8800b57cec5SDimitry Andric       uint32_t byte_offset = 0;
8810b57cec5SDimitry Andric       for (i = 0; i < num_registers; ++i) {
8820b57cec5SDimitry Andric         // For primordial registers, increment the byte_offset by the byte_size
8830b57cec5SDimitry Andric         // to arrive at the byte_offset for the next register.  Otherwise, we
8840b57cec5SDimitry Andric         // have a composite register whose offset can be calculated by
8850b57cec5SDimitry Andric         // consulting the offset of its first primordial register.
8860b57cec5SDimitry Andric         if (!g_register_infos[i].value_regs) {
8870b57cec5SDimitry Andric           g_register_infos[i].byte_offset = byte_offset;
8880b57cec5SDimitry Andric           byte_offset += g_register_infos[i].byte_size;
8890b57cec5SDimitry Andric         } else {
8900b57cec5SDimitry Andric           const uint32_t first_primordial_reg =
8910b57cec5SDimitry Andric               g_register_infos[i].value_regs[0];
8920b57cec5SDimitry Andric           g_register_infos[i].byte_offset =
8930b57cec5SDimitry Andric               g_register_infos[first_primordial_reg].byte_offset;
8940b57cec5SDimitry Andric         }
8950b57cec5SDimitry Andric       }
8960b57cec5SDimitry Andric     }
8970b57cec5SDimitry Andric     for (i = 0; i < num_registers; ++i) {
8980b57cec5SDimitry Andric       ConstString name;
8990b57cec5SDimitry Andric       ConstString alt_name;
9000b57cec5SDimitry Andric       if (g_register_infos[i].name && g_register_infos[i].name[0])
9010b57cec5SDimitry Andric         name.SetCString(g_register_infos[i].name);
9020b57cec5SDimitry Andric       if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0])
9030b57cec5SDimitry Andric         alt_name.SetCString(g_register_infos[i].alt_name);
9040b57cec5SDimitry Andric 
9050b57cec5SDimitry Andric       if (i <= 15 || i == 25)
9060b57cec5SDimitry Andric         AddRegister(g_register_infos[i], name, alt_name, gpr_reg_set);
9070b57cec5SDimitry Andric       else if (i <= 24)
9080b57cec5SDimitry Andric         AddRegister(g_register_infos[i], name, alt_name, sfp_reg_set);
9090b57cec5SDimitry Andric       else
9100b57cec5SDimitry Andric         AddRegister(g_register_infos[i], name, alt_name, vfp_reg_set);
9110b57cec5SDimitry Andric     }
9120b57cec5SDimitry Andric   } else {
9130b57cec5SDimitry Andric     // Add composite registers to our primordial registers, then.
9140b57cec5SDimitry Andric     const size_t num_composites = llvm::array_lengthof(g_composites);
9150b57cec5SDimitry Andric     const size_t num_dynamic_regs = GetNumRegisters();
9160b57cec5SDimitry Andric     const size_t num_common_regs = num_registers - num_composites;
9170b57cec5SDimitry Andric     RegisterInfo *g_comp_register_infos = g_register_infos + num_common_regs;
9180b57cec5SDimitry Andric 
9190b57cec5SDimitry Andric     // First we need to validate that all registers that we already have match
9200b57cec5SDimitry Andric     // the non composite regs. If so, then we can add the registers, else we
9210b57cec5SDimitry Andric     // need to bail
9220b57cec5SDimitry Andric     bool match = true;
9230b57cec5SDimitry Andric     if (num_dynamic_regs == num_common_regs) {
9240b57cec5SDimitry Andric       for (i = 0; match && i < num_dynamic_regs; ++i) {
9250b57cec5SDimitry Andric         // Make sure all register names match
9260b57cec5SDimitry Andric         if (m_regs[i].name && g_register_infos[i].name) {
9270b57cec5SDimitry Andric           if (strcmp(m_regs[i].name, g_register_infos[i].name)) {
9280b57cec5SDimitry Andric             match = false;
9290b57cec5SDimitry Andric             break;
9300b57cec5SDimitry Andric           }
9310b57cec5SDimitry Andric         }
9320b57cec5SDimitry Andric 
9330b57cec5SDimitry Andric         // Make sure all register byte sizes match
9340b57cec5SDimitry Andric         if (m_regs[i].byte_size != g_register_infos[i].byte_size) {
9350b57cec5SDimitry Andric           match = false;
9360b57cec5SDimitry Andric           break;
9370b57cec5SDimitry Andric         }
9380b57cec5SDimitry Andric       }
9390b57cec5SDimitry Andric     } else {
9400b57cec5SDimitry Andric       // Wrong number of registers.
9410b57cec5SDimitry Andric       match = false;
9420b57cec5SDimitry Andric     }
9430b57cec5SDimitry Andric     // If "match" is true, then we can add extra registers.
9440b57cec5SDimitry Andric     if (match) {
9450b57cec5SDimitry Andric       for (i = 0; i < num_composites; ++i) {
9460b57cec5SDimitry Andric         ConstString name;
9470b57cec5SDimitry Andric         ConstString alt_name;
9480b57cec5SDimitry Andric         const uint32_t first_primordial_reg =
9490b57cec5SDimitry Andric             g_comp_register_infos[i].value_regs[0];
9500b57cec5SDimitry Andric         const char *reg_name = g_register_infos[first_primordial_reg].name;
9510b57cec5SDimitry Andric         if (reg_name && reg_name[0]) {
9520b57cec5SDimitry Andric           for (uint32_t j = 0; j < num_dynamic_regs; ++j) {
9530b57cec5SDimitry Andric             const RegisterInfo *reg_info = GetRegisterInfoAtIndex(j);
9540b57cec5SDimitry Andric             // Find a matching primordial register info entry.
9550b57cec5SDimitry Andric             if (reg_info && reg_info->name &&
9560b57cec5SDimitry Andric                 ::strcasecmp(reg_info->name, reg_name) == 0) {
9570b57cec5SDimitry Andric               // The name matches the existing primordial entry. Find and
9580b57cec5SDimitry Andric               // assign the offset, and then add this composite register entry.
9590b57cec5SDimitry Andric               g_comp_register_infos[i].byte_offset = reg_info->byte_offset;
9600b57cec5SDimitry Andric               name.SetCString(g_comp_register_infos[i].name);
9610b57cec5SDimitry Andric               AddRegister(g_comp_register_infos[i], name, alt_name,
9620b57cec5SDimitry Andric                           vfp_reg_set);
9630b57cec5SDimitry Andric             }
9640b57cec5SDimitry Andric           }
9650b57cec5SDimitry Andric         }
9660b57cec5SDimitry Andric       }
9670b57cec5SDimitry Andric     }
9680b57cec5SDimitry Andric   }
9690b57cec5SDimitry Andric }
970