mips64: clean up register context storage

Store the gpr data in a DataBufferHeap and use a DataExtractor to
extract register values with appropriate endianness.  This avoids hard-
coding the register count, and with some further work would allow this
class to provide generic register context storage for any CPU.

llvm-svn: 205329
This commit is contained in:
Ed Maste 2014-04-01 17:27:25 +00:00
parent 17f4160859
commit af58e02d1c
2 changed files with 14 additions and 12 deletions

View File

@ -21,13 +21,9 @@ RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(Thread &thread,
const DataExtractor &fpregset)
: RegisterContextPOSIX_mips64(thread, 0, register_info)
{
size_t i;
lldb::offset_t offset = 0;
for (i = 0; i < k_num_gpr_registers_mips64; i++)
{
m_reg[i] = gpregset.GetU64(&offset);
}
m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
RegisterContextCorePOSIX_mips64::~RegisterContextCorePOSIX_mips64()
@ -63,10 +59,14 @@ RegisterContextCorePOSIX_mips64::WriteFPR()
bool
RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
{
int reg_num = reg_info->byte_offset / 8;
assert(reg_num < k_num_gpr_registers_mips64);
value = m_reg[reg_num];
return true;
lldb::offset_t offset = reg_info->byte_offset;
uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
if (offset == reg_info->byte_offset + reg_info->byte_size)
{
value = v;
return true;
}
return false;
}
bool

View File

@ -10,6 +10,7 @@
#ifndef liblldb_RegisterContextCorePOSIX_mips64_H_
#define liblldb_RegisterContextCorePOSIX_mips64_H_
#include "lldb/Core/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
class RegisterContextCorePOSIX_mips64 :
@ -52,7 +53,8 @@ protected:
WriteFPR();
private:
uint64_t m_reg[40];
lldb::DataBufferSP m_gpr_buffer;
lldb_private::DataExtractor m_gpr;
};
#endif // #ifndef liblldb_RegisterContextCorePOSIX_mips64_H_