diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-11-17 19:55:58 +0000 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-11-17 20:01:35 +0000 |
commit | 7438771288f1acd5ab25277188a75ce9e48e256c (patch) | |
tree | 7f261a382ee420c2a26d6ed2f0f9305fb5285359 /gdb/infrun.c | |
parent | 4a2530397b87c66bd45b21cf20e2cc12bf26879f (diff) | |
download | gdb-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/infrun.c')
-rw-r--r-- | gdb/infrun.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index 62b306f..785a4e1 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2079,10 +2079,8 @@ displaced_step_finish (thread_info *event_thread, point. */ struct regcache *child_regcache - = get_thread_arch_aspace_regcache (parent_inf, - event_status.child_ptid (), - gdbarch, - parent_inf->aspace); + = get_thread_arch_regcache (parent_inf, event_status.child_ptid (), + gdbarch); /* Read PC value of parent. */ CORE_ADDR parent_pc = regcache_read_pc (regcache); @@ -2626,7 +2624,6 @@ resume_1 (enum gdb_signal sig) struct regcache *regcache = get_current_regcache (); struct gdbarch *gdbarch = regcache->arch (); struct thread_info *tp = inferior_thread (); - const address_space *aspace = regcache->aspace (); ptid_t resume_ptid; /* This represents the user's step vs continue request. When deciding whether "set scheduler-locking step" applies, it's the @@ -2705,6 +2702,8 @@ resume_1 (enum gdb_signal sig) inferior_ptid.to_string ().c_str (), paddress (gdbarch, pc)); + const address_space *aspace = tp->inf->aspace; + /* Normally, by the time we reach `resume', the breakpoints are either removed or inserted, as appropriate. The exception is if we're sitting at a permanent breakpoint; we need to step over it, but permanent @@ -2819,8 +2818,8 @@ resume_1 (enum gdb_signal sig) if (target_is_non_stop_p ()) stop_all_threads ("displaced stepping falling back on inline stepping"); - set_step_over_info (regcache->aspace (), - regcache_read_pc (regcache), 0, tp->global_num); + set_step_over_info (aspace, regcache_read_pc (regcache), 0, + tp->global_num); step = maybe_software_singlestep (gdbarch); @@ -3147,7 +3146,7 @@ thread_still_needs_step_over_bp (struct thread_info *tp) { struct regcache *regcache = get_thread_regcache (tp); - if (breakpoint_here_p (regcache->aspace (), + if (breakpoint_here_p (tp->inf->aspace, regcache_read_pc (regcache)) == ordinary_breakpoint_here) return true; @@ -3590,7 +3589,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) regcache = get_current_regcache (); gdbarch = regcache->arch (); - const address_space *aspace = regcache->aspace (); pc = regcache_read_pc_protected (regcache); @@ -3612,6 +3610,8 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) if (addr == (CORE_ADDR) -1) { + const address_space *aspace = cur_thr->inf->aspace; + if (cur_thr->stop_pc_p () && pc == cur_thr->stop_pc () && breakpoint_here_p (aspace, pc) == ordinary_breakpoint_here @@ -4040,7 +4040,7 @@ do_target_wait_1 (inferior *inf, ptid_t ptid, paddress (gdbarch, pc)); discard = 1; } - else if (!breakpoint_inserted_here_p (regcache->aspace (), pc)) + else if (!breakpoint_inserted_here_p (tp->inf->aspace, pc)) { infrun_debug_printf ("previous breakpoint of %s, at %s gone", tp->ptid.to_string ().c_str (), @@ -4937,7 +4937,7 @@ adjust_pc_after_break (struct thread_info *thread, if (decr_pc == 0) return; - const address_space *aspace = regcache->aspace (); + const address_space *aspace = thread->inf->aspace; /* Find the location where (if we've hit a breakpoint) the breakpoint would be. */ @@ -5089,7 +5089,7 @@ handle_syscall_event (struct execution_control_state *ecs) infrun_debug_printf ("syscall number=%d", syscall_number); ecs->event_thread->control.stop_bpstat - = bpstat_stop_status_nowatch (regcache->aspace (), + = bpstat_stop_status_nowatch (ecs->event_thread->inf->aspace, ecs->event_thread->stop_pc (), ecs->event_thread, ecs->ws); @@ -5288,7 +5288,7 @@ save_waitstatus (struct thread_info *tp, const target_waitstatus &ws) && ws.sig () == GDB_SIGNAL_TRAP) { struct regcache *regcache = get_thread_regcache (tp); - const address_space *aspace = regcache->aspace (); + const address_space *aspace = tp->inf->aspace; CORE_ADDR pc = regcache_read_pc (regcache); adjust_pc_after_break (tp, tp->pending_waitstatus ()); @@ -6085,7 +6085,7 @@ handle_inferior_event (struct execution_control_state *ecs) { struct regcache *regcache = get_thread_regcache (ecs->event_thread); - if (breakpoint_inserted_here_p (regcache->aspace (), + if (breakpoint_inserted_here_p (ecs->event_thread->inf->aspace, regcache_read_pc (regcache))) { infrun_debug_printf ("Treating signal as SIGTRAP"); @@ -6118,7 +6118,7 @@ handle_inferior_event (struct execution_control_state *ecs) ecs->event_thread->set_stop_pc (regcache_read_pc (regcache)); ecs->event_thread->control.stop_bpstat - = bpstat_stop_status_nowatch (regcache->aspace (), + = bpstat_stop_status_nowatch (ecs->event_thread->inf->aspace, ecs->event_thread->stop_pc (), ecs->event_thread, ecs->ws); @@ -6312,7 +6312,7 @@ handle_inferior_event (struct execution_control_state *ecs) (regcache_read_pc (get_thread_regcache (ecs->event_thread))); ecs->event_thread->control.stop_bpstat - = bpstat_stop_status_nowatch (get_current_regcache ()->aspace (), + = bpstat_stop_status_nowatch (ecs->event_thread->inf->aspace, ecs->event_thread->stop_pc (), ecs->event_thread, ecs->ws); @@ -6458,7 +6458,7 @@ handle_inferior_event (struct execution_control_state *ecs) (regcache_read_pc (get_thread_regcache (ecs->event_thread))); ecs->event_thread->control.stop_bpstat - = bpstat_stop_status_nowatch (get_current_regcache ()->aspace (), + = bpstat_stop_status_nowatch (ecs->event_thread->inf->aspace, ecs->event_thread->stop_pc (), ecs->event_thread, ecs->ws); @@ -6884,7 +6884,7 @@ handle_signal_stop (struct execution_control_state *ecs) CORE_ADDR pc; regcache = get_thread_regcache (ecs->event_thread); - const address_space *aspace = regcache->aspace (); + const address_space *aspace = ecs->event_thread->inf->aspace; pc = regcache_read_pc (regcache); @@ -6968,8 +6968,7 @@ handle_signal_stop (struct execution_control_state *ecs) inline function call sites). */ if (ecs->event_thread->control.step_range_end != 1) { - const address_space *aspace - = get_thread_regcache (ecs->event_thread)->aspace (); + const address_space *aspace = ecs->event_thread->inf->aspace; /* skip_inline_frames is expensive, so we avoid it if we can determine that the address is one where functions cannot have @@ -7047,7 +7046,7 @@ handle_signal_stop (struct execution_control_state *ecs) /* See if there is a breakpoint/watchpoint/catchpoint/etc. that handles this event. */ ecs->event_thread->control.stop_bpstat - = bpstat_stop_status (get_current_regcache ()->aspace (), + = bpstat_stop_status (ecs->event_thread->inf->aspace, ecs->event_thread->stop_pc (), ecs->event_thread, ecs->ws, stop_chain); @@ -8931,7 +8930,7 @@ keep_going_pass_signal (struct execution_control_state *ecs) if (remove_bp && (remove_wps || !use_displaced_stepping (ecs->event_thread))) { - set_step_over_info (regcache->aspace (), + set_step_over_info (ecs->event_thread->inf->aspace, regcache_read_pc (regcache), remove_wps, ecs->event_thread->global_num); } |