diff options
author | Pedro Alves <palves@redhat.com> | 2009-02-23 00:03:50 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2009-02-23 00:03:50 +0000 |
commit | 28439f5ef78fd28c36bfc8c4b262f44fdd1ec40f (patch) | |
tree | 934b4ad794cc0be293b8527c0cf954f0fa9f88cf /gdb/procfs.c | |
parent | f05219476dd474da91cfa19ceeab27212c6acf91 (diff) | |
download | binutils-28439f5ef78fd28c36bfc8c4b262f44fdd1ec40f.zip binutils-28439f5ef78fd28c36bfc8c4b262f44fdd1ec40f.tar.gz binutils-28439f5ef78fd28c36bfc8c4b262f44fdd1ec40f.tar.bz2 |
* 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.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r-- | gdb/procfs.c | 190 |
1 files changed, 68 insertions, 122 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c index bc49ffe..c4b6b55 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -29,6 +29,7 @@ #include "gdbcmd.h" #include "gdbthread.h" #include "regcache.h" +#include "inf-child.h" #if defined (NEW_PROC_API) #define _STRUCTURED_PROC 1 /* Should be done by configure script. */ @@ -111,17 +112,17 @@ * This module defines the GDB target vector and its methods. */ -static void procfs_open (char *, int); static void procfs_attach (struct target_ops *, char *, int); static void procfs_detach (struct target_ops *, char *, int); -static void procfs_resume (ptid_t, int, enum target_signal); -static int procfs_can_run (void); +static void procfs_resume (struct target_ops *, + ptid_t, int, enum target_signal); static void procfs_stop (ptid_t); static void procfs_files_info (struct target_ops *); -static void procfs_fetch_registers (struct regcache *, int); -static void procfs_store_registers (struct regcache *, int); +static void procfs_fetch_registers (struct target_ops *, + struct regcache *, int); +static void procfs_store_registers (struct target_ops *, + struct regcache *, int); static void procfs_notice_signals (ptid_t); -static void procfs_prepare_to_store (struct regcache *); static void procfs_kill_inferior (void); static void procfs_mourn_inferior (struct target_ops *ops); static void procfs_create_inferior (struct target_ops *, char *, @@ -137,9 +138,9 @@ static LONGEST procfs_xfer_partial (struct target_ops *ops, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len); -static int procfs_thread_alive (ptid_t); +static int procfs_thread_alive (struct target_ops *ops, ptid_t); -void procfs_find_new_threads (void); +void procfs_find_new_threads (struct target_ops *ops); char *procfs_pid_to_str (struct target_ops *, ptid_t); static int proc_find_memory_regions (int (*) (CORE_ADDR, @@ -152,8 +153,6 @@ static char * procfs_make_note_section (bfd *, int *); static int procfs_can_use_hw_breakpoint (int, int, int); -struct target_ops procfs_ops; /* the target vector */ - #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) /* When GDB is built as 64-bit application on Solaris, the auxv data is presented in 64-bit format. We need to provide a custom parser to handle @@ -182,60 +181,46 @@ procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr, } #endif -static void -init_procfs_ops (void) +static struct target_ops * +procfs_target (void) { - procfs_ops.to_shortname = "procfs"; - procfs_ops.to_longname = "Unix /proc child process"; - procfs_ops.to_doc = + struct target_ops *t = inf_child_target (); + + t->to_shortname = "procfs"; + t->to_longname = "Unix /proc child process"; + t->to_doc = "Unix /proc child process (started by the \"run\" command)."; - procfs_ops.to_open = procfs_open; - procfs_ops.to_can_run = procfs_can_run; - procfs_ops.to_create_inferior = procfs_create_inferior; - procfs_ops.to_kill = procfs_kill_inferior; - procfs_ops.to_mourn_inferior = procfs_mourn_inferior; - procfs_ops.to_attach = procfs_attach; - procfs_ops.to_detach = procfs_detach; - procfs_ops.to_wait = procfs_wait; - procfs_ops.to_resume = procfs_resume; - procfs_ops.to_prepare_to_store = procfs_prepare_to_store; - procfs_ops.to_fetch_registers = procfs_fetch_registers; - procfs_ops.to_store_registers = procfs_store_registers; - procfs_ops.to_xfer_partial = procfs_xfer_partial; - procfs_ops.deprecated_xfer_memory = procfs_xfer_memory; - procfs_ops.to_insert_breakpoint = memory_insert_breakpoint; - procfs_ops.to_remove_breakpoint = memory_remove_breakpoint; - procfs_ops.to_notice_signals = procfs_notice_signals; - procfs_ops.to_files_info = procfs_files_info; - procfs_ops.to_stop = procfs_stop; - - procfs_ops.to_terminal_init = terminal_init_inferior; - procfs_ops.to_terminal_inferior = terminal_inferior; - procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output; - procfs_ops.to_terminal_ours = terminal_ours; - procfs_ops.to_terminal_save_ours = terminal_save_ours; - procfs_ops.to_terminal_info = child_terminal_info; - - procfs_ops.to_find_new_threads = procfs_find_new_threads; - procfs_ops.to_thread_alive = procfs_thread_alive; - procfs_ops.to_pid_to_str = procfs_pid_to_str; - - procfs_ops.to_has_all_memory = 1; - procfs_ops.to_has_memory = 1; - procfs_ops.to_has_execution = 1; - procfs_ops.to_has_stack = 1; - procfs_ops.to_has_registers = 1; - procfs_ops.to_stratum = process_stratum; - procfs_ops.to_has_thread_control = tc_schedlock; - procfs_ops.to_find_memory_regions = proc_find_memory_regions; - procfs_ops.to_make_corefile_notes = procfs_make_note_section; - procfs_ops.to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; + t->to_create_inferior = procfs_create_inferior; + t->to_kill = procfs_kill_inferior; + t->to_mourn_inferior = procfs_mourn_inferior; + t->to_attach = procfs_attach; + t->to_detach = procfs_detach; + t->to_wait = procfs_wait; + t->to_resume = procfs_resume; + t->to_fetch_registers = procfs_fetch_registers; + t->to_store_registers = procfs_store_registers; + t->to_xfer_partial = procfs_xfer_partial; + t->deprecated_xfer_memory = procfs_xfer_memory; + t->to_notice_signals = procfs_notice_signals; + t->to_files_info = procfs_files_info; + t->to_stop = procfs_stop; + + t->to_find_new_threads = procfs_find_new_threads; + t->to_thread_alive = procfs_thread_alive; + t->to_pid_to_str = procfs_pid_to_str; + + t->to_has_thread_control = tc_schedlock; + t->to_find_memory_regions = proc_find_memory_regions; + t->to_make_corefile_notes = procfs_make_note_section; + t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) - procfs_ops.to_auxv_parse = procfs_auxv_parse; + t->to_auxv_parse = procfs_auxv_parse; #endif - procfs_ops.to_magic = OPS_MAGIC; + t->to_magic = OPS_MAGIC; + + return t; } /* =================== END, TARGET_OPS "MODULE" =================== */ @@ -3630,7 +3615,7 @@ procfs_attach (struct target_ops *ops, char *args, int from_tty) fflush (stdout); } inferior_ptid = do_attach (pid_to_ptid (pid)); - push_target (&procfs_ops); + push_target (ops); } static void @@ -3659,7 +3644,7 @@ procfs_detach (struct target_ops *ops, char *args, int from_tty) inferior_ptid = null_ptid; detach_inferior (pid); - unpush_target (&procfs_ops); + unpush_target (ops); } static ptid_t @@ -3790,7 +3775,8 @@ do_detach (int signo) when the process is resumed. */ static void -procfs_fetch_registers (struct regcache *regcache, int regnum) +procfs_fetch_registers (struct target_ops *ops, + struct regcache *regcache, int regnum) { gdb_gregset_t *gregs; procinfo *pi; @@ -3827,17 +3813,6 @@ procfs_fetch_registers (struct regcache *regcache, int regnum) } } -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On - machines which store all the registers in one fell swoop, such as - /proc, this makes sure that registers contains all the registers - from the program being debugged. */ - -static void -procfs_prepare_to_store (struct regcache *regcache) -{ -} - /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers. @@ -3849,7 +3824,8 @@ procfs_prepare_to_store (struct regcache *regcache) writing one register might affect the value of others, etc. */ static void -procfs_store_registers (struct regcache *regcache, int regnum) +procfs_store_registers (struct target_ops *ops, + struct regcache *regcache, int regnum) { gdb_gregset_t *gregs; procinfo *pi; @@ -4564,7 +4540,8 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr) */ static void -procfs_resume (ptid_t ptid, int step, enum target_signal signo) +procfs_resume (struct target_ops *ops, + ptid_t ptid, int step, enum target_signal signo) { procinfo *pi, *thread; int native_signo; @@ -4701,44 +4678,6 @@ procfs_files_info (struct target_ops *ignore) } /* - * Function: target_open - * - * A dummy: you don't open procfs. - */ - -static void -procfs_open (char *args, int from_tty) -{ - error (_("Use the \"run\" command to start a Unix child process.")); -} - -/* - * Function: target_can_run - * - * This tells GDB that this target vector can be invoked - * for "run" or "attach". - */ - -int procfs_suppress_run = 0; /* Non-zero if procfs should pretend not to - be a runnable target. Used by targets - that can sit atop procfs, such as solaris - thread support. */ - - -static int -procfs_can_run (void) -{ - /* This variable is controlled by modules that sit atop procfs that - may layer their own process structure atop that provided here. - sol-thread.c does this because of the Solaris two-level thread - model. */ - - /* NOTE: possibly obsolete -- use the thread_stratum approach instead. */ - - return !procfs_suppress_run; -} - -/* * Function: target_stop * * Stop the child process asynchronously, as when the @@ -4856,7 +4795,7 @@ procfs_mourn_inferior (struct target_ops *ops) if (pi) destroy_procinfo (pi); } - unpush_target (&procfs_ops); + unpush_target (ops); if (dbx_link_bpt != NULL) { @@ -4878,7 +4817,7 @@ procfs_mourn_inferior (struct target_ops *ops) */ static void -procfs_init_inferior (int pid) +procfs_init_inferior (struct target_ops *ops, int pid) { procinfo *pi; gdb_sigset_t signals; @@ -4887,8 +4826,7 @@ procfs_init_inferior (int pid) /* This routine called on the parent side (GDB side) after GDB forks the inferior. */ - - push_target (&procfs_ops); + push_target (ops); if ((pi = create_procinfo (pid, 0)) == NULL) perror ("procfs: out of memory in 'init_inferior'"); @@ -5119,6 +5057,8 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file, { char *shell_file = getenv ("SHELL"); char *tryname; + int pid; + if (shell_file != NULL && strchr (shell_file, '/') == NULL) { @@ -5187,8 +5127,10 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file, shell_file = tryname; } - fork_inferior (exec_file, allargs, env, procfs_set_exec_trap, - procfs_init_inferior, NULL, shell_file); + pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap, + NULL, NULL, shell_file); + + procfs_init_inferior (ops, pid); #ifdef SYS_syssgi /* Make sure to cancel the syssgi() syscall-exit notifications. @@ -5227,7 +5169,7 @@ procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr) */ void -procfs_find_new_threads (void) +procfs_find_new_threads (struct target_ops *ops) { procinfo *pi; @@ -5247,7 +5189,7 @@ procfs_find_new_threads (void) */ static int -procfs_thread_alive (ptid_t ptid) +procfs_thread_alive (struct target_ops *ops, ptid_t ptid) { int proc, thread; procinfo *pi; @@ -6024,8 +5966,12 @@ proc_untrace_sysexit_cmd (char *args, int from_tty) void _initialize_procfs (void) { - init_procfs_ops (); - add_target (&procfs_ops); + struct target_ops * t; + + t = procfs_target (); + + add_target (t); + add_info ("proc", info_proc_cmd, _("\ Show /proc process information about any running process.\n\ Specify process id, or use the program being debugged by default.\n\ |