Call target_ops::beneath() throughout instead.
gdb/ChangeLog:
2018-06-07 Pedro Alves <palves@redhat.com>
* target.h (find_target_beneath): Delete declaration.
* target.c (find_target_beneath): Delete definition.
* aix-thread.c: All callers of find_target_beneath adjusted to
call target_ops::beneath instead.
* bsd-uthread.c: Likewise.
* linux-thread-db.c: Likewise.
* ravenscar-thread.c: Likewise.
* sol-thread.c: Likewise.
* spu-multiarch.c: Likewise.
+2018-06-07 Pedro Alves <palves@redhat.com>
+
+ * target.h (find_target_beneath): Delete declaration.
+ * target.c (find_target_beneath): Delete definition.
+ * aix-thread.c: All callers of find_target_beneath adjusted to
+ call target_ops::beneath instead.
+ * bsd-uthread.c: Likewise.
+ * linux-thread-db.c: Likewise.
+ * ravenscar-thread.c: Likewise.
+ * sol-thread.c: Likewise.
+ * spu-multiarch.c: Likewise.
+
2018-06-07 Pedro Alves <palves@redhat.com>
* target.h (target_ops) <beneath>: Now a method. All references
void
aix_thread_target::detach (inferior *inf, int from_tty)
{
- struct target_ops *beneath = find_target_beneath (this);
+ target_ops *beneath = this->beneath ();
pd_disable ();
beneath->detach (inf, from_tty);
if (!PD_TID (ptid))
{
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
- struct target_ops *beneath = find_target_beneath (this);
inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
- beneath->resume (ptid, step, sig);
+ beneath ()->resume (ptid, step, sig);
}
else
{
aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
int options)
{
- struct target_ops *beneath = find_target_beneath (this);
-
{
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
pid_to_prc (&ptid);
inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
- ptid = beneath->wait (ptid, status, options);
+ ptid = beneath ()->wait (ptid, status, options);
}
if (ptid_get_pid (ptid) == -1)
{
struct thread_info *thread;
pthdb_tid_t tid;
- struct target_ops *beneath = find_target_beneath (this);
if (!PD_TID (regcache->ptid ()))
- beneath->fetch_registers (regcache, regno);
+ beneath ()->fetch_registers (regcache, regno);
else
{
thread = find_thread_ptid (regcache->ptid ());
{
struct thread_info *thread;
pthdb_tid_t tid;
- struct target_ops *beneath = find_target_beneath (this);
if (!PD_TID (regcache->ptid ()))
- beneath->store_registers (regcache, regno);
+ beneath ()->store_registers (regcache, regno);
else
{
thread = find_thread_ptid (regcache->ptid ());
ULONGEST *xfered_len)
{
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
- struct target_ops *beneath = find_target_beneath (this);
inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
- return beneath->xfer_partial (object, annex, readbuf,
- writebuf, offset, len, xfered_len);
+ return beneath ()->xfer_partial (object, annex, readbuf,
+ writebuf, offset, len, xfered_len);
}
/* Clean up after the inferior exits. */
void
aix_thread_target::mourn_inferior ()
{
- struct target_ops *beneath = find_target_beneath (this);
+ target_ops *beneath = beneath ();
pd_deactivate ();
beneath->mourn_inferior ();
bool
aix_thread_target::thread_alive (ptid_t ptid)
{
- struct target_ops *beneath = find_target_beneath (this);
-
if (!PD_TID (ptid))
- return beneath->thread_alive (ptid);
+ return beneath ()->thread_alive (ptid);
/* We update the thread list every time the child stops, so all
valid threads should be in the thread list. */
aix_thread_target::pid_to_str (ptid_t ptid)
{
static char *ret = NULL;
- struct target_ops *beneath = find_target_beneath (this);
if (!PD_TID (ptid))
- return beneath->pid_to_str (ptid);
+ return beneath ()->pid_to_str (ptid);
/* Free previous return value; a new one will be allocated by
xstrprintf(). */
void
bsd_uthread_target::mourn_inferior ()
{
- struct target_ops *beneath = find_target_beneath (this);
- beneath->mourn_inferior ();
+ beneath ()->mourn_inferior ();
bsd_uthread_deactivate ();
}
= (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
ptid_t ptid = regcache->ptid ();
CORE_ADDR addr = ptid_get_tid (ptid);
- struct target_ops *beneath = find_target_beneath (this);
CORE_ADDR active_addr;
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = ptid;
/* Always fetch the appropriate registers from the layer beneath. */
- beneath->fetch_registers (regcache, regnum);
+ beneath ()->fetch_registers (regcache, regnum);
/* FIXME: That might have gotten us more than we asked for. Make
sure we overwrite all relevant registers with values from the
struct gdbarch *gdbarch = regcache->arch ();
struct bsd_uthread_ops *uthread_ops
= (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
- struct target_ops *beneath = find_target_beneath (this);
ptid_t ptid = regcache->ptid ();
CORE_ADDR addr = ptid_get_tid (ptid);
CORE_ADDR active_addr;
{
/* Updating the thread that is currently running; pass the
request to the layer beneath. */
- beneath->store_registers (regcache, regnum);
+ beneath ()->store_registers (regcache, regnum);
}
}
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
CORE_ADDR addr;
- struct target_ops *beneath = find_target_beneath (this);
/* Pass the request to the layer beneath. */
- ptid = beneath->wait (ptid, status, options);
+ ptid = beneath ()->wait (ptid, status, options);
/* If the process is no longer alive, there's no point in figuring
out the thread ID. It will fail anyway. */
bsd_uthread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
{
/* Pass the request to the layer beneath. */
- struct target_ops *beneath = find_target_beneath (this);
- beneath->resume (ptid, step, sig);
+ beneath ()->resume (ptid, step, sig);
}
bool
bsd_uthread_target::thread_alive (ptid_t ptid)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
- struct target_ops *beneath = find_target_beneath (this);
CORE_ADDR addr = ptid_get_tid (ptid);
if (addr != 0)
return false;
}
- return beneath->thread_alive (ptid);
+ return beneath ()->thread_alive (ptid);
}
void
void
thread_db_target::detach (inferior *inf, int from_tty)
{
- struct target_ops *target_beneath = find_target_beneath (this);
-
delete_thread_db_info (inf->pid);
- target_beneath->detach (inf, from_tty);
+ beneath ()->detach (inf, from_tty);
/* NOTE: From this point on, inferior_ptid is null_ptid. */
int options)
{
struct thread_db_info *info;
- struct target_ops *beneath = find_target_beneath (this);
- ptid = beneath->wait (ptid, ourstatus, options);
+ ptid = beneath ()->wait (ptid, ourstatus, options);
switch (ourstatus->kind)
{
void
thread_db_target::mourn_inferior ()
{
- struct target_ops *target_beneath = find_target_beneath (this);
-
delete_thread_db_info (ptid_get_pid (inferior_ptid));
- target_beneath->mourn_inferior ();
+ beneath ()->mourn_inferior ();
/* Detach thread_db target ops. */
if (!thread_db_list)
thread_db_target::pid_to_str (ptid_t ptid)
{
struct thread_info *thread_info = find_thread_ptid (ptid);
- struct target_ops *beneath;
if (thread_info != NULL && thread_info->priv != NULL)
{
return buf;
}
- beneath = find_target_beneath (this);
- return beneath->pid_to_str (ptid);
+ return beneath ()->pid_to_str (ptid);
}
/* Return a string describing the state of the thread specified by
CORE_ADDR offset)
{
struct thread_info *thread_info;
- struct target_ops *beneath;
/* Find the matching thread. */
thread_info = find_thread_ptid (ptid);
: (CORE_ADDR) (uintptr_t) address);
}
- beneath = find_target_beneath (this);
- return beneath->get_thread_local_address (ptid, lm, offset);
+ return beneath ()->get_thread_local_address (ptid, lm, offset);
}
/* Implement the to_get_ada_task_ptid target method for this target. */
void
thread_db_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
{
- struct target_ops *beneath = find_target_beneath (this);
struct thread_db_info *info;
if (ptid_equal (ptid, minus_one_ptid))
if (info)
info->need_stale_parent_threads_check = 0;
- beneath->resume (ptid, step, signo);
+ beneath ()->resume (ptid, step, signo);
}
/* std::sort helper function for info_auto_load_libthread_db, sort the
void
ravenscar_thread_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
{
- struct target_ops *beneath = find_target_beneath (this);
-
inferior_ptid = base_ptid;
- beneath->resume (base_ptid, step, siggnal);
+ beneath ()->resume (base_ptid, step, siggnal);
}
ptid_t
struct target_waitstatus *status,
int options)
{
- struct target_ops *beneath = find_target_beneath (this);
ptid_t event_ptid;
inferior_ptid = base_ptid;
- event_ptid = beneath->wait (base_ptid, status, 0);
+ event_ptid = beneath ()->wait (base_ptid, status, 0);
/* Find any new threads that might have been created, and update
inferior_ptid to the active thread.
void
ravenscar_thread_target::fetch_registers (struct regcache *regcache, int regnum)
{
- struct target_ops *beneath = find_target_beneath (this);
ptid_t ptid = regcache->ptid ();
if (ravenscar_runtime_initialized ()
arch_ops->to_fetch_registers (regcache, regnum);
}
else
- beneath->fetch_registers (regcache, regnum);
+ beneath ()->fetch_registers (regcache, regnum);
}
void
ravenscar_thread_target::store_registers (struct regcache *regcache,
int regnum)
{
- target_ops *beneath = find_target_beneath (this);
ptid_t ptid = regcache->ptid ();
if (ravenscar_runtime_initialized ()
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
- beneath->store_registers (regcache, regnum);
+ beneath ()->store_registers (regcache, regnum);
}
else
- beneath->store_registers (regcache, regnum);
+ beneath ()->store_registers (regcache, regnum);
}
void
ravenscar_thread_target::prepare_to_store (struct regcache *regcache)
{
- target_ops *beneath = find_target_beneath (this);
ptid_t ptid = regcache->ptid ();
if (ravenscar_runtime_initialized ()
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
- beneath->prepare_to_store (regcache);
+ beneath ()->prepare_to_store (regcache);
}
else
- beneath->prepare_to_store (regcache);
+ beneath ()->prepare_to_store (regcache);
}
/* Implement the to_stopped_by_sw_breakpoint target_ops "method". */
ravenscar_thread_target::stopped_by_sw_breakpoint ()
{
ptid_t saved_ptid = inferior_ptid;
- struct target_ops *beneath = find_target_beneath (this);
bool result;
inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
- result = beneath->stopped_by_sw_breakpoint ();
+ result = beneath ()->stopped_by_sw_breakpoint ();
inferior_ptid = saved_ptid;
return result;
}
ravenscar_thread_target::stopped_by_hw_breakpoint ()
{
ptid_t saved_ptid = inferior_ptid;
- struct target_ops *beneath = find_target_beneath (this);
bool result;
inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
- result = beneath->stopped_by_hw_breakpoint ();
+ result = beneath ()->stopped_by_hw_breakpoint ();
inferior_ptid = saved_ptid;
return result;
}
ravenscar_thread_target::stopped_by_watchpoint ()
{
ptid_t saved_ptid = inferior_ptid;
- struct target_ops *beneath = find_target_beneath (this);
bool result;
inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
- result = beneath->stopped_by_watchpoint ();
+ result = beneath ()->stopped_by_watchpoint ();
inferior_ptid = saved_ptid;
return result;
}
ravenscar_thread_target::stopped_data_address (CORE_ADDR *addr_p)
{
ptid_t saved_ptid = inferior_ptid;
- struct target_ops *beneath = find_target_beneath (this);
bool result;
inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
- result = beneath->stopped_data_address (addr_p);
+ result = beneath ()->stopped_data_address (addr_p);
inferior_ptid = saved_ptid;
return result;
}
void
ravenscar_thread_target::mourn_inferior ()
{
- struct target_ops *beneath = find_target_beneath (this);
-
base_ptid = null_ptid;
- beneath->mourn_inferior ();
+ beneath ()->mourn_inferior ();
unpush_target (&ravenscar_ops);
}
ravenscar_thread_target::core_of_thread (ptid_t ptid)
{
ptid_t saved_ptid = inferior_ptid;
- struct target_ops *beneath = find_target_beneath (this);
int result;
inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
- result = beneath->core_of_thread (inferior_ptid);
+ result = beneath ()->core_of_thread (inferior_ptid);
inferior_ptid = saved_ptid;
return result;
}
void
sol_thread_target::detach (inferior *inf, int from_tty)
{
- struct target_ops *beneath = find_target_beneath (this);
+ target_ops *beneath = this->beneath ();
sol_thread_active = 0;
inferior_ptid = pid_to_ptid (ptid_get_pid (main_ph.ptid));
void
sol_thread_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
{
- struct target_ops *beneath = find_target_beneath (this);
-
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = thread_to_lwp (inferior_ptid, ptid_get_pid (main_ph.ptid));
ptid_get_tid (save_ptid));
}
- beneath->resume (ptid, step, signo);
+ beneath ()->resume (ptid, step, signo);
}
/* Wait for any threads to stop. We may have to convert PTID from a
{
ptid_t rtnval;
ptid_t save_ptid;
- struct target_ops *beneath = find_target_beneath (this);
save_ptid = inferior_ptid;
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
ptid_get_tid (save_ptid));
}
- rtnval = beneath->wait (ptid, ourstatus, options);
+ rtnval = beneath ()->wait (ptid, ourstatus, options);
if (ourstatus->kind != TARGET_WAITKIND_EXITED)
{
prfpregset_t fpregset;
gdb_gregset_t *gregset_p = &gregset;
gdb_fpregset_t *fpregset_p = &fpregset;
- struct target_ops *beneath = find_target_beneath (this);
ptid_t ptid = regcache->ptid ();
if (!ptid_tid_p (ptid))
{
/* It's an LWP; pass the request on to the layer beneath. */
- beneath->fetch_registers (regcache, regnum);
+ beneath ()->fetch_registers (regcache, regnum);
return;
}
if (!ptid_tid_p (ptid))
{
- struct target_ops *beneath = find_target_beneath (this);
-
/* It's an LWP; pass the request on to the layer beneath. */
- beneath->store_registers (regcache, regnum);
+ beneath ()->store_registers (regcache, regnum);
return;
}
ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
{
- struct target_ops *beneath = find_target_beneath (this);
-
scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
if (ptid_tid_p (inferior_ptid) || !target_thread_alive (inferior_ptid))
inferior_ptid = procfs_first_available ();
}
- return beneath->xfer_partial (object, annex, readbuf,
- writebuf, offset, len, xfered_len);
+ return beneath ()->xfer_partial (object, annex, readbuf,
+ writebuf, offset, len, xfered_len);
}
static void
void
sol_thread_target::mourn_inferior ()
{
- struct target_ops *beneath = find_target_beneath (this);
+ target_ops *beneath = this->beneath ();
sol_thread_active = 0;
}
else
{
- struct target_ops *beneath = find_target_beneath (this);
-
/* It's an LPW; pass the request on to the layer below. */
- return beneath->thread_alive (ptid);
+ return beneath ()->thread_alive (ptid);
}
}
void
sol_thread_target::update_thread_list ()
{
- struct target_ops *beneath = find_target_beneath (this);
-
/* Delete dead threads. */
prune_threads ();
/* Find any new LWP's. */
- beneath->update_thread_list ();
+ beneath ()->update_thread_list ();
/* Then find any new user-level threads. */
p_td_ta_thr_iter (main_ta, sol_update_thread_list_callback, (void *) 0,
if (parse_spufs_run (ptid, &spufs_fd, &spufs_addr))
return spu_gdbarch (spufs_fd);
- target_ops *beneath = find_target_beneath (this);
- return beneath->thread_architecture (ptid);
+ return beneath ()->thread_architecture (ptid);
}
/* Override the to_region_ok_for_hw_watchpoint routine. */
int
spu_multiarch_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{
- struct target_ops *ops_beneath = find_target_beneath (this);
-
/* We cannot watch SPU local store. */
if (SPUADDR_SPU (addr) != -1)
return 0;
- return ops_beneath->region_ok_for_hw_watchpoint (addr, len);
+ return beneath ()->region_ok_for_hw_watchpoint (addr, len);
}
/* Override the to_fetch_registers routine. */
{
struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct target_ops *ops_beneath = find_target_beneath (this);
int spufs_fd;
CORE_ADDR spufs_addr;
/* This version applies only if we're currently in spu_run. */
if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
{
- ops_beneath->fetch_registers (regcache, regno);
+ beneath ()->fetch_registers (regcache, regno);
return;
}
{
gdb_byte buf[4];
- if (target_read (ops_beneath, TARGET_OBJECT_MEMORY, NULL,
+ if (target_read (beneath (), TARGET_OBJECT_MEMORY, NULL,
buf, spufs_addr, sizeof buf) == sizeof buf)
regcache->raw_supply (SPU_PC_REGNUM, buf);
}
int i;
xsnprintf (annex, sizeof annex, "%d/regs", spufs_fd);
- if (target_read (ops_beneath, TARGET_OBJECT_SPU, annex,
+ if (target_read (beneath (), TARGET_OBJECT_SPU, annex,
buf, 0, sizeof buf) == sizeof buf)
for (i = 0; i < SPU_NUM_GPRS; i++)
regcache->raw_supply (i, buf + i*16);
spu_multiarch_target::store_registers (struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = regcache->arch ();
- struct target_ops *ops_beneath = find_target_beneath (this);
int spufs_fd;
CORE_ADDR spufs_addr;
/* This version applies only if we're currently in spu_run. */
if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
{
- ops_beneath->store_registers (regcache, regno);
+ beneath ()->store_registers (regcache, regno);
return;
}
gdb_byte buf[4];
regcache->raw_collect (SPU_PC_REGNUM, buf);
- target_write (ops_beneath, TARGET_OBJECT_MEMORY, NULL,
+ target_write (beneath (), TARGET_OBJECT_MEMORY, NULL,
buf, spufs_addr, sizeof buf);
}
regcache->raw_collect (i, buf + i*16);
xsnprintf (annex, sizeof annex, "%d/regs", spufs_fd);
- target_write (ops_beneath, TARGET_OBJECT_SPU, annex,
+ target_write (beneath (), TARGET_OBJECT_SPU, annex,
buf, 0, sizeof buf);
}
}
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
{
- struct target_ops *ops_beneath = find_target_beneath (this);
+ struct target_ops *ops_beneath = this->beneath ();
/* Use the "mem" spufs file to access SPU local store. */
if (object == TARGET_OBJECT_MEMORY)
const gdb_byte *pattern, ULONGEST pattern_len,
CORE_ADDR *found_addrp)
{
- struct target_ops *ops_beneath = find_target_beneath (this);
-
/* For SPU local store, always fall back to the simple method. */
if (SPUADDR_SPU (start_addr) >= 0)
return simple_search_memory (this, start_addr, search_space_len,
pattern, pattern_len, found_addrp);
- return ops_beneath->search_memory (start_addr, search_space_len,
- pattern, pattern_len, found_addrp);
+ return beneath ()->search_memory (start_addr, search_space_len,
+ pattern, pattern_len, found_addrp);
}
void
spu_multiarch_target::mourn_inferior ()
{
- struct target_ops *ops_beneath = find_target_beneath (this);
-
- ops_beneath->mourn_inferior ();
+ beneath ()->mourn_inferior ();
spu_multiarch_deactivate ();
}
return inf->gdbarch;
}
-/*
- * Find the next target down the stack from the specified target.
- */
-
-struct target_ops *
-find_target_beneath (struct target_ops *t)
-{
- return t->beneath ();
-}
-
/* See target.h. */
struct target_ops *
extern void target_require_runnable (void);
-extern struct target_ops *find_target_beneath (struct target_ops *);
-
/* Find the target at STRATUM. If no target is at that stratum,
return NULL. */