[17/26] gdbserver: rename regcache's registers_valid to registers_fetched

Message ID 7296899ef77a86051c398fc1c20338f2937386eb.1677582745.git.tankut.baris.aktemur@intel.com
State New
Headers
Series gdbserver: refactor regcache and allow gradually populating |

Commit Message

Aktemur, Tankut Baris Feb. 28, 2023, 11:28 a.m. UTC
  The registers_valid field of the regcache struct is used for tracking
whether we have attempted to fetch all the registers from the target.
Its name does not reflect this well, I think.  It falsely gives the
impression that all the registers are valid.  This may conflict an
individual register status, which could be REG_UNAVAILABLE.  To better
reflect the purpose, rename the field to "registers_fetched".
---
 gdbserver/regcache.cc | 12 ++++++------
 gdbserver/regcache.h  | 13 +++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)
  

Comments

Simon Marchi Dec. 22, 2023, 3:23 a.m. UTC | #1
On 2023-02-28 06:28, Tankut Baris Aktemur via Gdb-patches wrote:
> The registers_valid field of the regcache struct is used for tracking
> whether we have attempted to fetch all the registers from the target.
> Its name does not reflect this well, I think.  It falsely gives the
> impression that all the registers are valid.  This may conflict an
> individual register status, which could be REG_UNAVAILABLE.  To better
> reflect the purpose, rename the field to "registers_fetched".

I agree that the term valid is used for both things here.  I'm fine with
the change.  Again, I think that can be pushed right away.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 4b56750d06a..0e21c1aa7d1 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -57,7 +57,7 @@  get_thread_regcache (struct thread_info *thread, bool fetch)
 void
 regcache::fetch ()
 {
-  if (!registers_valid)
+  if (!registers_fetched)
     {
       scoped_restore_current_thread restore_thread;
       gdb_assert (this->thread != nullptr);
@@ -66,7 +66,7 @@  regcache::fetch ()
       /* Invalidate all registers, to prevent stale left-overs.  */
       memset (register_status, REG_UNAVAILABLE, tdesc->reg_defs.size ());
       fetch_inferior_registers (this, -1);
-      registers_valid = true;
+      registers_fetched = true;
     }
 }
 
@@ -92,7 +92,7 @@  regcache_invalidate_thread (struct thread_info *thread)
 void
 regcache::invalidate ()
 {
-  if (registers_valid)
+  if (registers_fetched)
     {
       scoped_restore_current_thread restore_thread;
       gdb_assert (this->thread != nullptr);
@@ -128,7 +128,7 @@  regcache_invalidate (void)
 void
 regcache::discard ()
 {
-  registers_valid = false;
+  registers_fetched = false;
 }
 
 void
@@ -164,7 +164,7 @@  regcache::initialize (const target_desc *tdesc,
 #endif
     }
 
-  this->registers_valid = false;
+  this->registers_fetched = false;
 }
 
 #ifndef IN_PROCESS_AGENT
@@ -197,7 +197,7 @@  regcache::copy_from (regcache *src)
     memcpy (this->register_status, src->register_status,
 	    src->tdesc->reg_defs.size ());
 #endif
-  this->registers_valid = src->registers_valid;
+  this->registers_fetched = src->registers_fetched;
 }
 
 /* Return a reference to the description of register N.  */
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index f155ac631eb..3fcd4643a42 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -36,12 +36,13 @@  struct regcache : public reg_buffer_common
   /* Back-link to the thread to which this regcache belongs.  */
   thread_info *thread = nullptr;
 
-  /* Whether the REGISTERS buffer's contents are valid.  If false, we
-     haven't fetched the registers from the target yet.  Not that this
-     register cache is _not_ pass-through, unlike GDB's.  Note that
-     "valid" here is unrelated to whether the registers are available
-     in a traceframe.  For that, check REGISTER_STATUS below.  */
-  bool registers_valid = false;
+  /* Whether the REGISTERS buffer's contents are fetched.  If false,
+     we haven't fetched the registers from the target yet.  Note that
+     this register cache is _not_ pass-through, unlike GDB's.  Also,
+     note that "fetched" here is unrelated to whether the registers
+     are available in a traceframe.  For that, check REGISTER_STATUS
+     below.  */
+  bool registers_fetched = false;
   bool registers_owned = false;
   unsigned char *registers = nullptr;
 #ifndef IN_PROCESS_AGENT