summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
diff options
context:
space:
mode:
authorMohit K. Bhakkad <mohit.bhakkad@gmail.com>2015-03-31 12:01:27 +0000
committerMohit K. Bhakkad <mohit.bhakkad@gmail.com>2015-03-31 12:01:27 +0000
commit09ba1a323e583e84365f2425685b804b453efb10 (patch)
tree354ce4a9866a4c8724a77d5a70ded035049190c7 /lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
parent7aed6890fdf81853af7477cea20b63da85754e2c (diff)
downloadbcm5719-llvm-09ba1a323e583e84365f2425685b804b453efb10.tar.gz
bcm5719-llvm-09ba1a323e583e84365f2425685b804b453efb10.zip
[LLDB][MIPS] Read/Write register for MIPS64
Patch by Sagar Thakur Reviewers: clayborg, tberghammer. Subscribers: jaydeep, bhushan, mohit.bhakkad, llvm-commits. Differential Revision: http://reviews.llvm.org/D8695 llvm-svn: 233685
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp101
1 files changed, 95 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
index 0e4da3705ac..43986fcd53e 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
@@ -123,20 +123,109 @@ NativeRegisterContextLinux_mips64::GetRegisterSet (uint32_t set_index) const
return nullptr;
}
-Error
+lldb_private::Error
+NativeRegisterContextLinux_mips64::ReadRegisterRaw (uint32_t reg_index, RegisterValue &reg_value)
+{
+ Error error;
+
+ const RegisterInfo *const reg_info = GetRegisterInfoAtIndex (reg_index);
+ if (!reg_info)
+ {
+ error.SetErrorStringWithFormat ("register %" PRIu32 " not found", reg_index);
+ return error;
+ }
+
+ NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
+ if (!process_sp)
+ {
+ error.SetErrorString ("NativeProcessProtocol is NULL");
+ return error;
+ }
+
+ NativeProcessLinux *const process_p = reinterpret_cast<NativeProcessLinux*> (process_sp.get ());
+ return process_p->ReadRegisterValue(m_thread.GetID(),
+ reg_info->byte_offset,
+ reg_info->name,
+ reg_info->byte_size,
+ reg_value);
+}
+
+lldb_private::Error
NativeRegisterContextLinux_mips64::ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value)
{
Error error;
- error.SetErrorString ("MIPS TODO: NativeRegisterContextLinux_mips64::ReadRegister not implemented");
+
+ if (!reg_info)
+ {
+ error.SetErrorString ("reg_info NULL");
+ return error;
+ }
+
+ const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ if (reg == LLDB_INVALID_REGNUM)
+ {
+ // This is likely an internal register for lldb use only and should not be directly queried.
+ error.SetErrorStringWithFormat ("register \"%s\" is an internal-only lldb register, cannot read directly", reg_info->name);
+ return error;
+ }
+
+ error = ReadRegisterRaw(reg, reg_value);
+
+ if (error.Success ())
+ {
+ // If our return byte size was greater than the return value reg size, then
+ // use the type specified by reg_info rather than the uint64_t default
+ if (reg_value.GetByteSize() > reg_info->byte_size)
+ reg_value.SetType(reg_info);
+ }
+
return error;
}
-Error
-NativeRegisterContextLinux_mips64::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
+lldb_private::Error
+NativeRegisterContextLinux_mips64::WriteRegister(const uint32_t reg,
+ const RegisterValue &value)
{
Error error;
- error.SetErrorString ("MIPS TODO: NativeRegisterContextLinux_mips64::WriteRegister not implemented");
- return error;
+
+ uint32_t reg_to_write = reg;
+ RegisterValue value_to_write = value;
+
+ NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
+ if (!process_sp)
+ {
+ error.SetErrorString ("NativeProcessProtocol is NULL");
+ return error;
+ }
+
+ const RegisterInfo *const register_to_write_info_p = GetRegisterInfoAtIndex (reg_to_write);
+ assert (register_to_write_info_p && "register to write does not have valid RegisterInfo");
+ if (!register_to_write_info_p)
+ {
+ error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s failed to get RegisterInfo for write register index %" PRIu32, __FUNCTION__, reg_to_write);
+ return error;
+ }
+
+ NativeProcessLinux *const process_p = reinterpret_cast<NativeProcessLinux*> (process_sp.get ());
+ return process_p->WriteRegisterValue(m_thread.GetID(),
+ register_to_write_info_p->byte_offset,
+ register_to_write_info_p->name,
+ value_to_write);
+}
+
+
+
+lldb_private::Error
+NativeRegisterContextLinux_mips64::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
+{
+ assert (reg_info && "reg_info is null");
+
+ const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
+
+ if (reg_index == LLDB_INVALID_REGNUM)
+ return Error ("no lldb regnum for %s", reg_info && reg_info->name ? reg_info->name : "<unknown register>");
+
+ return WriteRegister(reg_index, reg_value);
}
Error
OpenPOWER on IntegriCloud