From 2a627e2ad1d80b660fcb02dde85b346f61193ade Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 28 Sep 2022 12:45:18 +0000 Subject: [PATCH] [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 --- lldb/include/lldb/Core/EmulateInstruction.h | 4 ++-- lldb/source/Core/EmulateInstruction.cpp | 8 ++++---- lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp | 2 +- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | 6 +++--- lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp | 6 +++--- .../Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index dc15fe2..444059d 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -388,9 +388,9 @@ public: uint32_t reg_num, std::string ®_name); // RegisterInfo variants - bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value); + bool ReadRegister(const RegisterInfo ®_info, RegisterValue ®_value); - uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info, + uint64_t ReadRegisterUnsigned(const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr); bool WriteRegister(const Context &context, const RegisterInfo *ref_info, diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp index b497b02..54d4d93 100644 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -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 ®_info, RegisterValue ®_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, ®_info, reg_value); return false; } @@ -84,7 +84,7 @@ bool EmulateInstruction::ReadRegister(lldb::RegisterKind reg_kind, RegisterValue ®_value) { llvm::Optional 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 ®_info, uint64_t fail_value, bool *success_ptr) { RegisterValue reg_value; diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index d71fff3..14a30a5 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -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)) diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp index 92af4da..e8a77a3 100644 --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -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, diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp index 060b631..d8a05fb 100644 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -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(®_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, diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp index 14041c7..b699ae89 100644 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -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, -- 2.7.4