DavidSpickett created this revision.
Herald added subscribers: atanasyan, jrtc27.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134962

Files:
  lldb/include/lldb/Core/EmulateInstruction.h
  lldb/source/Core/EmulateInstruction.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

Index: lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
===================================================================
--- lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -1160,7 +1160,7 @@
     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,
Index: lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
===================================================================
--- lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -1266,7 +1266,7 @@
     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 @@
     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 @@
     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,
Index: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
===================================================================
--- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -824,7 +824,7 @@
     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 @@
     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 @@
     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,
Index: lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
===================================================================
--- lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -2620,7 +2620,7 @@
           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))
Index: lldb/source/Core/EmulateInstruction.cpp
===================================================================
--- lldb/source/Core/EmulateInstruction.cpp
+++ lldb/source/Core/EmulateInstruction.cpp
@@ -72,10 +72,10 @@
 
 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 @@
                                       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 @@
   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;
Index: lldb/include/lldb/Core/EmulateInstruction.h
===================================================================
--- lldb/include/lldb/Core/EmulateInstruction.h
+++ lldb/include/lldb/Core/EmulateInstruction.h
@@ -388,9 +388,9 @@
                                        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,
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to