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

Tankut Baris Aktemur via Gdb-patches
2023-02-28T11:30:00Z

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(+)

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
--
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva