[3/4] gdbserver: make thread_regcache_data / set_thread_regcache_data methods of thread_info
Checks
Commit Message
From: Simon Marchi <simon.marchi@polymtl.ca>
Make the field private, change the free functions to be methods.
Change-Id: Ifd8ed2775dddefc73a0e00126182e1db02688af4
---
gdbserver/gdbthread.h | 10 ++++++++--
gdbserver/inferiors.cc | 12 ------------
gdbserver/inferiors.h | 2 --
gdbserver/regcache.cc | 14 +++++---------
4 files changed, 13 insertions(+), 25 deletions(-)
@@ -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. */
@@ -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)
{
@@ -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. */
@@ -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);
}
}