From: David Spickett Date: Wed, 28 Sep 2022 13:15:44 +0000 (+0000) Subject: [LLDB] Switch to RegisterInfo& for EmulateInstruction::WriteRegister X-Git-Tag: upstream/17.0.6~30971 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81832afc04e130a386a89f57d3f4f2d7f19006f7;p=platform%2Fupstream%2Fllvm.git [LLDB] Switch to RegisterInfo& for EmulateInstruction::WriteRegister WriteRegister and WriteRegisterUnsigned were never pased nullptr, and only one of them appeared to handle it. Switch to ref to make the intent clear. Depends on D134962 Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D134963 --- diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index 444059d..68b4067 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -393,11 +393,11 @@ public: uint64_t ReadRegisterUnsigned(const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr); - bool WriteRegister(const Context &context, const RegisterInfo *ref_info, + bool WriteRegister(const Context &context, const RegisterInfo &ref_info, const RegisterValue ®_value); bool WriteRegisterUnsigned(const Context &context, - const RegisterInfo *reg_info, uint64_t reg_value); + const RegisterInfo ®_info, uint64_t reg_value); // Register kind and number variants bool ReadRegister(lldb::RegisterKind reg_kind, uint32_t reg_num, diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp index 54d4d93..73cbcc7 100644 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -112,10 +112,10 @@ uint64_t EmulateInstruction::ReadRegisterUnsigned(const RegisterInfo ®_info, } bool EmulateInstruction::WriteRegister(const Context &context, - const RegisterInfo *reg_info, + const RegisterInfo ®_info, const RegisterValue ®_value) { if (m_write_reg_callback != nullptr) - return m_write_reg_callback(this, m_baton, context, reg_info, reg_value); + return m_write_reg_callback(this, m_baton, context, ®_info, reg_value); return false; } @@ -125,7 +125,7 @@ bool EmulateInstruction::WriteRegister(const Context &context, const RegisterValue ®_value) { llvm::Optional reg_info = GetRegisterInfo(reg_kind, reg_num); if (reg_info) - return WriteRegister(context, &(*reg_info), reg_value); + return WriteRegister(context, *reg_info, reg_value); return false; } @@ -137,19 +137,17 @@ bool EmulateInstruction::WriteRegisterUnsigned(const Context &context, if (reg_info) { RegisterValue reg_value; if (reg_value.SetUInt(uint_value, reg_info->byte_size)) - return WriteRegister(context, &(*reg_info), reg_value); + return WriteRegister(context, *reg_info, reg_value); } return false; } bool EmulateInstruction::WriteRegisterUnsigned(const Context &context, - const RegisterInfo *reg_info, + const RegisterInfo ®_info, uint64_t uint_value) { - if (reg_info != nullptr) { - RegisterValue reg_value; - if (reg_value.SetUInt(uint_value, reg_info->byte_size)) - return WriteRegister(context, reg_info, reg_value); - } + RegisterValue reg_value; + if (reg_value.SetUInt(uint_value, reg_info.byte_size)) + return WriteRegister(context, reg_info, reg_value); return false; } diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index 14a30a5..a9ea14a 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -2713,7 +2713,7 @@ bool EmulateInstructionARM::EmulateVPOP(const uint32_t opcode, data = MemARead(context, addr, reg_byte_size, 0, &success); if (!success) return false; - if (!WriteRegisterUnsigned(context, &(*dwarf_reg), data)) + if (!WriteRegisterUnsigned(context, *dwarf_reg, data)) return false; addr += reg_byte_size; } diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp index e8a77a3..7a8bd02 100644 --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -876,7 +876,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) { if (!vector && is_signed && !data_Rt.SignExtend(datasize)) return false; - if (!WriteRegister(context_t, &(*reg_info_Rt), data_Rt)) + if (!WriteRegister(context_t, *reg_info_Rt, data_Rt)) return false; if (!rt_unknown) { @@ -893,7 +893,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) { if (!vector && is_signed && !data_Rt2.SignExtend(datasize)) return false; - if (!WriteRegister(context_t2, &(*reg_info_Rt2), data_Rt2)) + if (!WriteRegister(context_t2, *reg_info_Rt2, data_Rt2)) return false; } break; @@ -910,7 +910,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) { context.type = eContextAdjustStackPointer; else context.type = eContextAdjustBaseRegister; - WriteRegisterUnsigned(context, &(*reg_info_base), wb_address); + WriteRegisterUnsigned(context, *reg_info_base, wb_address); } return true; } @@ -1023,7 +1023,7 @@ bool EmulateInstructionARM64::EmulateLDRSTRImm(const uint32_t opcode) { error) == 0) return false; - if (!WriteRegister(context, &(*reg_info_Rt), data_Rt)) + if (!WriteRegister(context, *reg_info_Rt, data_Rt)) return false; break; default: @@ -1040,7 +1040,7 @@ bool EmulateInstructionARM64::EmulateLDRSTRImm(const uint32_t opcode) { context.type = eContextAdjustBaseRegister; context.SetImmediateSigned(offset); - if (!WriteRegisterUnsigned(context, &(*reg_info_base), address)) + if (!WriteRegisterUnsigned(context, *reg_info_base, address)) return false; } return true; diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp index d8a05fb..ef9d94e 100644 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -1321,7 +1321,7 @@ bool EmulateInstructionMIPS::Emulate_LW(llvm::MCInst &insn) { context.type = eContextPopRegisterOffStack; context.SetAddress(address); - return WriteRegister(context, &(*reg_info_src), data_src); + return WriteRegister(context, *reg_info_src, data_src); } return false; @@ -1661,7 +1661,7 @@ bool EmulateInstructionMIPS::Emulate_LWSP(llvm::MCInst &insn) { context.type = eContextPopRegisterOffStack; context.SetAddress(base_address); - return WriteRegister(context, &(*reg_info_src), data_src); + return WriteRegister(context, *reg_info_src, data_src); } return false; @@ -1723,7 +1723,7 @@ bool EmulateInstructionMIPS::Emulate_LWM16_32(llvm::MCInst &insn) { context.type = eContextPopRegisterOffStack; context.SetAddress(base_address + (i * 4)); - if (!WriteRegister(context, &(*reg_info_dst), data_dst)) + if (!WriteRegister(context, *reg_info_dst, data_dst)) return false; } diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp index b699ae89..497d0a9 100644 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -1217,7 +1217,7 @@ bool EmulateInstructionMIPS64::Emulate_LD(llvm::MCInst &insn) { Context context; context.type = eContextRegisterLoad; - return WriteRegister(context, &(*reg_info_src), data_src); + return WriteRegister(context, *reg_info_src, data_src); } return false;