summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectRegister.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-05-09 20:18:18 +0000
committerGreg Clayton <gclayton@apple.com>2011-05-09 20:18:18 +0000
commit7349bd90786bb6f738d775a5044181f6111eb614 (patch)
treecac83b5e20bfe6cf8053948566c567fd9daf5d69 /lldb/source/Commands/CommandObjectRegister.cpp
parent112a2de78cfa8a32965f1c87243fe601941809f0 (diff)
downloadbcm5719-llvm-7349bd90786bb6f738d775a5044181f6111eb614.tar.gz
bcm5719-llvm-7349bd90786bb6f738d775a5044181f6111eb614.zip
While implementing unwind information using UnwindAssemblyInstEmulation I ran
into some cleanup I have been wanting to do when reading/writing registers. Previously all RegisterContext subclasses would need to implement: virtual bool ReadRegisterBytes (uint32_t reg, DataExtractor &data); virtual bool WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset = 0); There is now a new class specifically designed to hold register values: lldb_private::RegisterValue The new register context calls that subclasses must implement are: virtual bool ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) = 0; virtual bool WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) = 0; The RegisterValue class must be big enough to handle any register value. The class contains an enumeration for the value type, and then a union for the data value. Any integer/float values are stored directly in an appropriate host integer/float. Anything bigger is stored in a byte buffer that has a length and byte order. The RegisterValue class also knows how to copy register value bytes into in a buffer with a specified byte order which can be used to write the register value down into memory, and this does the right thing when not all bytes from the register values are needed (getting a uint8 from a uint32 register value..). All RegiterContext and other sources have been switched over to using the new regiter value class. llvm-svn: 131096
Diffstat (limited to 'lldb/source/Commands/CommandObjectRegister.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 45444065ac6..e1377bbe55e 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/Args.h"
@@ -77,26 +78,24 @@ public:
{
if (reg_info)
{
- uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ RegisterValue reg_value;
- DataExtractor reg_data;
-
- if (reg_ctx->ReadRegisterBytes(reg, reg_data))
+ if (reg_ctx->ReadRegister (reg_info, reg_value))
{
strm.Indent ();
- strm.Printf ("%-12s = ", reg_info ? reg_info->name : "<INVALID REGINFO>");
Format format;
if (m_options.format == eFormatDefault)
format = reg_info->format;
else
format = m_options.format;
- reg_data.Dump(&strm, 0, format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ bool prefix_with_name = true;
+ reg_value.Dump(&strm, reg_info, prefix_with_name, m_options.format);
if (((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) &&
(reg_info->byte_size == reg_ctx->GetThread().GetProcess().GetAddressByteSize()))
{
- addr_t reg_addr = reg_ctx->ReadRegisterAsUnsigned (reg, 0);
- if (reg_addr)
+ addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS);
+ if (reg_addr != LLDB_INVALID_ADDRESS)
{
Address so_reg_addr;
if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr))
@@ -393,11 +392,12 @@ public:
if (reg_info)
{
- Scalar scalar;
- Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size));
+ RegisterValue reg_value;
+
+ Error error (reg_value.SetValueFromCString (reg_info, value_str));
if (error.Success())
{
- if (reg_ctx->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar))
+ if (reg_ctx->WriteRegister (reg_info, reg_value))
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
return true;
OpenPOWER on IntegriCloud