* corelow.c (get_core_registers): Adjust.

(core_file_thread_alive): Rename to...
	(core_thread_alive): ... this.
	(core_pid_to_str): Try gdbarch_core_pid_to_str first.
	(init_core_ops): Adjust.
	(coreops_suppress_target): Delete.
	(_initialize_corelow): Unconditionally add core_ops.
	* procfs.c: Include "inf-child.h".
	(procfs_ops): Delete.
	(init_procfs_ops): Delete.  Reimplement as...
	(procfs_target): ... this, inheriting from inf-child.
	(procfs_attach, procfs_detach, procfs_fetch_registers): Adjust.
	(procfs_prepare_to_store): Delete.
	(procfs_store_registers, procfs_resume): Adjust.
	(procfs_open): Delete.
	(procfs_suppress_run): Delete.
	(procfs_can_run): Delete.
	(procfs_mourn_inferior): Adjust.
	(procfs_init_inferior): Add target_ops parameter.  Adjust.
	(procfs_create_inferior): Don't pass procfs_init_inferior to
	fork_inferior.  Instead call it after fork_inferior returns.
	(procfs_find_new_threads): Adjust.
	(_initialize_procfs): Adjust to use procfs_target instead of
	init_procfs_ops.
	* sol-thread.c (orig_core_ops, sol_core_ops): Delete.
	(lwp_to_thread): Use target_thread_alive.
	(sol_thread_open): Delete.
	(sol_thread_attach): Delete.
	(sol_thread_detach, sol_thread_resume, sol_thread_wait)
	(sol_thread_fetch_registers, sol_thread_store_registers): Adjust
	to use find_target_beneath.
	(sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete.
	(sol_thread_xfer_partial): Adjust to use find_target_beneath.
	(sol_thread_files_info, sol_thread_kill_inferior): Delete.
	(check_for_thread_db): New.
	(sol_thread_notice_signals, sol_thread_create_inferior): Delete.
	(sol_thread_new_objfile): Call check_for_thread_db.
	(sol_thread_mourn_inferior): Adjust to use find_target_beneath.
	(sol_thread_can_run): Delete.
	(sol_thread_alive): Adjust to use find_target_beneath.
	(sol_thread_stop): Delete.
	(rw_common): Use target_write_memory or target_read_memory.
	(ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers.
	(ps_lsetregs, ps_lsetfpregs): Use target_store_registers.
	(solaris_pid_to_str): Remove check for libthread_db initialization
	failing.
	(sol_find_new_threads): Remove check for libthread_db
	initialization failing, or for an invalid inferior_ptid.  Adjust
	to use find_target_beneath.
	(sol_core_open, sol_core_close, sol_core_detach,
	sol_core_files_info, sol_find_memory_regions,
	sol_make_note_section, ignore): Delete.
	(init_sol_thread_ops): Make it a thread_stratum target.  Remove
	unneeded callback settings.
	(init_sol_core_ops): Delete.
	(_initialize_sol_thread): No longer call init_sol_core_ops, set
	procfs_suppress_run, or hack with core_ops.

	* target.h (struct target_ops): Add a target_ops * parameter to
	to_resume, to_fetch_registers, to_store_registers, to_thread_alive
	and to_find_new_threads.
	(target_fetch_registers, target_store_registers)
	(target_thread_alive, target_find_new_threads): Redeclare as
	function.

	* target.c (update_current_target): Do not inherit or de_fault
	to_resume, to_fetch_registers, to_store_registers,
	to_thread_alive, to_find_new_threads.
	(target_resume): Adjust.
	(target_thread_alive, target_find_new_threads): New.
	(debug_to_resume, debug_to_fetch_registers): Delete.
	(target_fetch_registers): New.
	(debug_to_store_registers): Delete.
	(target_store_registers): New.
	(debug_to_thread_alive, debug_to_find_new_threads): Delete.
	(setup_target_debug): Adjust.

	* gdbcore.h (core_ops): Delete declaration.

	* inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c,
	inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c,
	i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c,
	hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c,
	nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c,
	alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c,
	bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c,
	hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c,
	ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c,
	m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c,
	mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c,
	ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c,
	shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c,
	vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes.

	* gdbarch.sh (core_pid_to_str): New gdbarch callback.
	* gdbarch.h, gdbarch.c: Regenerate.

	* sol2-tdep.c: Include "inferior.h".
	(sol2_core_pid_to_str): New.
	* sol2-tdep.h (sol2_core_pid_to_str): Declare.

	* amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it.
	* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it.
	* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it.
	* i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
This commit is contained in:
Pedro Alves 2009-02-23 00:03:50 +00:00
parent f05219476d
commit 28439f5ef7
66 changed files with 801 additions and 906 deletions

View file

@ -97,12 +97,6 @@ static struct target_ops debug_target;
static void debug_to_open (char *, int);
static void debug_to_resume (ptid_t, int, enum target_signal);
static void debug_to_fetch_registers (struct regcache *, int);
static void debug_to_store_registers (struct regcache *, int);
static void debug_to_prepare_to_store (struct regcache *);
static void debug_to_files_info (struct target_ops *);
@ -152,8 +146,6 @@ static int debug_to_can_run (void);
static void debug_to_notice_signals (ptid_t);
static int debug_to_thread_alive (ptid_t);
static void debug_to_stop (ptid_t);
/* NOTE: cagney/2004-09-29: Many targets reference this variable in
@ -412,10 +404,10 @@ update_current_target (void)
INHERIT (to_attach_no_wait, t);
/* Do not inherit to_detach. */
/* Do not inherit to_disconnect. */
INHERIT (to_resume, t);
/* Do not inherit to_resume. */
/* Do not inherit to_wait. */
INHERIT (to_fetch_registers, t);
INHERIT (to_store_registers, t);
/* Do not inherit to_fetch_registers. */
/* Do not inherit to_store_registers. */
INHERIT (to_prepare_to_store, t);
INHERIT (deprecated_xfer_memory, t);
INHERIT (to_files_info, t);
@ -455,8 +447,8 @@ update_current_target (void)
/* Do not inherit to_mourn_inferiour. */
INHERIT (to_can_run, t);
INHERIT (to_notice_signals, t);
INHERIT (to_thread_alive, t);
INHERIT (to_find_new_threads, t);
/* Do not inherit to_thread_alive. */
/* Do not inherit to_find_new_threads. */
/* Do not inherit to_pid_to_str. */
INHERIT (to_extra_thread_info, t);
INHERIT (to_stop, t);
@ -509,15 +501,6 @@ update_current_target (void)
de_fault (to_post_attach,
(void (*) (int))
target_ignore);
de_fault (to_resume,
(void (*) (ptid_t, int, enum target_signal))
noprocess);
de_fault (to_fetch_registers,
(void (*) (struct regcache *, int))
target_ignore);
de_fault (to_store_registers,
(void (*) (struct regcache *, int))
noprocess);
de_fault (to_prepare_to_store,
(void (*) (struct regcache *))
noprocess);
@ -614,12 +597,6 @@ update_current_target (void)
de_fault (to_notice_signals,
(void (*) (ptid_t))
target_ignore);
de_fault (to_thread_alive,
(int (*) (ptid_t))
return_zero);
de_fault (to_find_new_threads,
(void (*) (void))
target_ignore);
de_fault (to_extra_thread_info,
(char *(*) (struct thread_info *))
return_zero);
@ -1892,10 +1869,28 @@ target_pid_to_str (ptid_t ptid)
void
target_resume (ptid_t ptid, int step, enum target_signal signal)
{
struct target_ops *t;
dcache_invalidate (target_dcache);
(*current_target.to_resume) (ptid, step, signal);
set_executing (ptid, 1);
set_running (ptid, 1);
for (t = current_target.beneath; t != NULL; t = t->beneath)
{
if (t->to_resume != NULL)
{
t->to_resume (t, ptid, step, signal);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n",
PIDGET (ptid),
step ? "step" : "continue",
target_signal_to_name (signal));
set_executing (ptid, 1);
set_running (ptid, 1);
return;
}
}
noprocess ();
}
/* Look through the list of possible targets for a target that can
follow forks. */
@ -2607,6 +2602,45 @@ target_attach (char *args, int from_tty)
"could not find a target to attach");
}
int
target_thread_alive (ptid_t ptid)
{
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
{
if (t->to_thread_alive != NULL)
{
int retval;
retval = t->to_thread_alive (t, ptid);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
PIDGET (ptid), retval);
return retval;
}
}
return 0;
}
void
target_find_new_threads (void)
{
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
{
if (t->to_find_new_threads != NULL)
{
t->to_find_new_threads (t);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_find_new_threads ()\n");
return;
}
}
}
static void
debug_to_post_attach (int pid)
{
@ -2615,16 +2649,6 @@ debug_to_post_attach (int pid)
fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
}
static void
debug_to_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
debug_target.to_resume (ptid, step, siggnal);
fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", PIDGET (ptid),
step ? "step" : "continue",
target_signal_to_name (siggnal));
}
/* Return a pretty printed form of target_waitstatus.
Space for the result is malloc'd, caller must free. */
@ -2700,19 +2724,41 @@ debug_print_register (const char * func,
fprintf_unfiltered (gdb_stdlog, "\n");
}
static void
debug_to_fetch_registers (struct regcache *regcache, int regno)
void
target_fetch_registers (struct regcache *regcache, int regno)
{
debug_target.to_fetch_registers (regcache, regno);
debug_print_register ("target_fetch_registers", regcache, regno);
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
{
if (t->to_fetch_registers != NULL)
{
t->to_fetch_registers (t, regcache, regno);
if (targetdebug)
debug_print_register ("target_fetch_registers", regcache, regno);
return;
}
}
}
static void
debug_to_store_registers (struct regcache *regcache, int regno)
void
target_store_registers (struct regcache *regcache, int regno)
{
debug_target.to_store_registers (regcache, regno);
debug_print_register ("target_store_registers", regcache, regno);
fprintf_unfiltered (gdb_stdlog, "\n");
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
{
if (t->to_store_registers != NULL)
{
t->to_store_registers (t, regcache, regno);
if (targetdebug)
{
debug_print_register ("target_store_registers", regcache, regno);
}
return;
}
}
noprocess ();
}
static void
@ -3124,27 +3170,6 @@ debug_to_notice_signals (ptid_t ptid)
PIDGET (ptid));
}
static int
debug_to_thread_alive (ptid_t ptid)
{
int retval;
retval = debug_target.to_thread_alive (ptid);
fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
PIDGET (ptid), retval);
return retval;
}
static void
debug_to_find_new_threads (void)
{
debug_target.to_find_new_threads ();
fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog);
}
static void
debug_to_stop (ptid_t ptid)
{
@ -3182,9 +3207,6 @@ setup_target_debug (void)
current_target.to_open = debug_to_open;
current_target.to_post_attach = debug_to_post_attach;
current_target.to_resume = debug_to_resume;
current_target.to_fetch_registers = debug_to_fetch_registers;
current_target.to_store_registers = debug_to_store_registers;
current_target.to_prepare_to_store = debug_to_prepare_to_store;
current_target.deprecated_xfer_memory = deprecated_debug_xfer_memory;
current_target.to_files_info = debug_to_files_info;
@ -3219,8 +3241,6 @@ setup_target_debug (void)
current_target.to_has_exited = debug_to_has_exited;
current_target.to_can_run = debug_to_can_run;
current_target.to_notice_signals = debug_to_notice_signals;
current_target.to_thread_alive = debug_to_thread_alive;
current_target.to_find_new_threads = debug_to_find_new_threads;
current_target.to_stop = debug_to_stop;
current_target.to_rcmd = debug_to_rcmd;
current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;