aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/aarch64-fbsd-tdep.c3
-rw-r--r--gdb/amd64-fbsd-tdep.c6
-rw-r--r--gdb/arm-fbsd-tdep.c6
-rw-r--r--gdb/darwin-nat.c7
-rw-r--r--gdb/displaced-stepping.c3
-rw-r--r--gdb/frame.c12
-rw-r--r--gdb/gcore-elf.c5
-rw-r--r--gdb/i386-fbsd-tdep.c6
-rw-r--r--gdb/infrun.c43
-rw-r--r--gdb/linux-nat.c56
-rw-r--r--gdb/linux-nat.h2
-rw-r--r--gdb/ppc-fbsd-tdep.c6
-rw-r--r--gdb/proc-service.c3
-rw-r--r--gdb/process-stratum-target.c14
-rw-r--r--gdb/process-stratum-target.h4
-rw-r--r--gdb/record-full.c6
-rw-r--r--gdb/regcache.c68
-rw-r--r--gdb/regcache.h27
-rw-r--r--gdb/remote.c8
-rw-r--r--gdb/riscv-fbsd-tdep.c6
-rw-r--r--gdb/sol-thread.c20
-rw-r--r--gdb/solib-svr4.c5
-rw-r--r--gdb/target-delegates.c28
-rw-r--r--gdb/target.c13
-rw-r--r--gdb/target.h8
25 files changed, 113 insertions, 252 deletions
diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index 1102eb0..681149b 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -215,8 +215,7 @@ aarch64_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
struct regcache *regcache;
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
target_fetch_registers (regcache, tdep->tls_regnum_base);
diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index 2b633cd..5b0896fc 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -288,10 +288,8 @@ static CORE_ADDR
amd64fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
CORE_ADDR lm_addr, CORE_ADDR offset)
{
- struct regcache *regcache;
-
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
target_fetch_registers (regcache, AMD64_FSBASE_REGNUM);
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index b6aa42a..90273a3 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -271,10 +271,8 @@ arm_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
CORE_ADDR lm_addr, CORE_ADDR offset)
{
arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
- struct regcache *regcache;
-
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
target_fetch_registers (regcache, tdep->tls_regnum);
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 588e9e2..0de476b 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1151,7 +1151,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
}
int
-darwin_nat_target::cancel_breakpoint (ptid_t ptid)
+darwin_nat_target::cancel_breakpoint (inferior *inf, ptid_t ptid)
{
/* Arrange for a breakpoint to be hit again later. We will handle
the current event, eventually we will resume this thread, and this
@@ -1166,7 +1166,7 @@ darwin_nat_target::cancel_breakpoint (ptid_t ptid)
CORE_ADDR pc;
pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch);
- if (breakpoint_inserted_here_p (regcache->aspace (), pc))
+ if (breakpoint_inserted_here_p (inf->aspace, pc))
{
inferior_debug (4, "cancel_breakpoint for thread 0x%lx\n",
(unsigned long) ptid.tid ());
@@ -1286,7 +1286,8 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
&& thread->event.ex_type == EXC_BREAKPOINT)
{
if (thread->single_step
- || cancel_breakpoint (ptid_t (inf->pid, 0, thread->gdb_port)))
+ || cancel_breakpoint (inf,
+ ptid_t (inf->pid, 0, thread->gdb_port)))
{
gdb_assert (thread->msg_state == DARWIN_MESSAGE);
darwin_send_reply (inf, thread);
diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c
index 6d5e6cd..9d45013 100644
--- a/gdb/displaced-stepping.c
+++ b/gdb/displaced-stepping.c
@@ -53,7 +53,6 @@ displaced_step_buffers::prepare (thread_info *thread, CORE_ADDR &displaced_pc)
gdb_assert (buf.current_thread != thread);
regcache *regcache = get_thread_regcache (thread);
- const address_space *aspace = regcache->aspace ();
gdbarch *arch = regcache->arch ();
ULONGEST len = gdbarch_displaced_step_buffer_length (arch);
@@ -64,7 +63,7 @@ displaced_step_buffers::prepare (thread_info *thread, CORE_ADDR &displaced_pc)
for (displaced_step_buffer &candidate : m_buffers)
{
- bool bp_in_range = breakpoint_in_range_p (aspace, candidate.addr, len);
+ bool bp_in_range = breakpoint_in_range_p (thread->inf->aspace, candidate.addr, len);
bool is_free = candidate.current_thread == nullptr;
if (!bp_in_range)
diff --git a/gdb/frame.c b/gdb/frame.c
index 4a46ccb..dfd9299 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1620,14 +1620,15 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
CODE_ADDR. */
static frame_info_ptr
-create_sentinel_frame (struct program_space *pspace, struct regcache *regcache,
- CORE_ADDR stack_addr, CORE_ADDR code_addr)
+create_sentinel_frame (program_space *pspace, address_space *aspace,
+ regcache *regcache, CORE_ADDR stack_addr,
+ CORE_ADDR code_addr)
{
frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
frame->level = -1;
frame->pspace = pspace;
- frame->aspace = regcache->aspace ();
+ frame->aspace = aspace;
/* Explicitly initialize the sentinel frame's cache. Provide it
with the underlying regcache. In the future additional
information, such as the frame's thread will be added. */
@@ -1688,8 +1689,8 @@ get_current_frame (void)
if (sentinel_frame == NULL)
sentinel_frame =
- create_sentinel_frame (current_program_space, get_current_regcache (),
- 0, 0).get ();
+ create_sentinel_frame (current_program_space, current_inferior ()->aspace,
+ get_current_regcache (), 0, 0).get ();
/* Set the current frame before computing the frame id, to avoid
recursion inside compute_frame_id, in case the frame's
@@ -2022,6 +2023,7 @@ create_new_frame (frame_id id)
frame_info *fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
fi->next = create_sentinel_frame (current_program_space,
+ current_inferior ()->aspace,
get_current_regcache (),
id.stack_addr, id.code_addr).get ();
diff --git a/gdb/gcore-elf.c b/gdb/gcore-elf.c
index 0142db8..8b4177c 100644
--- a/gdb/gcore-elf.c
+++ b/gdb/gcore-elf.c
@@ -128,9 +128,8 @@ gcore_elf_build_thread_register_notes
(struct gdbarch *gdbarch, struct thread_info *info, gdb_signal stop_signal,
bfd *obfd, gdb::unique_xmalloc_ptr<char> *note_data, int *note_size)
{
- struct regcache *regcache
- = get_thread_arch_regcache (info->inf->process_target (),
- info->ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (info->inf, info->ptid, gdbarch);
target_fetch_registers (regcache, -1);
gcore_elf_collect_thread_registers (regcache, info->ptid, obfd,
note_data, note_size, stop_signal);
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index f8c2758..58d06e3 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -354,10 +354,8 @@ static CORE_ADDR
i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
CORE_ADDR lm_addr, CORE_ADDR offset)
{
- struct regcache *regcache;
-
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
target_fetch_registers (regcache, I386_GSBASE_REGNUM);
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);
}
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 8951b34..d3e9560 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2472,6 +2472,17 @@ stop_wait_callback (struct lwp_info *lp)
return 0;
}
+/* Get the inferior associated to LWP. Must be called with an LWP that has
+ an associated inferior. Always return non-nullptr. */
+
+static inferior *
+lwp_inferior (const lwp_info *lwp)
+{
+ inferior *inf = find_inferior_ptid (linux_target, lwp->ptid);
+ gdb_assert (inf != nullptr);
+ return inf;
+}
+
/* Return non-zero if LP has a wait status pending. Discard the
pending event and resume the LWP if the event that originally
caused the stop became uninteresting. */
@@ -2507,7 +2518,7 @@ status_callback (struct lwp_info *lp)
}
#if !USE_SIGTRAP_SIGINFO
- else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
+ else if (!breakpoint_inserted_here_p (lwp_inferior (lp)->aspace, pc))
{
linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
lp->ptid.to_string ().c_str (),
@@ -2607,7 +2618,7 @@ save_stop_reason (struct lwp_info *lp)
if (!linux_target->low_status_is_event (lp->status))
return;
- inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
+ inferior *inf = lwp_inferior (lp);
if (inf->starting_up)
return;
@@ -2662,15 +2673,14 @@ save_stop_reason (struct lwp_info *lp)
}
#else
if ((!lp->step || lp->stop_pc == sw_bp_pc)
- && software_breakpoint_inserted_here_p (regcache->aspace (),
- sw_bp_pc))
+ && software_breakpoint_inserted_here_p (inf->aspace, sw_bp_pc))
{
/* The LWP was either continued, or stepped a software
breakpoint instruction. */
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
}
- if (hardware_breakpoint_inserted_here_p (regcache->aspace (), pc))
+ if (hardware_breakpoint_inserted_here_p (inf->aspace, pc))
lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
if (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
@@ -3417,7 +3427,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
static int
resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
{
- inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
+ inferior *inf = lwp_inferior (lp);
if (!lp->stopped)
{
@@ -3453,7 +3463,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
immediately, and we're not waiting for this LWP. */
if (!lp->ptid.matches (wait_ptid))
{
- if (breakpoint_inserted_here_p (regcache->aspace (), pc))
+ if (breakpoint_inserted_here_p (inf->aspace, pc))
leave_stopped = 1;
}
@@ -4383,38 +4393,6 @@ linux_nat_target::stop (ptid_t ptid)
iterate_over_lwps (ptid, linux_nat_stop_lwp);
}
-/* When requests are passed down from the linux-nat layer to the
- single threaded inf-ptrace layer, ptids of (lwpid,0,0) form are
- used. The address space pointer is stored in the inferior object,
- but the common code that is passed such ptid can't tell whether
- lwpid is a "main" process id or not (it assumes so). We reverse
- look up the "main" process id from the lwp here. */
-
-struct address_space *
-linux_nat_target::thread_address_space (ptid_t ptid)
-{
- struct lwp_info *lwp;
- struct inferior *inf;
- int pid;
-
- if (ptid.lwp () == 0)
- {
- /* An (lwpid,0,0) ptid. Look up the lwp object to get at the
- tgid. */
- lwp = find_lwp_pid (ptid);
- pid = lwp->ptid.pid ();
- }
- else
- {
- /* A (pid,lwpid,0) ptid. */
- pid = ptid.pid ();
- }
-
- inf = find_inferior_pid (this, pid);
- gdb_assert (inf != NULL);
- return inf->aspace;
-}
-
/* Return the cached value of the processor core for thread PTID. */
int
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index cf23616..cce8bb3 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -68,8 +68,6 @@ public:
const char *thread_name (struct thread_info *) override;
- struct address_space *thread_address_space (ptid_t) override;
-
bool stopped_by_watchpoint () override;
bool stopped_data_address (CORE_ADDR *) override;
diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
index 4355b64..2238a22 100644
--- a/gdb/ppc-fbsd-tdep.c
+++ b/gdb/ppc-fbsd-tdep.c
@@ -288,11 +288,9 @@ ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
CORE_ADDR lm_addr, CORE_ADDR offset)
{
ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
- struct regcache *regcache;
int tp_offset, tp_regnum;
-
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
if (tdep->wordsize == 4)
{
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index e41278d..48f3dec 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -135,8 +135,7 @@ static struct regcache *
get_ps_regcache (struct ps_prochandle *ph, lwpid_t lwpid)
{
inferior *inf = ph->thread->inf;
- return get_thread_arch_regcache (inf->process_target (),
- ptid_t (inf->pid, lwpid),
+ return get_thread_arch_regcache (inf, ptid_t (inf->pid, lwpid),
inf->arch ());
}
diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
index 173c3ec..017d26e 100644
--- a/gdb/process-stratum-target.c
+++ b/gdb/process-stratum-target.c
@@ -26,20 +26,6 @@ process_stratum_target::~process_stratum_target ()
{
}
-struct address_space *
-process_stratum_target::thread_address_space (ptid_t ptid)
-{
- /* Fall-back to the "main" address space of the inferior. */
- inferior *inf = find_inferior_ptid (this, ptid);
-
- if (inf == NULL || inf->aspace == NULL)
- internal_error (_("Can't determine the current "
- "address space of thread %s\n"),
- target_pid_to_str (ptid).c_str ());
-
- return inf->aspace;
-}
-
struct gdbarch *
process_stratum_target::thread_architecture (ptid_t ptid)
{
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index f4968ec..f35b599 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -51,10 +51,6 @@ public:
bool supports_non_stop () override { return false; }
bool supports_disable_randomization () override { return false; }
- /* This default implementation returns the inferior's address
- space. */
- struct address_space *thread_address_space (ptid_t ptid) override;
-
/* This default implementation always returns the current inferior's
gdbarch. */
struct gdbarch *thread_architecture (ptid_t ptid) override;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 2ee08e6..1cea869 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -884,7 +884,7 @@ record_full_exec_insn (struct regcache *regcache,
not doing the change at all if the watchpoint
traps. */
if (hardware_watchpoint_inserted_in_range
- (regcache->aspace (),
+ (current_inferior ()->aspace,
entry->u.mem.addr, entry->u.mem.len))
record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
}
@@ -1218,7 +1218,7 @@ record_full_wait_1 (struct target_ops *ops,
ret);
regcache = get_current_regcache ();
tmp_pc = regcache_read_pc (regcache);
- const struct address_space *aspace = regcache->aspace ();
+ const address_space *aspace = current_inferior ()->aspace;
if (target_stopped_by_watchpoint ())
{
@@ -1288,7 +1288,7 @@ record_full_wait_1 (struct target_ops *ops,
record_full_resume_ptid);
struct regcache *regcache = get_current_regcache ();
struct gdbarch *gdbarch = regcache->arch ();
- const struct address_space *aspace = regcache->aspace ();
+ const address_space *aspace = current_inferior ()->aspace;
int continue_flag = 1;
int first_record_full_end = 1;
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 2e48c02..48a926e 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -208,11 +208,10 @@ reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo)
}
}
-regcache::regcache (inferior *inf_for_target_calls, gdbarch *gdbarch,
- const address_space *aspace_)
+regcache::regcache (inferior *inf_for_target_calls, gdbarch *gdbarch)
/* The register buffers. A read/write register cache can only hold
[0 .. gdbarch_num_regs). */
- : detached_regcache (gdbarch, false), m_aspace (aspace_),
+ : detached_regcache (gdbarch, false),
m_inf_for_target_calls (inf_for_target_calls)
{
m_ptid = minus_one_ptid;
@@ -348,10 +347,9 @@ using target_pid_ptid_regcache_map
target when appropriate. */
static target_pid_ptid_regcache_map regcaches;
-struct regcache *
-get_thread_arch_aspace_regcache (inferior *inf_for_target_calls,
- ptid_t ptid, gdbarch *arch,
- struct address_space *aspace)
+regcache *
+get_thread_arch_regcache (inferior *inf_for_target_calls, ptid_t ptid,
+ gdbarch *arch)
{
gdb_assert (inf_for_target_calls != nullptr);
@@ -373,7 +371,7 @@ get_thread_arch_aspace_regcache (inferior *inf_for_target_calls,
}
/* It does not exist, create it. */
- regcache *new_regcache = new regcache (inf_for_target_calls, arch, aspace);
+ regcache *new_regcache = new regcache (inf_for_target_calls, arch);
new_regcache->set_ptid (ptid);
/* Work around a problem with g++ 4.8 (PR96537): Call the regcache_up
constructor explicitly instead of implicitly. */
@@ -382,18 +380,6 @@ get_thread_arch_aspace_regcache (inferior *inf_for_target_calls,
return new_regcache;
}
-struct regcache *
-get_thread_arch_regcache (process_stratum_target *target, ptid_t ptid,
- struct gdbarch *gdbarch)
-{
- scoped_restore_current_inferior restore_current_inferior;
- inferior *inf = find_inferior_ptid (target, ptid);
- set_current_inferior (inf);
- address_space *aspace = target_thread_address_space (ptid);
-
- return get_thread_arch_aspace_regcache (inf, ptid, gdbarch, aspace);
-}
-
static process_stratum_target *current_thread_target;
static ptid_t current_thread_ptid;
static struct gdbarch *current_thread_arch;
@@ -401,6 +387,8 @@ static struct gdbarch *current_thread_arch;
struct regcache *
get_thread_regcache (process_stratum_target *target, ptid_t ptid)
{
+ inferior *inf = find_inferior_ptid (target, ptid);
+
if (!current_thread_arch
|| target != current_thread_target
|| current_thread_ptid != ptid)
@@ -411,11 +399,11 @@ get_thread_regcache (process_stratum_target *target, ptid_t ptid)
current_thread_target = target;
scoped_restore_current_inferior restore_current_inferior;
- set_current_inferior (find_inferior_ptid (target, ptid));
+ set_current_inferior (inf);
current_thread_arch = target_thread_architecture (ptid);
}
- return get_thread_arch_regcache (target, ptid, current_thread_arch);
+ return get_thread_arch_regcache (inf, ptid, current_thread_arch);
}
/* See regcache.h. */
@@ -1618,24 +1606,22 @@ regcache_count (process_stratum_target *target, ptid_t ptid)
return 0;
};
-/* Wrapper around get_thread_arch_aspace_regcache that does some self checks. */
+/* Wrapper around get_thread_arch_regcache that does some self checks. */
static void
-get_thread_arch_aspace_regcache_and_check (inferior *inf_for_target_calls,
- ptid_t ptid)
+get_thread_arch_regcache_and_check (inferior *inf_for_target_calls,
+ ptid_t ptid)
{
/* We currently only test with a single gdbarch. Any gdbarch will do, so use
the current inferior's gdbarch. Also use the current inferior's address
space. */
gdbarch *arch = inf_for_target_calls->arch ();
- address_space *aspace = inf_for_target_calls->aspace;
- regcache *regcache = get_thread_arch_aspace_regcache (inf_for_target_calls,
- ptid, arch, aspace);
+ regcache *regcache
+ = get_thread_arch_regcache (inf_for_target_calls, ptid, arch);
SELF_CHECK (regcache != NULL);
SELF_CHECK (regcache->ptid () == ptid);
SELF_CHECK (regcache->arch () == arch);
- SELF_CHECK (regcache->aspace () == aspace);
}
/* The data that the regcaches selftests must hold onto for the duration of the
@@ -1683,12 +1669,12 @@ populate_regcaches_for_test ()
{
for (long lwp : { 1, 2, 3 })
{
- get_thread_arch_aspace_regcache_and_check
+ get_thread_arch_regcache_and_check
(&data->test_ctx_1.mock_inferior, ptid_t (pid, lwp));
expected_regcache_size++;
SELF_CHECK (regcaches_size () == expected_regcache_size);
- get_thread_arch_aspace_regcache_and_check
+ get_thread_arch_regcache_and_check
(&data->test_ctx_2.mock_inferior, ptid_t (pid, lwp));
expected_regcache_size++;
SELF_CHECK (regcaches_size () == expected_regcache_size);
@@ -1699,16 +1685,16 @@ populate_regcaches_for_test ()
}
static void
-get_thread_arch_aspace_regcache_test ()
+get_thread_arch_regcache_test ()
{
/* populate_regcaches_for_test already tests most of the
- get_thread_arch_aspace_regcache functionality. */
+ get_thread_arch_regcache functionality. */
regcache_test_data_up data = populate_regcaches_for_test ();
size_t regcaches_size_before = regcaches_size ();
/* Test that getting an existing regcache doesn't create a new one. */
- get_thread_arch_aspace_regcache_and_check (&data->test_ctx_1.mock_inferior,
- ptid_t (2, 2));
+ get_thread_arch_regcache_and_check (&data->test_ctx_1.mock_inferior,
+ ptid_t (2, 2));
SELF_CHECK (regcaches_size () == regcaches_size_before);
}
@@ -1835,7 +1821,7 @@ class readwrite_regcache : public regcache
public:
readwrite_regcache (inferior *inf_for_target_calls,
struct gdbarch *gdbarch)
- : regcache (inf_for_target_calls, gdbarch, nullptr)
+ : regcache (inf_for_target_calls, gdbarch)
{}
};
@@ -2116,10 +2102,8 @@ regcache_thread_ptid_changed ()
gdb_assert (regcaches.empty ());
/* Populate the regcaches container. */
- get_thread_arch_aspace_regcache (&target1.mock_inferior, old_ptid, arch,
- nullptr);
- get_thread_arch_aspace_regcache (&target2.mock_inferior, old_ptid, arch,
- nullptr);
+ get_thread_arch_regcache (&target1.mock_inferior, old_ptid, arch);
+ get_thread_arch_regcache (&target2.mock_inferior, old_ptid, arch);
gdb_assert (regcaches.size () == 2);
gdb_assert (regcache_count (&target1.mock_target, old_ptid) == 1);
@@ -2163,8 +2147,8 @@ _initialize_regcache ()
deprecate_cmd (c, "maintenance flush register-cache");
#if GDB_SELF_TEST
- selftests::register_test ("get_thread_arch_aspace_regcache",
- selftests::get_thread_arch_aspace_regcache_test);
+ selftests::register_test ("get_thread_arch_regcache",
+ selftests::get_thread_arch_regcache_test);
selftests::register_test ("registers_changed_ptid_all",
selftests::registers_changed_ptid_all_test);
selftests::register_test ("registers_changed_ptid_target",
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>;
diff --git a/gdb/remote.c b/gdb/remote.c
index ce5adda..5012700 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8421,6 +8421,8 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,
&& status->kind () != TARGET_WAITKIND_SIGNALLED
&& status->kind () != TARGET_WAITKIND_NO_RESUMED)
{
+ remote_notice_new_inferior (ptid, false);
+
/* Expedited registers. */
if (!stop_reply->regcache.empty ())
{
@@ -8429,8 +8431,9 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,
already). */
gdb_assert (status->kind () != TARGET_WAITKIND_THREAD_EXITED);
- struct regcache *regcache
- = get_thread_arch_regcache (this, ptid, stop_reply->arch);
+ regcache *regcache
+ = get_thread_arch_regcache (find_inferior_ptid (this, ptid), ptid,
+ stop_reply->arch);
for (cached_reg_t &reg : stop_reply->regcache)
{
@@ -8441,7 +8444,6 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,
stop_reply->regcache.clear ();
}
- remote_notice_new_inferior (ptid, false);
remote_thread_info *remote_thr = get_remote_thread_info (this, ptid);
remote_thr->core = stop_reply->core;
remote_thr->stop_reason = stop_reply->stop_reason;
diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
index 8ae4a19..9050cf4 100644
--- a/gdb/riscv-fbsd-tdep.c
+++ b/gdb/riscv-fbsd-tdep.c
@@ -166,10 +166,8 @@ static CORE_ADDR
riscv_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
CORE_ADDR lm_addr, CORE_ADDR offset)
{
- struct regcache *regcache;
-
- regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
- ptid, gdbarch);
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), ptid, gdbarch);
target_fetch_registers (regcache, RISCV_TP_REGNUM);
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);
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index e21190a..b02e809 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2399,9 +2399,8 @@ enable_break (struct svr4_info *info, int from_tty)
most cases. */
if (!load_addr_found)
{
- struct regcache *regcache
- = get_thread_arch_regcache (current_inferior ()->process_target (),
- inferior_ptid,
+ regcache *regcache
+ = get_thread_arch_regcache (current_inferior (), inferior_ptid,
current_inferior ()->arch ());
load_addr = (regcache_read_pc (regcache)
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index a27b66d..4c499fa 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -134,7 +134,6 @@ struct dummy_target : public target_ops
void dumpcore (const char *arg0) override;
bool can_run_breakpoint_commands () override;
struct gdbarch *thread_architecture (ptid_t arg0) override;
- struct address_space *thread_address_space (ptid_t arg0) override;
bool filesystem_is_local () override;
void trace_init () override;
void download_tracepoint (struct bp_location *arg0) override;
@@ -311,7 +310,6 @@ struct debug_target : public target_ops
void dumpcore (const char *arg0) override;
bool can_run_breakpoint_commands () override;
struct gdbarch *thread_architecture (ptid_t arg0) override;
- struct address_space *thread_address_space (ptid_t arg0) override;
bool filesystem_is_local () override;
void trace_init () override;
void download_tracepoint (struct bp_location *arg0) override;
@@ -3014,32 +3012,6 @@ debug_target::thread_architecture (ptid_t arg0)
return result;
}
-struct address_space *
-target_ops::thread_address_space (ptid_t arg0)
-{
- return this->beneath ()->thread_address_space (arg0);
-}
-
-struct address_space *
-dummy_target::thread_address_space (ptid_t arg0)
-{
- return NULL;
-}
-
-struct address_space *
-debug_target::thread_address_space (ptid_t arg0)
-{
- gdb_printf (gdb_stdlog, "-> %s->thread_address_space (...)\n", this->beneath ()->shortname ());
- struct address_space * result
- = this->beneath ()->thread_address_space (arg0);
- gdb_printf (gdb_stdlog, "<- %s->thread_address_space (", this->beneath ()->shortname ());
- target_debug_print_ptid_t (arg0);
- gdb_puts (") = ", gdb_stdlog);
- target_debug_print_address_space_p (result);
- gdb_puts ("\n", gdb_stdlog);
- return result;
-}
-
bool
target_ops::filesystem_is_local ()
{
diff --git a/gdb/target.c b/gdb/target.c
index a6ca7fc..a93740b 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2999,19 +2999,6 @@ target_get_osdata (const char *type)
return target_read_stralloc (t, TARGET_OBJECT_OSDATA, type);
}
-/* Determine the current address space of thread PTID. */
-
-struct address_space *
-target_thread_address_space (ptid_t ptid)
-{
- struct address_space *aspace;
-
- aspace = current_inferior ()->top_target ()->thread_address_space (ptid);
- gdb_assert (aspace != NULL);
-
- return aspace;
-}
-
/* See target.h. */
target_ops *
diff --git a/gdb/target.h b/gdb/target.h
index 558be46..fca0bbb 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -949,10 +949,6 @@ struct target_ops
virtual struct gdbarch *thread_architecture (ptid_t)
TARGET_DEFAULT_RETURN (NULL);
- /* Determine current address space of thread PTID. */
- virtual struct address_space *thread_address_space (ptid_t)
- TARGET_DEFAULT_RETURN (NULL);
-
/* Target file operations. */
/* Return true if the filesystem seen by the current inferior
@@ -1544,10 +1540,6 @@ extern void target_store_registers (struct regcache *regcache, int regs);
extern void target_prepare_to_store (regcache *regcache);
-/* Determine current address space of thread PTID. */
-
-struct address_space *target_thread_address_space (ptid_t);
-
/* Implement the "info proc" command. This returns one if the request
was handled, and zero otherwise. It can also throw an exception if
an error was encountered while attempting to handle the