[05/26] gdbserver: add a pointer to the owner thread in regcache

Message ID 5e9fc384d9456c05d12037a4f2f1999b675c19f5.1677582744.git.tankut.baris.aktemur@intel.com
State New
Headers
Series gdbserver: refactor regcache and allow gradually populating |

Commit Message

Tankut Baris Aktemur Feb. 28, 2023, 11:28 a.m. UTC
  Add a back-link in regcache to the thread that owns the regcache.
This will help us in future patches to refer to the right thread
object without having to rely on the global current_thread pointer.
---
 gdbserver/regcache.cc | 1 +
 gdbserver/regcache.h  | 3 +++
 2 files changed, 4 insertions(+)
  

Patch

diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 21c2207822c..2a8dc17ed6a 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -45,6 +45,7 @@  get_thread_regcache (struct thread_info *thread, bool fetch)
 
       regcache = new struct regcache (proc->tdesc);
       set_thread_regcache_data (thread, regcache);
+      regcache->thread = thread;
     }
 
   if (fetch && regcache->registers_valid == 0)
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 5b2066ced4d..053ed08b20f 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -33,6 +33,9 @@  struct regcache : public reg_buffer_common
   /* The regcache's target description.  */
   const struct target_desc *tdesc = nullptr;
 
+  /* 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