aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-11-17 19:55:58 +0000
committerSimon Marchi <simon.marchi@efficios.com>2023-11-17 20:01:35 +0000
commit7438771288f1acd5ab25277188a75ce9e48e256c (patch)
tree7f261a382ee420c2a26d6ed2f0f9305fb5285359 /gdb/regcache.h
parent4a2530397b87c66bd45b21cf20e2cc12bf26879f (diff)
downloadbinutils-7438771288f1acd5ab25277188a75ce9e48e256c.zip
binutils-7438771288f1acd5ab25277188a75ce9e48e256c.tar.gz
binutils-7438771288f1acd5ab25277188a75ce9e48e256c.tar.bz2
gdb: remove regcache's address space
While looking at the regcache code, I noticed that the address space (passed to regcache when constructing it, and available through regcache::aspace) wasn't relevant for the regcache itself. Callers of regcache::aspace use that method because it appears to be a convenient way of getting the address space for a thread, if you already have the regcache. But there is always another way to get the address space, as the callers pretty much always know which thread they are dealing with. The regcache code itself doesn't use the address space. This patch removes anything related to address_space from the regcache code, and updates callers to get it from the thread in context. This removes a bit of unnecessary complexity from the regcache code. The current get_thread_arch_regcache function gets an address_space for the given thread using the target_thread_address_space function (which calls the target_ops::thread_address_space method). This suggest that there might have been the intention of supporting per-thread address spaces. But digging through the history, I did not find any such case. Maybe this method was just added because we needed a way to get an address space from a ptid (because constructing a regcache required an address space), and this seemed like the right way to do it, I don't know. The only implementations of thread_address_space and process_stratum_target::thread_address_space and linux_nat_target::thread_address_space, which essentially just return the inferior's address space. And thread_address_space is only used in the current get_thread_arch_regcache, which gets removed. So, I think that the thread_address_space target method can be removed, and we can assume that it's fine to use the inferior's address space everywhere. Callers of regcache::aspace are updated to get the address space from the relevant inferior, either using some context they already know about, or in last resort using the current global context. So, to summarize: - remove everything in regcache related to address spaces - in particular, remove get_thread_arch_regcache, and rename get_thread_arch_aspace_regcache to get_thread_arch_regcache - remove target_ops::thread_address_space, and target_thread_address_space - adjust all users of regcache::aspace to get the address space another way Change-Id: I04fd41b22c83fe486522af7851c75bcfb31c88c7
Diffstat (limited to 'gdb/regcache.h')
-rw-r--r--gdb/regcache.h27
1 files changed, 5 insertions, 22 deletions
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 57ddac4..f73f08a 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -26,7 +26,6 @@
struct regcache;
struct regset;
struct gdbarch;
-struct address_space;
class thread_info;
struct process_stratum_target;
struct inferior;
@@ -38,11 +37,8 @@ extern struct regcache *get_thread_regcache (process_stratum_target *target,
/* Get the regcache of THREAD. */
extern struct regcache *get_thread_regcache (thread_info *thread);
-extern struct regcache *get_thread_arch_regcache
- (process_stratum_target *targ, ptid_t, struct gdbarch *);
-extern struct regcache *get_thread_arch_aspace_regcache
- (inferior *inf_for_target_calls, ptid_t,
- struct gdbarch *, struct address_space *);
+extern regcache *get_thread_arch_regcache (inferior *inf_for_target_calls,
+ ptid_t ptid, gdbarch *arch);
extern enum register_status
regcache_raw_read_signed (struct regcache *regcache,
@@ -339,12 +335,6 @@ class regcache : public detached_regcache
public:
DISABLE_COPY_AND_ASSIGN (regcache);
- /* Return REGCACHE's address space. */
- const address_space *aspace () const
- {
- return m_aspace;
- }
-
/* Restore 'this' regcache. The set of registers restored into
the regcache determined by the restore_reggroup.
Writes to regcache will go through to the target. SRC is a
@@ -422,8 +412,7 @@ public:
void debug_print_register (const char *func, int regno);
protected:
- regcache (inferior *inf_for_target_calls, gdbarch *gdbarch,
- const address_space *aspace);
+ regcache (inferior *inf_for_target_calls, gdbarch *gdbarch);
private:
@@ -445,10 +434,6 @@ private:
enum register_status write_part (int regnum, int offset, int len,
const gdb_byte *in, bool is_raw);
- /* The address space of this register cache (for registers where it
- makes sense, like PC or SP). */
- const address_space * const m_aspace;
-
/* The inferior to switch to, to make target calls.
This may not be the inferior of thread M_PTID. For instance, this
@@ -462,10 +447,8 @@ private:
it connected to? */
ptid_t m_ptid;
- friend struct regcache *
- get_thread_arch_aspace_regcache (inferior *inf_for_target_calls, ptid_t ptid,
- struct gdbarch *gdbarch,
- struct address_space *aspace);
+ friend regcache *get_thread_arch_regcache (inferior *inf_for_target_calls,
+ ptid_t ptid, gdbarch *gdbarch);
};
using regcache_up = std::unique_ptr<regcache>;