aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog45
-rw-r--r--gdb/Makefile.in7
-rw-r--r--gdb/NEWS8
-rw-r--r--gdb/alpha-nat.c73
-rw-r--r--gdb/configure.in3
-rw-r--r--gdb/procfs.c127
6 files changed, 250 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 902f34c..fd0ff2a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,48 @@
+Thu Jan 12 09:33:24 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * README: Add note about SPARCworks cc release 3.0 and higher.
+
+ Add procfs support for Alpha OSF/1-2.x.
+ * config/alpha/nm-osf.h: Renamed from nm-alpha.h, generic
+ OSF/1 native support.
+ * config/alpha/alpha-osf1.mh (NAT_FILE): Changed accordingly.
+ (MUNCH_DEFINE): Removed.
+ * config/alpha/alpha-osf2.mh, config/alpha/nm-osf2.h: New files
+ for procfs support.
+ * configure.in (alpha-dec-osf*): Use alpha-osf2.mh for OSF/1
+ release 2.x and higher, else alpha-osf1.mh, as the procfs support
+ in release 1.x is incomplete.
+ * Makefile.in (ALLCONFIG): Add config/alpha/alpha-osf2.mh.
+ * alpha-nat.c (supply_gregset, fill_gregset, supply_fpgregset,
+ fill_fpgregset): New routines for procfs support.
+ * inftarg.c (_initialize_inftarg): Don't add ptrace support
+ if we have an optional procfs and /proc is accessible.
+ * procfs.c: Include sys/fault.h and sys/syscall.h before
+ including sys/procfs.h.
+ (unconditionally_kill_inferior): If PROCFS_NEED_PIOCSSIG_FOR_KILL
+ is defined, additionally perform a PIOCSSIG to really terminate
+ the inferior.
+ (create_procinfo): Always return a result.
+ (create_procinfo, do_attach): Don't trace T_IFAULT faults if
+ PROCFS_DONT_TRACE_IFAULT is defined.
+ (procfs_init_inferior): Use START_INFERIOR_TRAPS_EXPECTED as
+ argument to startup_inferior if it is defined.
+ (proc_set_exec_trap): If PIOCSSPCACT is defined, use it instead
+ of tracing exits from exec system calls. Needed for the user level
+ loader under Alpha OSF/1.
+ (do_detach): Clear any pending signal if we want to detach from
+ a process without a signal.
+ (set_proc_siginfo): If PROCFS_DONT_PIOCSSIG_CURSIG is defined,
+ don't issue a PIOCSSIG if pr_cursig already contains the signal we
+ intend to set.
+ (info_proc_signals): If PROCFS_SIGPEND_OFFSET is defined, the
+ pending signals are numbered from 1 instead of 0.
+ (info_proc_mappings): Increase size of output format for addresses
+ if BFD_HOST_64_BIT is defined.
+ (procfs_stop): Renamed from child_stop.
+ (_initialize_procfs): Don't add procfs support if we have an
+ optional procfs and /proc is not accessible.
+
Wed Jan 11 17:06:55 1995 Stu Grossman (grossman@cygnus.com)
* gdbtk.tcl: Add button to control mixed source disassembly.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 4b7d8eb..4650493 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1,4 +1,5 @@
-# Copyright 1989, 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+# Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995
+# Free Software Foundation, Inc.
# This file is part of GDB.
@@ -906,8 +907,8 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \
ALLCONFIG = config/a29k/a29k-kern.mt config/a29k/a29k-udi.mt \
config/a29k/a29k.mt config/a29k/ultra3.mh config/a29k/ultra3.mt \
- config/alpha/alpha-osf1.mh config/alpha/alpha-osf1.mt \
- config/alpha/alpha-nw.mt \
+ config/alpha/alpha-osf1.mh config/alpha/alpha-osf2.mh \
+ config/alpha/alpha-osf1.mt config/alpha/alpha-nw.mt \
config/arm/arm.mh config/arm/arm.mt config/convex/convex.mh \
config/convex/convex.mt config/gould/np1.mh config/gould/np1.mt \
config/gould/pn.mh config/gould/pn.mt config/h8300/h8300hms.mt \
diff --git a/gdb/NEWS b/gdb/NEWS
index 0af1c67..effa051 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -1,6 +1,14 @@
What has changed since GDB-3.5?
(Organized release by release)
+* Alpha OSF/1 support for procfs
+
+GDB now supports procfs under OSF/1-2.x and higher, which makes it
+possible to attach to running processes. As the mounting of the /proc
+filesystem is optional on the Alpha, GDB automatically determines
+the availability of /proc during startup. This can lead to problems
+if /proc is unmounted after GDB has been started.
+
* User commands may accept up to 10 arguments separated by whitespace.
Arguments are accessed within the user command via $arg0..$arg0.
A trivial example:
diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c
index a0c5399..4d91fe8 100644
--- a/gdb/alpha-nat.c
+++ b/gdb/alpha-nat.c
@@ -1,5 +1,5 @@
/* Low level Alpha interface, for GDB when running native.
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1995 Free Software Foundation, Inc.
This file is part of GDB.
@@ -142,3 +142,74 @@ register_addr (regno, blockend)
{
return REGISTER_PTRACE_ADDR (regno);
}
+
+#ifdef USE_PROC_FS
+#include <sys/procfs.h>
+
+/*
+ * See the comment in m68k-tdep.c regarding the utility of these functions.
+ */
+
+void
+supply_gregset (gregsetp)
+ gregset_t *gregsetp;
+{
+ register int regi;
+ register long *regp = gregsetp->regs;
+
+ for (regi = 0; regi < 31; regi++)
+ supply_register (regi, (char *)(regp + regi));
+
+ supply_register (PC_REGNUM, (char *)(regp + 31));
+}
+
+void
+fill_gregset (gregsetp, regno)
+ gregset_t *gregsetp;
+ int regno;
+{
+ int regi;
+ register long *regp = gregsetp->regs;
+
+ for (regi = 0; regi < 31; regi++)
+ if ((regno == -1) || (regno == regi))
+ *(regp + regi) = *(long *) &registers[REGISTER_BYTE (regi)];
+
+ if ((regno == -1) || (regno == PC_REGNUM))
+ *(regp + 31) = *(long *) &registers[REGISTER_BYTE (PC_REGNUM)];
+}
+
+/*
+ * Now we do the same thing for floating-point registers.
+ * Again, see the comments in m68k-tdep.c.
+ */
+
+void
+supply_fpregset (fpregsetp)
+ fpregset_t *fpregsetp;
+{
+ register int regi;
+ register long *regp = fpregsetp->regs;
+
+ for (regi = 0; regi < 32; regi++)
+ supply_register (regi + FP0_REGNUM, (char *)(regp + regi));
+}
+
+void
+fill_fpregset (fpregsetp, regno)
+ fpregset_t *fpregsetp;
+ int regno;
+{
+ int regi;
+ register long *regp = fpregsetp->regs;
+
+ for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
+ {
+ if ((regno == -1) || (regno == regi))
+ {
+ *(regp + regi - FP0_REGNUM) =
+ *(long *) &registers[REGISTER_BYTE (regi)];
+ }
+ }
+}
+#endif
diff --git a/gdb/configure.in b/gdb/configure.in
index 0fed66c..c9e0819 100644
--- a/gdb/configure.in
+++ b/gdb/configure.in
@@ -32,7 +32,8 @@ case "${host}" in
a29k-*-*) gdb_host=ultra3 ;;
-alpha-*-osf*) gdb_host=alpha-osf1 ;;
+alpha-*-osf1*) gdb_host=alpha-osf1 ;;
+alpha-*-osf[23456789]*) gdb_host=alpha-osf2 ;;
arm-*-*) gdb_host=arm ;;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 0f75191..bcae876 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1,5 +1,5 @@
/* Machine independent support for SVR4 /proc (process file system) for GDB.
- Copyright 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Copyright 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
Written by Fred Fish at Cygnus Support.
This file is part of GDB.
@@ -36,6 +36,8 @@ regardless of whether or not the actual target has floating point hardware.
#include <sys/types.h>
#include <time.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
#include <sys/procfs.h>
#include <fcntl.h>
#include <errno.h>
@@ -1278,6 +1280,26 @@ unconditionally_kill_inferior (pi)
signo = SIGKILL;
ioctl (pi->fd, PIOCKILL, &signo);
+
+#ifdef PROCFS_NEED_PIOCSSIG_FOR_KILL
+ /* Alpha OSF/1 procfs needs an additional PIOCSSIG call with
+ a SIGKILL signal to kill the inferior, otherwise it might remain
+ stopped with a pending SIGKILL.
+ We do not check the result of the PIOCSSIG, the inferior might have
+ died already. */
+ {
+ struct siginfo newsiginfo;
+
+ memset ((char *) &newsiginfo, 0, sizeof (newsiginfo));
+ newsiginfo.si_signo = signo;
+ newsiginfo.si_code = 0;
+ newsiginfo.si_errno = 0;
+ newsiginfo.si_pid = getpid ();
+ newsiginfo.si_uid = getuid ();
+ ioctl (pi->fd, PIOCSSIG, &newsiginfo);
+ }
+#endif
+
close_proc_file (pi);
/* Only wait() for our direct children. Our grandchildren zombies are killed
@@ -1444,8 +1466,9 @@ create_procinfo (pid)
{
struct procinfo *pi;
- if (find_procinfo (pid, 1))
- return; /* All done! It already exists */
+ pi = find_procinfo (pid, 1);
+ if (pi != NULL)
+ return pi; /* All done! It already exists */
pi = (struct procinfo *) xmalloc (sizeof (struct procinfo));
@@ -1465,6 +1488,14 @@ create_procinfo (pid)
prfillset (&pi->prrun.pr_fault);
prdelset (&pi->prrun.pr_fault, FLTPAGE);
+#ifdef PROCFS_DONT_TRACE_IFAULT
+ /* Tracing T_IFAULT under Alpha OSF/1 causes a `floating point enable'
+ fault from which we cannot continue (except by disabling the
+ tracing). We rely on the delivery of a SIGTRAP signal (which is traced)
+ for the other T_IFAULT faults if tracing them is disabled. */
+ prdelset (&pi->prrun.pr_fault, T_IFAULT);
+#endif
+
if (ioctl (pi->fd, PIOCWSTOP, &pi->prstatus) < 0)
proc_init_failed (pi, "PIOCWSTOP failed");
@@ -1509,8 +1540,12 @@ procfs_init_inferior (pid)
create_procinfo (pid);
add_thread (pid); /* Setup initial thread */
+#ifdef START_INFERIOR_TRAPS_EXPECTED
+ startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
+#else
/* One trap to exec the shell, one to exec the program being debugged. */
startup_inferior (2);
+#endif
}
/*
@@ -1615,6 +1650,27 @@ proc_set_exec_trap ()
premptyset (&exitset);
premptyset (&entryset);
+#ifdef PIOCSSPCACT
+ /* Under Alpha OSF/1 we have to use a PIOCSSPCACT ioctl to trace
+ exits from exec system calls because of the user level loader. */
+ {
+ int prfs_flags;
+
+ if (ioctl (fd, PIOCGSPCACT, &prfs_flags) < 0)
+ {
+ perror (procname);
+ gdb_flush (gdb_stderr);
+ _exit (127);
+ }
+ prfs_flags |= PRFS_STOPEXEC;
+ if (ioctl (fd, PIOCSSPCACT, &prfs_flags) < 0)
+ {
+ perror (procname);
+ gdb_flush (gdb_stderr);
+ _exit (127);
+ }
+ }
+#else
/* GW: Rationale...
Not all systems with /proc have all the exec* syscalls with the same
names. On the SGI, for example, there is no SYS_exec, but there
@@ -1636,6 +1692,7 @@ proc_set_exec_trap ()
gdb_flush (gdb_stderr);
_exit (127);
}
+#endif
praddset (&entryset, SYS_exit);
@@ -2037,6 +2094,15 @@ do_attach (pid)
procfs_notice_signals (pid);
prfillset (&pi->prrun.pr_fault);
prdelset (&pi->prrun.pr_fault, FLTPAGE);
+
+#ifdef PROCFS_DONT_TRACE_IFAULT
+ /* Tracing T_IFAULT under Alpha OSF/1 causes a `floating point enable'
+ fault from which we cannot continue (except by disabling the
+ tracing). We rely on the delivery of a SIGTRAP signal (which is traced)
+ for the other T_IFAULT faults if tracing them is disabled. */
+ prdelset (&pi->prrun.pr_fault, T_IFAULT);
+#endif
+
if (ioctl (pi->fd, PIOCSFAULT, &pi->prrun.pr_fault))
{
print_sys_errmsg ("PIOCSFAULT failed", errno);
@@ -2128,6 +2194,11 @@ do_detach (signal)
if (signal || !pi->was_stopped ||
query ("Was stopped when attached, make it runnable again? "))
{
+ /* Clear any pending signal if we want to detach without
+ a signal. */
+ if (signal == 0)
+ set_proc_siginfo (pi, signal);
+
/* Clear any fault that might have stopped it. */
if (ioctl (pi->fd, PIOCCFAULT, 0))
{
@@ -2475,6 +2546,14 @@ set_proc_siginfo (pip, signo)
struct siginfo newsiginfo;
struct siginfo *sip;
+#ifdef PROCFS_DONT_PIOCSSIG_CURSIG
+ /* With Alpha OSF/1 procfs, the kernel gets really confused if it
+ receives a PIOCSSSIG with a signal identical to the current signal,
+ it messes up the current signal. Work around the kernel bug. */
+ if (signo == pip -> prstatus.pr_cursig)
+ return;
+#endif
+
if (signo == pip -> prstatus.pr_info.si_signo)
{
sip = &pip -> prstatus.pr_info;
@@ -3142,9 +3221,19 @@ info_proc_signals (pip, summary)
printf_filtered ("%-8s ",
prismember (&pip -> prstatus.pr_sighold, signo)
? "on" : "off");
+
+#ifdef PROCFS_SIGPEND_OFFSET
+ /* Alpha OSF/1 numbers the pending signals from 1. */
+ printf_filtered ("%-8s ",
+ (signo ? prismember (&pip -> prstatus.pr_sigpend,
+ signo - 1)
+ : 0)
+ ? "yes" : "no");
+#else
printf_filtered ("%-8s ",
prismember (&pip -> prstatus.pr_sigpend, signo)
? "yes" : "no");
+#endif
printf_filtered (" %s\n", safe_strsignal (signo));
}
printf_filtered ("\n");
@@ -3193,7 +3282,11 @@ info_proc_mappings (pip, summary)
if (!summary)
{
printf_filtered ("Mapped address spaces:\n\n");
+#ifdef BFD_HOST_64_BIT
+ printf_filtered (" %18s %18s %10s %10s %7s\n",
+#else
printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+#endif
"Start Addr",
" End Addr",
" Size",
@@ -3206,9 +3299,14 @@ info_proc_mappings (pip, summary)
{
for (prmap = prmaps; prmap -> pr_size; ++prmap)
{
- printf_filtered ("\t%#10x %#10x %#10x %#10x %7s\n",
- prmap -> pr_vaddr,
- prmap -> pr_vaddr + prmap -> pr_size - 1,
+#ifdef BFD_HOST_64_BIT
+ printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
+#else
+ printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
+#endif
+ (unsigned long)prmap -> pr_vaddr,
+ (unsigned long)prmap -> pr_vaddr
+ + prmap -> pr_size - 1,
prmap -> pr_size,
prmap -> pr_off,
mappingflags (prmap -> pr_mflags));
@@ -3663,7 +3761,7 @@ procfs_stopped_by_watchpoint(pid)
killpg() instead of kill (-pgrp). */
void
-child_stop ()
+procfs_stop ()
{
extern pid_t inferior_process_group;
@@ -3700,7 +3798,7 @@ struct target_ops procfs_ops = {
procfs_mourn_inferior, /* to_mourn_inferior */
procfs_can_run, /* to_can_run */
procfs_notice_signals, /* to_notice_signals */
- child_stop, /* to_stop */
+ procfs_stop, /* to_stop */
process_stratum, /* to_stratum */
0, /* to_next */
1, /* to_has_all_memory */
@@ -3716,6 +3814,19 @@ struct target_ops procfs_ops = {
void
_initialize_procfs ()
{
+#ifdef HAVE_OPTIONAL_PROC_FS
+ char procname[32];
+ int fd;
+
+ /* If we have an optional /proc filesystem (e.g. under OSF/1),
+ don't add procfs support if we cannot access the running
+ GDB via /proc. */
+ sprintf (procname, PROC_NAME_FMT, getpid ());
+ if ((fd = open (procname, O_RDONLY)) < 0)
+ return;
+ close (fd);
+#endif
+
add_target (&procfs_ops);
add_info ("proc", info_proc,