[PATCH v4 32/44] gdbserver: add a pointer to the owner thread in regcache

Markus Metzger <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
From: Tankut Baris Aktemur <[email protected]>

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 7e1fd9a82e0..1084e61d62a 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -44,6 +44,7 @@ get_thread_regcache (thread_info *thread, bool fetch)
 
       thread->set_regcache (std::make_unique<struct regcache> (proc->tdesc));
       regcache = thread->regcache ();
+      regcache->thread = thread;
     }
 
   if (fetch && !regcache->registers_fetched)
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 2f0fac6e7d0..abe19f9ec41 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -34,6 +34,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 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,
-- 
2.43.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.