[LLDB] Change pointer to ref in EmulateInstruction::ReadRegister methods

ReadRegister and ReadRegisterAsUnsigned are always passed valid pointers,
so the parameter should be a ref to make the intent clear.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D134962
This commit is contained in:
David Spickett 2022-09-28 12:45:18 +00:00
parent 0648e42e52
commit 2a627e2ad1
6 changed files with 14 additions and 14 deletions

View File

@ -388,9 +388,9 @@ public:
uint32_t reg_num, std::string &reg_name);
// RegisterInfo variants
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value);
bool ReadRegister(const RegisterInfo &reg_info, RegisterValue &reg_value);
uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info,
uint64_t ReadRegisterUnsigned(const RegisterInfo &reg_info,
uint64_t fail_value, bool *success_ptr);
bool WriteRegister(const Context &context, const RegisterInfo *ref_info,

View File

@ -72,10 +72,10 @@ EmulateInstruction::FindPlugin(const ArchSpec &arch,
EmulateInstruction::EmulateInstruction(const ArchSpec &arch) : m_arch(arch) {}
bool EmulateInstruction::ReadRegister(const RegisterInfo *reg_info,
bool EmulateInstruction::ReadRegister(const RegisterInfo &reg_info,
RegisterValue &reg_value) {
if (m_read_reg_callback != nullptr)
return m_read_reg_callback(this, m_baton, reg_info, reg_value);
return m_read_reg_callback(this, m_baton, &reg_info, reg_value);
return false;
}
@ -84,7 +84,7 @@ bool EmulateInstruction::ReadRegister(lldb::RegisterKind reg_kind,
RegisterValue &reg_value) {
llvm::Optional<RegisterInfo> reg_info = GetRegisterInfo(reg_kind, reg_num);
if (reg_info)
return ReadRegister(&(*reg_info), reg_value);
return ReadRegister(*reg_info, reg_value);
return false;
}
@ -100,7 +100,7 @@ uint64_t EmulateInstruction::ReadRegisterUnsigned(lldb::RegisterKind reg_kind,
return fail_value;
}
uint64_t EmulateInstruction::ReadRegisterUnsigned(const RegisterInfo *reg_info,
uint64_t EmulateInstruction::ReadRegisterUnsigned(const RegisterInfo &reg_info,
uint64_t fail_value,
bool *success_ptr) {
RegisterValue reg_value;

View File

@ -2620,7 +2620,7 @@ bool EmulateInstructionARM::EmulateVPUSH(const uint32_t opcode,
GetRegisterInfo(eRegisterKindDWARF, start_reg + d + i);
context.SetRegisterToRegisterPlusOffset(*dwarf_reg, *sp_reg, addr - sp);
// uint64_t to accommodate 64-bit registers.
uint64_t reg_value = ReadRegisterUnsigned(&(*dwarf_reg), 0, &success);
uint64_t reg_value = ReadRegisterUnsigned(*dwarf_reg, 0, &success);
if (!success)
return false;
if (!MemAWrite(context, addr, reg_value, reg_byte_size))

View File

@ -824,7 +824,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
context_t2.SetRegisterToRegisterPlusOffset(*reg_info_Rt2, *reg_info_base,
size);
if (!ReadRegister(&(*reg_info_Rt), data_Rt))
if (!ReadRegister(*reg_info_Rt, data_Rt))
return false;
if (data_Rt.GetAsMemoryData(&(*reg_info_Rt), buffer, reg_info_Rt->byte_size,
@ -834,7 +834,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
if (!WriteMemory(context_t, address + 0, buffer, reg_info_Rt->byte_size))
return false;
if (!ReadRegister(&(*reg_info_Rt2), data_Rt2))
if (!ReadRegister(*reg_info_Rt2, data_Rt2))
return false;
if (data_Rt2.GetAsMemoryData(&(*reg_info_Rt2), buffer,
@ -995,7 +995,7 @@ bool EmulateInstructionARM64::EmulateLDRSTRImm(const uint32_t opcode) {
context.SetRegisterToRegisterPlusOffset(*reg_info_Rt, *reg_info_base,
postindex ? 0 : offset);
if (!ReadRegister(&(*reg_info_Rt), data_Rt))
if (!ReadRegister(*reg_info_Rt, data_Rt))
return false;
if (data_Rt.GetAsMemoryData(&(*reg_info_Rt), buffer, reg_info_Rt->byte_size,

View File

@ -1266,7 +1266,7 @@ bool EmulateInstructionMIPS::Emulate_SW(llvm::MCInst &insn) {
uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
Status error;
if (!ReadRegister(&(*reg_info_base), data_src))
if (!ReadRegister(*reg_info_base, data_src))
return false;
if (data_src.GetAsMemoryData(&(*reg_info_src), buffer,
@ -1526,7 +1526,7 @@ bool EmulateInstructionMIPS::Emulate_SWSP(llvm::MCInst &insn) {
uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
Status error;
if (!ReadRegister(&(*reg_info_base), data_src))
if (!ReadRegister(*reg_info_base, data_src))
return false;
if (data_src.GetAsMemoryData(&reg_info_src, buffer, reg_info_src.byte_size,
@ -1608,7 +1608,7 @@ bool EmulateInstructionMIPS::Emulate_SWM16_32(llvm::MCInst &insn) {
uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
Status error;
if (!ReadRegister(&(*reg_info_base), data_src))
if (!ReadRegister(*reg_info_base, data_src))
return false;
if (data_src.GetAsMemoryData(&(*reg_info_src), buffer,

View File

@ -1160,7 +1160,7 @@ bool EmulateInstructionMIPS64::Emulate_SD(llvm::MCInst &insn) {
uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
Status error;
if (!ReadRegister(&(*reg_info_base), data_src))
if (!ReadRegister(*reg_info_base, data_src))
return false;
if (data_src.GetAsMemoryData(&(*reg_info_src), buffer,