aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2024-12-04 11:30:41 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2024-12-04 15:05:58 -0500
commit489b56a30c491476e2e36e2589786247a0424f38 (patch)
tree4e479f01f8104262d6af620ac6c6550b8520159e
parentceb0ae8d4ddf7e9bc1a8399a35e49f8bc090a54d (diff)
downloadbinutils-489b56a30c491476e2e36e2589786247a0424f38.zip
binutils-489b56a30c491476e2e36e2589786247a0424f38.tar.gz
binutils-489b56a30c491476e2e36e2589786247a0424f38.tar.bz2
gdbserver: make thread_regcache_data / set_thread_regcache_data methods of thread_info
Make the field private, change the free functions to be methods. Change-Id: Ifd8ed2775dddefc73a0e00126182e1db02688af4 Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdbserver/gdbthread.h10
-rw-r--r--gdbserver/inferiors.cc12
-rw-r--r--gdbserver/inferiors.h2
-rw-r--r--gdbserver/regcache.cc14
4 files changed, 13 insertions, 25 deletions
diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index 11ab7f4..2f06be9 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -33,18 +33,23 @@ struct thread_info : public intrusive_list_node<thread_info>
~thread_info ()
{
- free_register_cache (this->regcache_data);
+ free_register_cache (m_regcache);
}
/* Return the process owning this thread. */
process_info *process () const
{ return m_process; }
+ struct regcache *regcache ()
+ { return m_regcache; }
+
+ void set_regcache (struct regcache *regcache)
+ { m_regcache = regcache; }
+
/* The id of this thread. */
ptid_t id;
void *target_data;
- struct regcache *regcache_data = nullptr;
/* The last resume GDB requested on this thread. */
enum resume_kind last_resume_kind = resume_continue;
@@ -88,6 +93,7 @@ struct thread_info : public intrusive_list_node<thread_info>
private:
process_info *m_process;
+ struct regcache *m_regcache = nullptr;
};
/* Return a pointer to the first thread, or NULL if there isn't one. */
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index e72b1c9..96fb753 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -124,18 +124,6 @@ thread_target_data (struct thread_info *thread)
return thread->target_data;
}
-struct regcache *
-thread_regcache_data (struct thread_info *thread)
-{
- return thread->regcache_data;
-}
-
-void
-set_thread_regcache_data (struct thread_info *thread, struct regcache *data)
-{
- thread->regcache_data = data;
-}
-
void
clear_inferiors (void)
{
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index 5372a3c..cdf1006 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -155,8 +155,6 @@ void switch_to_process (process_info *proc);
void clear_inferiors (void);
void *thread_target_data (struct thread_info *);
-struct regcache *thread_regcache_data (struct thread_info *);
-void set_thread_regcache_data (struct thread_info *, struct regcache *);
/* Set the inferior current working directory. If CWD is empty, unset
the directory. */
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index ef235b1..d750668 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -27,9 +27,7 @@
struct regcache *
get_thread_regcache (struct thread_info *thread, int fetch)
{
- struct regcache *regcache;
-
- regcache = thread_regcache_data (thread);
+ regcache *regcache = thread->regcache ();
/* Threads' regcaches are created lazily, because biarch targets add
the main thread/lwp before seeing it stop for the first time, and
@@ -45,7 +43,7 @@ get_thread_regcache (struct thread_info *thread, int fetch)
gdb_assert (proc->tdesc != NULL);
regcache = new_register_cache (proc->tdesc);
- set_thread_regcache_data (thread, regcache);
+ thread->set_regcache (regcache);
}
if (fetch && regcache->registers_valid == 0)
@@ -74,9 +72,7 @@ get_thread_regcache_for_ptid (ptid_t ptid)
void
regcache_invalidate_thread (struct thread_info *thread)
{
- struct regcache *regcache;
-
- regcache = thread_regcache_data (thread);
+ regcache *regcache = thread->regcache ();
if (regcache == NULL)
return;
@@ -277,13 +273,13 @@ find_regno (const struct target_desc *tdesc, const char *name)
static void
free_register_cache_thread (struct thread_info *thread)
{
- struct regcache *regcache = thread_regcache_data (thread);
+ regcache *regcache = thread->regcache ();
if (regcache != NULL)
{
regcache_invalidate_thread (thread);
free_register_cache (regcache);
- set_thread_regcache_data (thread, NULL);
+ thread->set_regcache (nullptr);
}
}