[Lldb-commits] [PATCH] D63594: [lldb] [Process/NetBSD] Simplify register buffer usage

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 20 04:20:17 PDT 2019


mgorny created this revision.
mgorny added reviewers: labath, krytarowski.

Firstly, make Get*Buffer() method abstract, rather than defining them
to return NULL.  They are going to be redefined in majority (if not all)
arches and if we ever need to skip them somewhere, it's better to
define it as llvm_unreachable().  Appropriately, remove unnecessary
NULL checks from Read*() and Write*() functions.

Secondly, remove GetFPRSize() and GetDPRSize() methods.  They are never
used, nor implemented.

Cleanup suggested by Pavel Labath in D63545 <https://reviews.llvm.org/D63545>.


https://reviews.llvm.org/D63594

Files:
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h


Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
===================================================================
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -67,9 +67,9 @@
   uint32_t NumSupportedHardwareWatchpoints() override;
 
 protected:
-  void *GetGPRBuffer() override { return &m_gpr_x86_64; }
-  void *GetFPRBuffer() override { return &m_fpr_x86_64; }
-  void *GetDBRBuffer() override { return &m_dbr_x86_64; }
+  void *GetGPRBuffer() { return &m_gpr_x86_64; }
+  void *GetFPRBuffer() { return &m_fpr_x86_64; }
+  void *GetDBRBuffer() { return &m_dbr_x86_64; }
 
 private:
   // Private member types.
Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
===================================================================
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -41,16 +41,14 @@
   virtual Status ReadDBR();
   virtual Status WriteDBR();
 
-  virtual void *GetGPRBuffer() { return nullptr; }
+  virtual void *GetGPRBuffer() = 0;
   virtual size_t GetGPRSize() {
     return GetRegisterInfoInterface().GetGPRSize();
   }
 
-  virtual void *GetFPRBuffer() { return nullptr; }
-  virtual size_t GetFPRSize() { return 0; }
+  virtual void *GetFPRBuffer() = 0;
 
-  virtual void *GetDBRBuffer() { return nullptr; }
-  virtual size_t GetDBRSize() { return 0; }
+  virtual void *GetDBRBuffer() = 0;
 
   virtual Status DoReadGPR(void *buf);
   virtual Status DoWriteGPR(void *buf);
Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
===================================================================
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -26,49 +26,31 @@
 
 Status NativeRegisterContextNetBSD::ReadGPR() {
   void *buf = GetGPRBuffer();
-  if (!buf)
-    return Status("GPR buffer is NULL");
-
   return DoReadGPR(buf);
 }
 
 Status NativeRegisterContextNetBSD::WriteGPR() {
   void *buf = GetGPRBuffer();
-  if (!buf)
-    return Status("GPR buffer is NULL");
-
   return DoWriteGPR(buf);
 }
 
 Status NativeRegisterContextNetBSD::ReadFPR() {
   void *buf = GetFPRBuffer();
-  if (!buf)
-    return Status("FPR buffer is NULL");
-
   return DoReadFPR(buf);
 }
 
 Status NativeRegisterContextNetBSD::WriteFPR() {
   void *buf = GetFPRBuffer();
-  if (!buf)
-    return Status("FPR buffer is NULL");
-
   return DoWriteFPR(buf);
 }
 
 Status NativeRegisterContextNetBSD::ReadDBR() {
   void *buf = GetDBRBuffer();
-  if (!buf)
-    return Status("DBR buffer is NULL");
-
   return DoReadDBR(buf);
 }
 
 Status NativeRegisterContextNetBSD::WriteDBR() {
   void *buf = GetDBRBuffer();
-  if (!buf)
-    return Status("DBR buffer is NULL");
-
   return DoWriteDBR(buf);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63594.205776.patch
Type: text/x-patch
Size: 2968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190620/6f2c0fd0/attachment.bin>


More information about the lldb-commits mailing list