From: Simon Marchi Date: Wed, 4 Dec 2024 16:30:41 +0000 (-0500) Subject: gdbserver: make thread_regcache_data / set_thread_regcache_data methods of thread_info X-Git-Tag: gdb-16-branchpoint~187 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=489b56a30c491476e2e36e2589786247a0424f38;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h index 11ab7f49adb..2f06be9101d 100644 --- a/gdbserver/gdbthread.h +++ b/gdbserver/gdbthread.h @@ -33,18 +33,23 @@ struct thread_info : public intrusive_list_node ~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 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 e72b1c9bfc2..96fb7530ebc 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 5372a3cd5b7..cdf1006a091 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 ef235b18c41..d750668b192 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); } }