aboutsummaryrefslogtreecommitdiff
path: root/gdb/sol-thread.c
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/sol-thread.c
parent4a2530397b87c66bd45b21cf20e2cc12bf26879f (diff)
downloadgdb-7438771288f1acd5ab25277188a75ce9e48e256c.zip
gdb-7438771288f1acd5ab25277188a75ce9e48e256c.tar.gz
gdb-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/sol-thread.c')
-rw-r--r--gdb/sol-thread.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 537acdb..61331f9 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -845,9 +845,8 @@ ps_err_e
ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
{
ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
- struct regcache *regcache
- = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, current_inferior ()->arch ());
+ regcache *regcache = get_thread_arch_regcache (current_inferior (), ptid,
+ current_inferior ()->arch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
@@ -862,9 +861,8 @@ ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid,
const prgregset_t gregset)
{
ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
- struct regcache *regcache
- = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, current_inferior ()->arch ());
+ regcache *regcache = get_thread_arch_regcache (current_inferior (), ptid,
+ current_inferior ()->arch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
@@ -915,9 +913,8 @@ ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
prfpregset_t *fpregset)
{
ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
- struct regcache *regcache
- = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, current_inferior ()->arch ());
+ regcache *regcache = get_thread_arch_regcache (current_inferior (), ptid,
+ current_inferior ()->arch ());
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
@@ -932,9 +929,8 @@ ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
const prfpregset_t * fpregset)
{
ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
- struct regcache *regcache
- = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, current_inferior ()->arch ());
+ regcache *regcache = get_thread_arch_regcache (current_inferior (), ptid,
+ current_inferior ()->arch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);