summaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectRegister.cpp
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2023-03-13 13:22:01 +0000
committerDavid Spickett <david.spickett@linaro.org>2023-04-17 07:40:13 +0000
commit2ad771cf7bae513da6e54772e4e50e0e049af9ac (patch)
tree39525c83bc56098bc0e0d5224c854f3668bbf57c /lldb/source/Commands/CommandObjectRegister.cpp
parent2a528760bf20004066effcf8f91fedaabd261903 (diff)
[lldb] Change some pointers to refs in register printing code
No one was passing nullptr for these. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D148228
Diffstat (limited to 'lldb/source/Commands/CommandObjectRegister.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp70
1 files changed, 32 insertions, 38 deletions
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 4b0d455d90da..8784b8b9977a 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -84,42 +84,38 @@ public:
Options *GetOptions() override { return &m_option_group; }
bool DumpRegister(const ExecutionContext &exe_ctx, Stream &strm,
- RegisterContext *reg_ctx, const RegisterInfo *reg_info,
+ RegisterContext &reg_ctx, const RegisterInfo &reg_info,
bool print_flags) {
- if (reg_info) {
- RegisterValue reg_value;
-
- if (reg_ctx->ReadRegister(reg_info, reg_value)) {
- strm.Indent();
-
- bool prefix_with_altname = (bool)m_command_options.alternate_name;
- bool prefix_with_name = !prefix_with_altname;
- DumpRegisterValue(reg_value, &strm, reg_info, prefix_with_name,
- prefix_with_altname, m_format_options.GetFormat(), 8,
- exe_ctx.GetBestExecutionContextScope(), print_flags,
- exe_ctx.GetTargetSP());
- if ((reg_info->encoding == eEncodingUint) ||
- (reg_info->encoding == eEncodingSint)) {
- Process *process = exe_ctx.GetProcessPtr();
- if (process && reg_info->byte_size == process->GetAddressByteSize()) {
- addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS);
- if (reg_addr != LLDB_INVALID_ADDRESS) {
- Address so_reg_addr;
- if (exe_ctx.GetTargetRef()
- .GetSectionLoadList()
- .ResolveLoadAddress(reg_addr, so_reg_addr)) {
- strm.PutCString(" ");
- so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(),
- Address::DumpStyleResolvedDescription);
- }
- }
+ RegisterValue reg_value;
+ if (!reg_ctx.ReadRegister(&reg_info, reg_value))
+ return false;
+
+ strm.Indent();
+
+ bool prefix_with_altname = (bool)m_command_options.alternate_name;
+ bool prefix_with_name = !prefix_with_altname;
+ DumpRegisterValue(reg_value, strm, reg_info, prefix_with_name,
+ prefix_with_altname, m_format_options.GetFormat(), 8,
+ exe_ctx.GetBestExecutionContextScope(), print_flags,
+ exe_ctx.GetTargetSP());
+ if ((reg_info.encoding == eEncodingUint) ||
+ (reg_info.encoding == eEncodingSint)) {
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process && reg_info.byte_size == process->GetAddressByteSize()) {
+ addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS);
+ if (reg_addr != LLDB_INVALID_ADDRESS) {
+ Address so_reg_addr;
+ if (exe_ctx.GetTargetRef().GetSectionLoadList().ResolveLoadAddress(
+ reg_addr, so_reg_addr)) {
+ strm.PutCString(" ");
+ so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(),
+ Address::DumpStyleResolvedDescription);
}
}
- strm.EOL();
- return true;
}
}
- return false;
+ strm.EOL();
+ return true;
}
bool DumpRegisterSet(const ExecutionContext &exe_ctx, Stream &strm,
@@ -144,8 +140,8 @@ public:
if (primitive_only && reg_info && reg_info->value_regs)
continue;
- if (DumpRegister(exe_ctx, strm, reg_ctx, reg_info,
- /*print_flags=*/false))
+ if (reg_info && DumpRegister(exe_ctx, strm, *reg_ctx, *reg_info,
+ /*print_flags=*/false))
++available_count;
else
++unavailable_count;
@@ -165,7 +161,6 @@ protected:
Stream &strm = result.GetOutputStream();
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();
- const RegisterInfo *reg_info = nullptr;
if (command.GetArgumentCount() == 0) {
size_t set_idx;
@@ -218,10 +213,9 @@ protected:
auto arg_str = entry.ref();
arg_str.consume_front("$");
- reg_info = reg_ctx->GetRegisterInfoByName(arg_str);
-
- if (reg_info) {
- if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info,
+ if (const RegisterInfo *reg_info =
+ reg_ctx->GetRegisterInfoByName(arg_str)) {
+ if (!DumpRegister(m_exe_ctx, strm, *reg_ctx, *reg_info,
/*print_flags=*/true))
strm.Printf("%-12s = error: unavailable\n", reg_info->name);
} else {