2004-11-21 21:51:53 +08:00
|
|
|
|
/* Low-level child interface to ptrace.
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
2007-01-10 01:59:20 +08:00
|
|
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
|
|
|
|
|
1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
|
2005-01-11 04:36:38 +08:00
|
|
|
|
Free Software Foundation, Inc.
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-12-18 06:34:03 +08:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "command.h"
|
2004-11-21 21:51:53 +08:00
|
|
|
|
#include "inferior.h"
|
|
|
|
|
#include "inflow.h"
|
2004-09-12 21:04:41 +08:00
|
|
|
|
#include "gdbcore.h"
|
2005-01-11 04:36:38 +08:00
|
|
|
|
#include "regcache.h"
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
2005-01-11 04:36:38 +08:00
|
|
|
|
#include "gdb_assert.h"
|
2004-11-21 21:51:53 +08:00
|
|
|
|
#include "gdb_string.h"
|
|
|
|
|
#include "gdb_ptrace.h"
|
2004-10-15 21:29:33 +08:00
|
|
|
|
#include "gdb_wait.h"
|
2004-09-12 21:04:41 +08:00
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
2004-11-21 21:51:53 +08:00
|
|
|
|
#include "inf-child.h"
|
|
|
|
|
|
|
|
|
|
/* HACK: Save the ptrace ops returned by inf_ptrace_target. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
static struct target_ops *ptrace_ops_hack;
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
|
|
|
|
|
|
2005-07-26 05:11:02 +08:00
|
|
|
|
#ifdef PT_GET_PROCESS_STATE
|
|
|
|
|
|
|
|
|
|
static int
|
2005-09-05 00:18:20 +08:00
|
|
|
|
inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
|
2005-07-26 05:11:02 +08:00
|
|
|
|
{
|
|
|
|
|
pid_t pid, fpid;
|
|
|
|
|
ptrace_state_t pe;
|
|
|
|
|
|
|
|
|
|
/* FIXME: kettenis/20050720: This stuff should really be passed as
|
|
|
|
|
an argument by our caller. */
|
|
|
|
|
{
|
|
|
|
|
ptid_t ptid;
|
|
|
|
|
struct target_waitstatus status;
|
|
|
|
|
|
|
|
|
|
get_last_target_status (&ptid, &status);
|
|
|
|
|
gdb_assert (status.kind == TARGET_WAITKIND_FORKED);
|
|
|
|
|
|
|
|
|
|
pid = ptid_get_pid (ptid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ptrace (PT_GET_PROCESS_STATE, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
|
|
|
|
|
gdb_assert (pe.pe_report_event == PTRACE_FORK);
|
|
|
|
|
fpid = pe.pe_other_pid;
|
|
|
|
|
|
|
|
|
|
if (follow_child)
|
|
|
|
|
{
|
|
|
|
|
inferior_ptid = pid_to_ptid (fpid);
|
|
|
|
|
detach_breakpoints (pid);
|
|
|
|
|
|
|
|
|
|
/* Reset breakpoints in the child as appropriate. */
|
|
|
|
|
follow_inferior_reset_breakpoints ();
|
|
|
|
|
|
|
|
|
|
if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inferior_ptid = pid_to_ptid (pid);
|
|
|
|
|
detach_breakpoints (fpid);
|
|
|
|
|
|
|
|
|
|
if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* PT_GET_PROCESS_STATE */
|
|
|
|
|
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Prepare to be traced. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static void
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
inf_ptrace_me (void)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
/* "Trace me, Dr. Memory!" */
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Start tracing PID. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static void
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
inf_ptrace_him (int pid)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
push_target (ptrace_ops_hack);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
/* On some targets, there must be some explicit synchronization
|
|
|
|
|
between the parent and child processes after the debugger
|
|
|
|
|
forks, and before the child execs the debuggee program. This
|
|
|
|
|
call basically gives permission for the child to exec. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
target_acknowledge_created_inferior (pid);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
/* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h, and will
|
|
|
|
|
be 1 or 2 depending on whether we're starting without or with a
|
|
|
|
|
shell. */
|
|
|
|
|
startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
|
|
|
|
|
|
|
|
|
|
/* On some targets, there must be some explicit actions taken after
|
|
|
|
|
the inferior has been started up. */
|
|
|
|
|
target_post_startup_inferior (pid_to_ptid (pid));
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Start a new inferior Unix child process. EXEC_FILE is the file to
|
|
|
|
|
run, ALLARGS is a string containing the arguments to the program.
|
|
|
|
|
ENV is the environment vector to pass. If FROM_TTY is non-zero, be
|
|
|
|
|
chatty about it. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_create_inferior (char *exec_file, char *allargs, char **env,
|
|
|
|
|
int from_tty)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
fork_inferior (exec_file, allargs, env, inf_ptrace_me, inf_ptrace_him,
|
|
|
|
|
NULL, NULL);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:23:35 +08:00
|
|
|
|
#ifdef PT_GET_PROCESS_STATE
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_post_startup_inferior (ptid_t pid)
|
|
|
|
|
{
|
|
|
|
|
ptrace_event_t pe;
|
|
|
|
|
|
|
|
|
|
/* Set the initial event mask. */
|
|
|
|
|
memset (&pe, 0, sizeof pe);
|
|
|
|
|
pe.pe_set_event |= PTRACE_FORK;
|
|
|
|
|
if (ptrace (PT_SET_EVENT_MASK, ptid_get_pid (pid),
|
|
|
|
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Clean up a rotting corpse of an inferior after it died. */
|
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_mourn_inferior (void)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
/* Wait just one more time to collect the inferior's exit status.
|
2005-12-07 06:05:51 +08:00
|
|
|
|
Do not check whether this succeeds though, since we may be
|
2005-07-26 04:42:29 +08:00
|
|
|
|
dealing with a process that we attached to. Such a process will
|
2005-12-24 04:51:35 +08:00
|
|
|
|
only report its exit status to its original parent. */
|
2005-07-26 04:42:29 +08:00
|
|
|
|
waitpid (ptid_get_pid (inferior_ptid), &status, 0);
|
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
unpush_target (ptrace_ops_hack);
|
|
|
|
|
generic_mourn_inferior ();
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Attach to the process specified by ARGS. If FROM_TTY is non-zero,
|
|
|
|
|
be chatty about it. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_attach (char *args, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
char *exec_file;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid;
|
2004-09-12 21:04:41 +08:00
|
|
|
|
char *dummy;
|
|
|
|
|
|
|
|
|
|
if (!args)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
error_no_arg (_("process-id to attach"));
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
dummy = args;
|
|
|
|
|
pid = strtol (args, &dummy, 0);
|
2004-11-21 01:03:38 +08:00
|
|
|
|
/* Some targets don't set errno on errors, grrr! */
|
2004-09-25 20:32:01 +08:00
|
|
|
|
if (pid == 0 && args == dummy)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("Illegal process-id: %s."), args);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
2004-11-21 01:03:38 +08:00
|
|
|
|
if (pid == getpid ()) /* Trying to masturbate? */
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("I refuse to debug myself!"));
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
if (from_tty)
|
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
exec_file = get_exec_file (0);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
if (exec_file)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
|
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
|
2004-09-12 21:04:41 +08:00
|
|
|
|
target_pid_to_str (pid_to_ptid (pid)));
|
|
|
|
|
else
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
|
printf_unfiltered (_("Attaching to %s\n"),
|
2004-09-12 21:04:41 +08:00
|
|
|
|
target_pid_to_str (pid_to_ptid (pid)));
|
|
|
|
|
|
|
|
|
|
gdb_flush (gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:32:01 +08:00
|
|
|
|
#ifdef PT_ATTACH
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0);
|
2004-09-25 20:32:01 +08:00
|
|
|
|
if (errno != 0)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
perror_with_name (("ptrace"));
|
2004-09-25 20:32:01 +08:00
|
|
|
|
attach_flag = 1;
|
|
|
|
|
#else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("This system does not support attaching to a process"));
|
2004-09-25 20:32:01 +08:00
|
|
|
|
#endif
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
inferior_ptid = pid_to_ptid (pid);
|
|
|
|
|
push_target (ptrace_ops_hack);
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:23:35 +08:00
|
|
|
|
#ifdef PT_GET_PROCESS_STATE
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
inf_ptrace_post_attach (int pid)
|
|
|
|
|
{
|
|
|
|
|
ptrace_event_t pe;
|
|
|
|
|
|
|
|
|
|
/* Set the initial event mask. */
|
|
|
|
|
memset (&pe, 0, sizeof pe);
|
|
|
|
|
pe.pe_set_event |= PTRACE_FORK;
|
|
|
|
|
if (ptrace (PT_SET_EVENT_MASK, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Detach from the inferior, optionally passing it the signal
|
2005-12-07 06:05:51 +08:00
|
|
|
|
specified by ARGS. If FROM_TTY is non-zero, be chatty about it. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_detach (char *args, int from_tty)
|
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid = ptid_get_pid (inferior_ptid);
|
2004-09-25 20:32:01 +08:00
|
|
|
|
int sig = 0;
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
if (from_tty)
|
|
|
|
|
{
|
|
|
|
|
char *exec_file = get_exec_file (0);
|
|
|
|
|
if (exec_file == 0)
|
|
|
|
|
exec_file = "";
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up some of printf_filtered and printf_unfiltered.
* ada-lang.c, annotate.c, arch-utils.c, breakpoint.c: Update.
* corelow.c, cp-namespace.c, cp-support.c, dcache.c: Update.
* demangle.c, dsrec.c, dwarf2read.c, dwarfread.c: Update.
* event-loop.c, event-top.c, exec.c, f-valprint.c: Update.
* gdbtypes.c, inf-loop.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcmd.c, inflow.c, infrun.c, inftarg.c, language.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, maint.c: Update.
* mdebugread.c, memattr.c, monitor.c, objc-lang.c: Update.
* ocd.c, osabi.c, printcmd.c, procfs.c, regcache.c: Update.
* remote.c, solib-som.c, solib.c, somsolib.c, source.c: Update.
* stack.c, symfile.c, symmisc.c, target.c, thread.c: Update.
* top.c, utils.c, valprint.c, value.c, cli/cli-cmds.c: Update.
* cli/cli-dump.c, cli/cli-logging.c, tui/tui-hooks.c: Update.
* tui/tui-regs.c, tui/tui-win.c: Update.
2005-02-12 08:39:24 +08:00
|
|
|
|
printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
|
2004-09-12 21:04:41 +08:00
|
|
|
|
target_pid_to_str (pid_to_ptid (pid)));
|
|
|
|
|
gdb_flush (gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
if (args)
|
2004-09-25 20:32:01 +08:00
|
|
|
|
sig = atoi (args);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
2004-09-25 20:32:01 +08:00
|
|
|
|
#ifdef PT_DETACH
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* We'd better not have left any breakpoints in the program or it'll
|
2005-12-07 06:05:51 +08:00
|
|
|
|
die when it hits one. Also note that this may only work if we
|
2005-07-26 04:42:29 +08:00
|
|
|
|
previously attached to the inferior. It *might* work if we
|
|
|
|
|
started the process ourselves. */
|
2004-09-25 20:32:01 +08:00
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, sig);
|
2004-09-25 20:32:01 +08:00
|
|
|
|
if (errno != 0)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
perror_with_name (("ptrace"));
|
2004-09-25 20:32:01 +08:00
|
|
|
|
attach_flag = 0;
|
|
|
|
|
#else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
|
error (_("This system does not support detaching from a process"));
|
2004-09-25 20:32:01 +08:00
|
|
|
|
#endif
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
inferior_ptid = null_ptid;
|
|
|
|
|
unpush_target (ptrace_ops_hack);
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Kill the inferior. */
|
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
static void
|
2005-07-26 04:42:29 +08:00
|
|
|
|
inf_ptrace_kill (void)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid = ptid_get_pid (inferior_ptid);
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0);
|
|
|
|
|
waitpid (pid, &status, 0);
|
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
target_mourn_inferior ();
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Stop the inferior. */
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
static void
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
inf_ptrace_stop (void)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Send a SIGINT to the process group. This acts just like the user
|
|
|
|
|
typed a ^C on the controlling terminal. Note that using a
|
|
|
|
|
negative process number in kill() is a System V-ism. The proper
|
|
|
|
|
BSD interface is killpg(). However, all modern BSDs support the
|
|
|
|
|
System V interface too. */
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
kill (-inferior_process_group, SIGINT);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Resume execution of thread PTID, or all threads if PTID is -1. If
|
|
|
|
|
STEP is nonzero, single-step it. If SIGNAL is nonzero, give it
|
|
|
|
|
that signal. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static void
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
inf_ptrace_resume (ptid_t ptid, int step, enum target_signal signal)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid = ptid_get_pid (ptid);
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
int request = PT_CONTINUE;
|
|
|
|
|
|
|
|
|
|
if (pid == -1)
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Resume all threads. Traditionally ptrace() only supports
|
|
|
|
|
single-threaded processes, so simply resume the inferior. */
|
|
|
|
|
pid = ptid_get_pid (inferior_ptid);
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
|
|
|
|
|
if (step)
|
|
|
|
|
{
|
|
|
|
|
/* If this system does not support PT_STEP, a higher level
|
|
|
|
|
function will have called single_step() to transmute the step
|
|
|
|
|
request into a continue request (by setting breakpoints on
|
|
|
|
|
all possible successor instructions), so we don't have to
|
|
|
|
|
worry about that here. */
|
|
|
|
|
request = PT_STEP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* An address of (PTRACE_TYPE_ARG3)1 tells ptrace to continue from
|
|
|
|
|
where it was. If GDB wanted it to start some other way, we have
|
2005-07-26 04:42:29 +08:00
|
|
|
|
already written a new program counter value to the child. */
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (request, pid, (PTRACE_TYPE_ARG3)1, target_signal_to_host (signal));
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
if (errno != 0)
|
|
|
|
|
perror_with_name (("ptrace"));
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Wait for the child specified by PTID to do something. Return the
|
|
|
|
|
process ID of the child, or MINUS_ONE_PTID in case of error; store
|
|
|
|
|
the status in *OURSTATUS. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
static ptid_t
|
|
|
|
|
inf_ptrace_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid;
|
|
|
|
|
int status, save_errno;
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
do
|
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
set_sigint_trap ();
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
set_sigio_trap ();
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
pid = waitpid (ptid_get_pid (ptid), &status, 0);
|
|
|
|
|
save_errno = errno;
|
|
|
|
|
}
|
|
|
|
|
while (pid == -1 && errno == EINTR);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
clear_sigio_trap ();
|
|
|
|
|
clear_sigint_trap ();
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
if (pid == -1)
|
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stderr,
|
2005-07-26 04:42:29 +08:00
|
|
|
|
_("Child process unexpectedly missing: %s.\n"),
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
safe_strerror (save_errno));
|
|
|
|
|
|
|
|
|
|
/* Claim it exited with unknown signal. */
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
|
|
|
|
|
ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
return minus_one_ptid;
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Ignore terminated detached child processes. */
|
|
|
|
|
if (!WIFSTOPPED (status) && pid != ptid_get_pid (inferior_ptid))
|
|
|
|
|
pid = -1;
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
}
|
2005-07-26 04:42:29 +08:00
|
|
|
|
while (pid == -1);
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
|
2005-07-26 05:11:02 +08:00
|
|
|
|
#ifdef PT_GET_PROCESS_STATE
|
|
|
|
|
if (WIFSTOPPED (status))
|
|
|
|
|
{
|
|
|
|
|
ptrace_state_t pe;
|
|
|
|
|
pid_t fpid;
|
|
|
|
|
|
|
|
|
|
if (ptrace (PT_GET_PROCESS_STATE, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
|
|
|
|
|
switch (pe.pe_report_event)
|
|
|
|
|
{
|
|
|
|
|
case PTRACE_FORK:
|
|
|
|
|
ourstatus->kind = TARGET_WAITKIND_FORKED;
|
|
|
|
|
ourstatus->value.related_pid = pe.pe_other_pid;
|
|
|
|
|
|
|
|
|
|
/* Make sure the other end of the fork is stopped too. */
|
|
|
|
|
fpid = waitpid (pe.pe_other_pid, &status, 0);
|
|
|
|
|
if (fpid == -1)
|
|
|
|
|
perror_with_name (("waitpid"));
|
|
|
|
|
|
|
|
|
|
if (ptrace (PT_GET_PROCESS_STATE, fpid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
|
|
|
|
|
perror_with_name (("ptrace"));
|
|
|
|
|
|
|
|
|
|
gdb_assert (pe.pe_report_event == PTRACE_FORK);
|
|
|
|
|
gdb_assert (pe.pe_other_pid == pid);
|
|
|
|
|
if (fpid == ptid_get_pid (inferior_ptid))
|
|
|
|
|
{
|
|
|
|
|
ourstatus->value.related_pid = pe.pe_other_pid;
|
|
|
|
|
return pid_to_ptid (fpid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pid_to_ptid (pid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
store_waitstatus (ourstatus, status);
|
|
|
|
|
return pid_to_ptid (pid);
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Attempt a transfer all LEN bytes starting at OFFSET between the
|
|
|
|
|
inferior's OBJECT:ANNEX space and GDB's READBUF/WRITEBUF buffer.
|
|
|
|
|
Return the number of bytes actually transferred. */
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
|
inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
|
2005-05-17 00:36:24 +08:00
|
|
|
|
const char *annex, gdb_byte *readbuf,
|
|
|
|
|
const gdb_byte *writebuf,
|
|
|
|
|
ULONGEST offset, LONGEST len)
|
2004-09-12 21:04:41 +08:00
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
pid_t pid = ptid_get_pid (inferior_ptid);
|
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
switch (object)
|
|
|
|
|
{
|
|
|
|
|
case TARGET_OBJECT_MEMORY:
|
2004-09-30 23:47:30 +08:00
|
|
|
|
#ifdef PT_IO
|
|
|
|
|
/* OpenBSD 3.1, NetBSD 1.6 and FreeBSD 5.0 have a new PT_IO
|
|
|
|
|
request that promises to be much more efficient in reading
|
|
|
|
|
and writing data in the traced process's address space. */
|
|
|
|
|
{
|
|
|
|
|
struct ptrace_io_desc piod;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
/* NOTE: We assume that there are no distinct address spaces
|
2005-11-21 17:11:44 +08:00
|
|
|
|
for instruction and data. However, on OpenBSD 3.9 and
|
|
|
|
|
later, PIOD_WRITE_D doesn't allow changing memory that's
|
|
|
|
|
mapped read-only. Since most code segments will be
|
|
|
|
|
read-only, using PIOD_WRITE_D will prevent us from
|
|
|
|
|
inserting breakpoints, so we use PIOD_WRITE_I instead. */
|
|
|
|
|
piod.piod_op = writebuf ? PIOD_WRITE_I : PIOD_READ_D;
|
2004-09-30 23:47:30 +08:00
|
|
|
|
piod.piod_addr = writebuf ? (void *) writebuf : readbuf;
|
|
|
|
|
piod.piod_offs = (void *) (long) offset;
|
|
|
|
|
piod.piod_len = len;
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
|
2004-09-30 23:47:30 +08:00
|
|
|
|
/* Return the actual number of bytes read or written. */
|
|
|
|
|
return piod.piod_len;
|
|
|
|
|
/* If the PT_IO request is somehow not supported, fallback on
|
|
|
|
|
using PT_WRITE_D/PT_READ_D. Otherwise we will return zero
|
|
|
|
|
to indicate failure. */
|
|
|
|
|
if (errno != EINVAL)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
PTRACE_TYPE_RET word;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
gdb_byte byte[sizeof (PTRACE_TYPE_RET)];
|
2004-09-30 23:47:30 +08:00
|
|
|
|
} buffer;
|
|
|
|
|
ULONGEST rounded_offset;
|
|
|
|
|
LONGEST partial_len;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-10-02 00:12:26 +08:00
|
|
|
|
/* Round the start offset down to the next long word
|
|
|
|
|
boundary. */
|
2004-09-30 23:47:30 +08:00
|
|
|
|
rounded_offset = offset & -(ULONGEST) sizeof (PTRACE_TYPE_RET);
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-10-02 00:12:26 +08:00
|
|
|
|
/* Since ptrace will transfer a single word starting at that
|
|
|
|
|
rounded_offset the partial_len needs to be adjusted down to
|
|
|
|
|
that (remember this function only does a single transfer).
|
|
|
|
|
Should the required length be even less, adjust it down
|
|
|
|
|
again. */
|
|
|
|
|
partial_len = (rounded_offset + sizeof (PTRACE_TYPE_RET)) - offset;
|
|
|
|
|
if (partial_len > len)
|
2004-09-30 23:47:30 +08:00
|
|
|
|
partial_len = len;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (writebuf)
|
|
|
|
|
{
|
2004-10-02 00:12:26 +08:00
|
|
|
|
/* If OFFSET:PARTIAL_LEN is smaller than
|
|
|
|
|
ROUNDED_OFFSET:WORDSIZE then a read/modify write will
|
|
|
|
|
be needed. Read in the entire word. */
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (rounded_offset < offset
|
2004-10-02 00:12:26 +08:00
|
|
|
|
|| (offset + partial_len
|
|
|
|
|
< rounded_offset + sizeof (PTRACE_TYPE_RET)))
|
2004-09-30 23:47:30 +08:00
|
|
|
|
/* Need part of initial word -- fetch it. */
|
2005-07-26 04:42:29 +08:00
|
|
|
|
buffer.word = ptrace (PT_READ_I, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)(long)rounded_offset, 0);
|
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
/* Copy data to be written over corresponding part of
|
|
|
|
|
buffer. */
|
2004-11-21 01:03:38 +08:00
|
|
|
|
memcpy (buffer.byte + (offset - rounded_offset),
|
|
|
|
|
writebuf, partial_len);
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_WRITE_D, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)(long)rounded_offset, buffer.word);
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (errno)
|
|
|
|
|
{
|
|
|
|
|
/* Using the appropriate one (I or D) is necessary for
|
|
|
|
|
Gould NP1, at least. */
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_WRITE_I, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)(long)rounded_offset, buffer.word);
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (errno)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (readbuf)
|
|
|
|
|
{
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
buffer.word = ptrace (PT_READ_I, pid,
|
|
|
|
|
(PTRACE_TYPE_ARG3)(long)rounded_offset, 0);
|
2004-09-30 23:47:30 +08:00
|
|
|
|
if (errno)
|
|
|
|
|
return 0;
|
|
|
|
|
/* Copy appropriate bytes out of the buffer. */
|
|
|
|
|
memcpy (readbuf, buffer.byte + (offset - rounded_offset),
|
|
|
|
|
partial_len);
|
|
|
|
|
}
|
2005-07-26 04:42:29 +08:00
|
|
|
|
|
2004-09-30 23:47:30 +08:00
|
|
|
|
return partial_len;
|
|
|
|
|
}
|
2004-09-12 21:04:41 +08:00
|
|
|
|
|
|
|
|
|
case TARGET_OBJECT_UNWIND_TABLE:
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
case TARGET_OBJECT_AUXV:
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
case TARGET_OBJECT_WCOOKIE:
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Return non-zero if the thread specified by PTID is alive. */
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
inf_ptrace_thread_alive (ptid_t ptid)
|
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* ??? Is kill the right way to do this? */
|
|
|
|
|
return (kill (ptid_get_pid (ptid), 0) != -1);
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print status information about what we're accessing. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_files_info (struct target_ops *ignore)
|
|
|
|
|
{
|
2005-07-26 04:42:29 +08:00
|
|
|
|
printf_filtered (_("\tUsing the running image of %s %s.\n"),
|
|
|
|
|
attach_flag ? "attached" : "child",
|
|
|
|
|
target_pid_to_str (inferior_ptid));
|
2004-09-12 21:04:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-01-11 04:36:38 +08:00
|
|
|
|
/* Create a prototype ptrace target. The client can override it with
|
|
|
|
|
local methods. */
|
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
struct target_ops *
|
|
|
|
|
inf_ptrace_target (void)
|
|
|
|
|
{
|
|
|
|
|
struct target_ops *t = inf_child_target ();
|
2005-01-11 04:36:38 +08:00
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
t->to_attach = inf_ptrace_attach;
|
|
|
|
|
t->to_detach = inf_ptrace_detach;
|
|
|
|
|
t->to_resume = inf_ptrace_resume;
|
|
|
|
|
t->to_wait = inf_ptrace_wait;
|
|
|
|
|
t->to_files_info = inf_ptrace_files_info;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
t->to_kill = inf_ptrace_kill;
|
2004-09-12 21:04:41 +08:00
|
|
|
|
t->to_create_inferior = inf_ptrace_create_inferior;
|
2005-07-26 05:11:02 +08:00
|
|
|
|
#ifdef PT_GET_PROCESS_STATE
|
|
|
|
|
t->to_follow_fork = inf_ptrace_follow_fork;
|
2005-08-14 06:23:35 +08:00
|
|
|
|
t->to_post_startup_inferior = inf_ptrace_post_startup_inferior;
|
|
|
|
|
t->to_post_attach = inf_ptrace_post_attach;
|
2005-07-26 05:11:02 +08:00
|
|
|
|
#endif
|
2004-09-12 21:04:41 +08:00
|
|
|
|
t->to_mourn_inferior = inf_ptrace_mourn_inferior;
|
|
|
|
|
t->to_thread_alive = inf_ptrace_thread_alive;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
t->to_pid_to_str = normal_pid_to_str;
|
2004-09-12 21:04:41 +08:00
|
|
|
|
t->to_stop = inf_ptrace_stop;
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
t->to_xfer_partial = inf_ptrace_xfer_partial;
|
2005-01-11 04:36:38 +08:00
|
|
|
|
|
* inf-ptrace.c: Reorder functions.
(inf_ptrace_open, inf_ptrace_reported_exec_events_per_call)
(inf_ptrace_can_run, inf_ptrace_post_attach): Removed.
(inf_ptrace_target): Don't set to_open,
to_reported_exec_events_per_call, to_can_run, to_post_attach,
to_stratum, to_has_all_memory, to_has_memory, to_has_stack,
to_has_registers, to_has_execution, to_magic. Reorder remaining
initializations.
2005-07-26 04:19:37 +08:00
|
|
|
|
ptrace_ops_hack = t;
|
2005-01-11 04:36:38 +08:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-07-26 04:42:29 +08:00
|
|
|
|
/* Pointer to a function that returns the offset within the user area
|
2005-01-11 04:36:38 +08:00
|
|
|
|
where a particular register is stored. */
|
|
|
|
|
static CORE_ADDR (*inf_ptrace_register_u_offset)(int);
|
|
|
|
|
|
|
|
|
|
/* Fetch register REGNUM from the inferior. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_fetch_register (int regnum)
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
size_t size;
|
|
|
|
|
PTRACE_TYPE_RET *buf;
|
|
|
|
|
int pid, i;
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
if (CANNOT_FETCH_REGISTER (regnum))
|
|
|
|
|
{
|
|
|
|
|
regcache_raw_supply (current_regcache, regnum, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-11 04:36:38 +08:00
|
|
|
|
/* Cater for systems like GNU/Linux, that implement threads as
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
separate processes. */
|
2005-01-11 04:36:38 +08:00
|
|
|
|
pid = ptid_get_lwp (inferior_ptid);
|
|
|
|
|
if (pid == 0)
|
|
|
|
|
pid = ptid_get_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
/* This isn't really an address, but ptrace thinks of it as one. */
|
|
|
|
|
addr = inf_ptrace_register_u_offset (regnum);
|
|
|
|
|
size = register_size (current_gdbarch, regnum);
|
|
|
|
|
|
|
|
|
|
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
|
|
|
|
|
buf = alloca (size);
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
/* Read the register contents from the inferior a chunk at a time. */
|
2005-01-11 04:36:38 +08:00
|
|
|
|
for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
|
|
|
|
|
{
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0);
|
2005-01-11 04:36:38 +08:00
|
|
|
|
if (errno != 0)
|
2005-07-26 04:42:29 +08:00
|
|
|
|
error (_("Couldn't read register %s (#%d): %s."),
|
|
|
|
|
REGISTER_NAME (regnum), regnum, safe_strerror (errno));
|
2005-01-11 04:36:38 +08:00
|
|
|
|
|
|
|
|
|
addr += sizeof (PTRACE_TYPE_RET);
|
|
|
|
|
}
|
|
|
|
|
regcache_raw_supply (current_regcache, regnum, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
|
|
|
|
|
for all registers. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_fetch_registers (int regnum)
|
|
|
|
|
{
|
|
|
|
|
if (regnum == -1)
|
|
|
|
|
for (regnum = 0; regnum < NUM_REGS; regnum++)
|
|
|
|
|
inf_ptrace_fetch_register (regnum);
|
|
|
|
|
else
|
|
|
|
|
inf_ptrace_fetch_register (regnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store register REGNUM into the inferior. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inf_ptrace_store_register (int regnum)
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
size_t size;
|
|
|
|
|
PTRACE_TYPE_RET *buf;
|
|
|
|
|
int pid, i;
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
if (CANNOT_STORE_REGISTER (regnum))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-01-11 04:36:38 +08:00
|
|
|
|
/* Cater for systems like GNU/Linux, that implement threads as
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
separate processes. */
|
2005-01-11 04:36:38 +08:00
|
|
|
|
pid = ptid_get_lwp (inferior_ptid);
|
|
|
|
|
if (pid == 0)
|
|
|
|
|
pid = ptid_get_pid (inferior_ptid);
|
|
|
|
|
|
|
|
|
|
/* This isn't really an address, but ptrace thinks of it as one. */
|
|
|
|
|
addr = inf_ptrace_register_u_offset (regnum);
|
|
|
|
|
size = register_size (current_gdbarch, regnum);
|
|
|
|
|
|
|
|
|
|
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
|
|
|
|
|
buf = alloca (size);
|
|
|
|
|
|
* Makefile.in (ALLDEPFILES): Update.
(alpha-linux-nat.o, sparc-linux-nat.o): New rules.
(amd64-linux-nat.o, arm-linux-nat.o, hppa-linux-nat.o)
(i386-linux-nat.o, ia64-linux-nat.o, linux-nat.o, m32r-linux-nat.o)
(m68klinux-nat.o, mips-linux-nat.o, ppc-linux-nat.o, s390-nat.o)
(sparc64-linux-nat.o): Update dependencies.
* alpha-linux-nat.c, sparc-linux-nat.c: New files.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(amd64_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(amd64_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_amd64_linux_nat): Set it. Call linux_target and
add_target.
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(arm_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_arm_linux_nat): Add a prototype. Use linux_target and
add_target.
* hppa-linux-nat.c (hppa_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(hppa_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_hppa_linux_nat): New function.
* i386-linux-nat.c (i386_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(i386_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(i386_linux_resume): Renamed from child_resume and made static.
(i386_linux_child_post_start_inferior): Renamed from
child_post_startup_inferior and made static. Call
super_post_startup_inferior.
(super_post_startup_inferior): New.
(_initialize_i386_linux_nat): New function.
* i386-nat.c: Remove LINUX_CHILD_POST_STARTUP_INFERIOR #ifndef.
* ia64-linux-nat.c (ia64_linux_xfer_unwind_table): Remove.
(super_xfer_partial): New.
(ia64_linux_xfer_partial): New function. Use it.
(_initialize_ia64_linux_nat): New function.
* ia64-tdep.c (getunwind_table): Revert 2005-06-08 change; use
target_read_partial and document the problem.
* inf-ptrace.c (inf_ptrace_fetch_register): Use
CANNOT_FETCH_REGISTER. Fix some comments.
(inf_ptrace_store_register): Use CANNOT_STORE_REGISTER. Fix some
comments.
* linux-nat.c: Include "inf-ptrace.h" and "auxv.h".
(linux_ops, super_xfer_partial): New variables.
(linux_child_post_startup_inferior): Make static.
(child_post_startup_inferior): Delete.
(linux_nat_attach, linux_nat_detach, resume_callback)
(linux_nat_resume, linux_nat_wait, linux_nat_create_inferior)
(linux_nat_mourn_inferior): Use linux_ops instead of
deprecated_child_ops.
(child_wait): Do not depend on CHILD_WAIT.
(linux_nat_xfer_memory): Remove, replace by ...
(linux_nat_xfer_partial): ... this. Use linux_ops->to_xfer_partial
instead of linux_proc_xfer_memory and child_xfer_memory.
(linux_nat_fetch_registers, linux_nat_store_registers)
(linux_nat_child_post_startup_inferior): New functions.
(init_linux_nat_ops): Use the new functions.
(linux_proc_xfer_memory): Remove, replace by ...
(linux_proc_xfer_partial): ... this. Make static.
(linux_xfer_partial, linux_register_u_offset, linux_target): New
functions.
(_initialize_linux_nat): Do not modify deprecated_child_ops.
* linux-nat.h (linux_proc_xfer_memory): Remove prototype.
(struct mem_attrib, struct target_ops): Remove forward declarations.
(linux_child_post_startup_inferior): Remove prototype.
(linux_target): Add prototype.
* linux-thread-db.c (thread_db_xfer_memory): Remove, replace by ...
(thread_db_xfer_partial): ... this.
(init_thread_db_ops): Set to_xfer_partial instead of
deprecated_xfer_memory.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m32r_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_m32r_linux_nat): New function.
* m68klinux-nat.c (m68k_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(m68k_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(old_fetch_inferior_registers, old_store_inferior_registers): Made
static.
(_initialize_m68k_linux_nat): Use linux_target and add_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): New function.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(ppc_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_ppc_linux_nat): New function.
* s390-nat.c (s390_linux_fetch_inferior_registers): Renamed
from fetch_inferior_registers and made static.
(s390_linux_store_inferior_registers): Renamed from
store_inferior_registers and made static.
(_initialize_s390_nat): New function.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
linux_target and add_target.
* config/nm-linux.h: Don't include "auxv.h".
(struct target_waitstatus, child_wait, CHILD_WAIT)
(CHILD_PID_TO_EXEC_FILE, CHILD_INSERT_FORK_CATCHPOINT)
(CHILD_INSERT_VFORK_CATCHPOINT, CHILD_INSERT_EXEC_CATCHPOINT)
(CHILD_POST_STARTUP_INFERIOR, CHILD_POST_ATTACH, CHILD_FOLLOW_FORK)
(DEPRECATED_KILL_INFERIOR, NATIVE_XFER_AUXV): Delete.
* config/alpha/alpha-linux.mh (NATDEPFILES): Replace infptrace.o
and inftarg.o with inf-ptrace.o and alpha-linux-nat.o.
* config/sparc/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with sparc-linux-nat.o.
* config/sparc/linux64.mh (NATDEPFILES): Remove infptrace.o and
inftarg.o.
* config/arm/linux.mh (NATDEPFILES): Replace infptrace.o and
inftarg.o with inf-ptrace.o.
* config/i386/linux.mh (NATDEPFILES): Likewise.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* config/ia64/linux.mh (NATDEPFILES): Likewise.
* config/m32r/linux.mh (NATDEPFILES): Likewise.
* config/m68k/linux.mh (NATDEPFILES): Likewise.
* config/mips/linux.mh (NATDEPFILES): Likewise.
* config/pa/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
* config/s390/s390.mh (NATDEPFILES): Likewise.
* config/i386/nm-linux.h (DEPRECATED_CHILD_RESUME): Don't define.
(LINUX_CHILD_POST_STARTUP_INFERIOR): Don't define.
* config/i386/nm-linux64.h (LINUX_CHILD_POST_STARTUP_INFERIOR):
Don't define.
* config/ia64/nm-linux.h: Don't include "target.h".
(NATIVE_XFER_UNWIND_TABLE, ia64_linux_xfer_unwind_table): Remove.
* config/djgpp/fnchange.lst: Add alpha-linux-tdep.c,
alpha-linux-nat.c, sparc-linux-tdep.c, and sparc-linux-nat.c.
2005-09-11 02:11:14 +08:00
|
|
|
|
/* Write the register contents into the inferior a chunk at a time. */
|
2005-01-11 04:36:38 +08:00
|
|
|
|
regcache_raw_collect (current_regcache, regnum, buf);
|
|
|
|
|
for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
|
|
|
|
|
{
|
|
|
|
|
errno = 0;
|
2005-07-26 04:42:29 +08:00
|
|
|
|
ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]);
|
2005-01-11 04:36:38 +08:00
|
|
|
|
if (errno != 0)
|
2005-07-26 04:42:29 +08:00
|
|
|
|
error (_("Couldn't write register %s (#%d): %s."),
|
|
|
|
|
REGISTER_NAME (regnum), regnum, safe_strerror (errno));
|
2005-01-11 04:36:38 +08:00
|
|
|
|
|
|
|
|
|
addr += sizeof (PTRACE_TYPE_RET);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store register REGNUM back into the inferior. If REGNUM is -1, do
|
|
|
|
|
this for all registers. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
inf_ptrace_store_registers (int regnum)
|
|
|
|
|
{
|
|
|
|
|
if (regnum == -1)
|
|
|
|
|
for (regnum = 0; regnum < NUM_REGS; regnum++)
|
|
|
|
|
inf_ptrace_store_register (regnum);
|
|
|
|
|
else
|
|
|
|
|
inf_ptrace_store_register (regnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a "traditional" ptrace target. REGISTER_U_OFFSET should be
|
|
|
|
|
a function returning the offset within the user area where a
|
|
|
|
|
particular register is stored. */
|
|
|
|
|
|
|
|
|
|
struct target_ops *
|
|
|
|
|
inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)(int))
|
|
|
|
|
{
|
|
|
|
|
struct target_ops *t = inf_ptrace_target();
|
|
|
|
|
|
|
|
|
|
gdb_assert (register_u_offset);
|
|
|
|
|
inf_ptrace_register_u_offset = register_u_offset;
|
|
|
|
|
t->to_fetch_registers = inf_ptrace_fetch_registers;
|
|
|
|
|
t->to_store_registers = inf_ptrace_store_registers;
|
|
|
|
|
|
2004-09-12 21:04:41 +08:00
|
|
|
|
return t;
|
|
|
|
|
}
|