diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -393,11 +393,11 @@ 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 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -112,10 +112,10 @@ } 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 @@ 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 @@ 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 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -2713,7 +2713,7 @@ 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 --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -876,7 +876,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -1321,7 +1321,7 @@ 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 @@ 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 @@ 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 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -1217,7 +1217,7 @@ Context context; context.type = eContextRegisterLoad; - return WriteRegister(context, &(*reg_info_src), data_src); + return WriteRegister(context, *reg_info_src, data_src); } return false;