This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Remove ptrace-based Alpha OSF support


Hello,

after the AIX conversion, there is a single inftrace.c target
remaining: alpha-osf.  I don't have access to such a system,
so it's hard for me to convert the configuration to inf-ptrace.

However, I'm wondering whether this is actually necessary at
this point.  Looking at the OSF targets, there is an interesting
twist: they attempt to use *either* ptrace *or* procfs.

Do do that, alpha-osf2.mh and alpha-osf3.mh include *both*
procfs.o and infptrace.o in their NATDEPFILES.  I had been
wondering how this could possibly work, seeing as this would
lead to two targets both responding to the target_can_run
query, which should cause find_default_run_target to fail.

However, once upon a time that indeed appears to have worked,
due to this piece of code in inftarg.c (_initialize_inftarg):

#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 ptrace support if we can access the running GDB via /proc.  */
#ifndef PROC_NAME_FMT
#define PROC_NAME_FMT "/proc/%05d"
#endif
  sprintf (procname, PROC_NAME_FMT, getpid ());
  fd = open (procname, O_RDONLY);
  if (fd >= 0)
    {
      close (fd);
      return;
    }
#endif

and a corresponding piece in procfs.c (_initialize_procfs):
#ifdef HAVE_OPTIONAL_PROC_FS
  char procname[MAX_PROC_NAME_SIZE];
  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, STATUS_PROC_NAME_FMT, getpid ());
  if ((fd = open (procname, O_RDONLY)) < 0)
    return;
  close (fd);
#endif


So the idea was that exactly one of inftarg and procfs would refuse
to register its target, and then the other one would be used.

However, this has been broken a long time ago: CVS revision 1.2
of procfs.c already no longer has the #ifdef HAVE_OPTIONAL_PROC_FS
support.   In fact, I'm not quite sure what happened there:

revision 1.2
date: 2000/02/16 08:02:57;  author: cagney;  state: Exp;  lines: +4540 -5031
>From Rodney Brown: Define MERGEPID when needed.

as this revision is basically a re-write of the whole file, which doesn't
really match the log entry ...


What does that mean?  Well, if the OSF system *does* support procfs,
it does't matter: the infptrace code is still there, thus the ptrace
target will not be registered and GDB will use procfs.

However, in the situation where procfs is *not* present, we would
now get both infptrace and procfs registered, completely breaking
debugging.


Since GDB has been in this state for over 7 years now and apparently
nobody noticed, that would imply that either nobody uses GDB on OSF,
or else OSF actually always provides procfs support and the ptrace
fallback isn't really needed.

In either case, I suggest this means it would be OK to remove that
fallback from GDB sources, and just always use procfs on OSF.

The only hitch is OSF/1-1.x, which *only* supports ptrace.  But I
guess this configuration is so old it could be safely obsoleted.

That would allow us to finally get rid of inftarg.c / infptrace.c.


The following patch implements the above suggestion.  It's not
really tested as I don't have access to an OSF system, but it
appears to compile (modulo procfs headers), and the configuration
changes seem to work ...


What do you think?   Is this reasonable?  Did I miss something
in the above analysis?

Bye,
Ulrich


ChangeLog:

	* configure.host (alpha*-*-osf1*): Remove support.
	* NEWS: Mention removed configuration.

	* config/alpha/alpha-osf1.mh: Delete file.
	* config/alpha/alpha-osf2.mh (NATDEPFILES): Remove inftarg.o
	and infptrace.o.
	* config/alpha/alpha-osf3.mh: Likewise.
	* config/alpha/nm-osf.h (U_REGS_OFFSET): Do not define.
	* config/alpha/nm-osf2.h (USE_PROC_FS): Do not define.
	(HAVE_OPTIONAL_PROC_FS): Likewise.
	(KERNEL_U_SIZE, kernel_u_size): Remove.

	* alpha-nat.c (ALPHA_UNIQUE_PTRACE_ADDR): Do not define.
	(register_addr, kernel_u_size): Remove.
	Do not check for "defined(USE_PROC_FS) || defined(HAVE_GREGSET_T)".

diff -urNp gdb-orig/gdb/alpha-nat.c gdb-head/gdb/alpha-nat.c
--- gdb-orig/gdb/alpha-nat.c	2007-04-28 19:25:19.115567362 +0200
+++ gdb-head/gdb/alpha-nat.c	2007-04-28 19:28:01.327093486 +0200
@@ -117,34 +117,7 @@ fetch_osf_core_registers (char *core_reg
 }
 
 
-/* Map gdb internal register number to a ptrace ``address''.
-   These ``addresses'' are defined in <sys/ptrace.h>, with
-   the exception of ALPHA_UNIQUE_PTRACE_ADDR.  */
-
-#define ALPHA_UNIQUE_PTRACE_ADDR 0
-
-CORE_ADDR
-register_addr (int regno, CORE_ADDR blockend)
-{
-  if (regno == PC_REGNUM)
-    return PC;
-  if (regno == ALPHA_UNIQUE_REGNUM)
-    return ALPHA_UNIQUE_PTRACE_ADDR;
-  if (regno < FP0_REGNUM)
-    return GPR_BASE + regno;
-  else
-    return FPR_BASE + regno - FP0_REGNUM;
-}
-
-int
-kernel_u_size (void)
-{
-  return (sizeof (struct user));
-}
-
-#if defined(USE_PROC_FS) || defined(HAVE_GREGSET_T)
 #include <sys/procfs.h>
-
 /* Prototypes for supply_gregset etc. */
 #include "gregset.h"
 
@@ -192,7 +165,6 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
   /* FPCR is in slot 32.  */
   alpha_fill_fp_regs (regno, regp, regp + 31);
 }
-#endif
 
 
 /* Register that we are able to handle alpha core file formats. */
diff -urNp gdb-orig/gdb/config/alpha/alpha-osf1.mh gdb-head/gdb/config/alpha/alpha-osf1.mh
--- gdb-orig/gdb/config/alpha/alpha-osf1.mh	2004-08-05 20:18:17.000000000 +0200
+++ gdb-head/gdb/config/alpha/alpha-osf1.mh	1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-# Host: Little-endian Alpha running OSF/1-1.x
-NAT_FILE= nm-osf.h
-NATDEPFILES= infptrace.o inftarg.o corelow.o alpha-nat.o fork-child.o \
-	solib-osf.o solib.o
diff -urNp gdb-orig/gdb/config/alpha/alpha-osf2.mh gdb-head/gdb/config/alpha/alpha-osf2.mh
--- gdb-orig/gdb/config/alpha/alpha-osf2.mh	2004-08-05 20:18:17.000000000 +0200
+++ gdb-head/gdb/config/alpha/alpha-osf2.mh	2007-04-28 19:22:31.282920293 +0200
@@ -1,5 +1,5 @@
 # Host: Little-endian Alpha running OSF/1-2.x using procfs
 NAT_FILE= nm-osf2.h
-NATDEPFILES= infptrace.o inftarg.o corelow.o alpha-nat.o fork-child.o \
+NATDEPFILES= corelow.o alpha-nat.o fork-child.o \
 	solib-osf.o solib.o procfs.o proc-api.o proc-events.o proc-flags.o \
 	proc-why.o
diff -urNp gdb-orig/gdb/config/alpha/alpha-osf3.mh gdb-head/gdb/config/alpha/alpha-osf3.mh
--- gdb-orig/gdb/config/alpha/alpha-osf3.mh	2004-08-05 20:18:17.000000000 +0200
+++ gdb-head/gdb/config/alpha/alpha-osf3.mh	2007-04-28 19:22:39.913023781 +0200
@@ -1,5 +1,5 @@
 # Host: Little-endian Alpha running OSF/1-3.x and higher using procfs
 NAT_FILE= nm-osf3.h
-NATDEPFILES= infptrace.o inftarg.o corelow.o alpha-nat.o fork-child.o \
+NATDEPFILES= corelow.o alpha-nat.o fork-child.o \
 	solib-osf.o solib.o procfs.o proc-api.o proc-events.o proc-flags.o \
 	proc-why.o
diff -urNp gdb-orig/gdb/config/alpha/nm-osf2.h gdb-head/gdb/config/alpha/nm-osf2.h
--- gdb-orig/gdb/config/alpha/nm-osf2.h	2007-01-11 20:58:02.000000000 +0100
+++ gdb-head/gdb/config/alpha/nm-osf2.h	2007-04-28 19:21:07.891160748 +0200
@@ -21,10 +21,6 @@
 /* Get generic OSF/1 definitions.  */
 #include "alpha/nm-osf.h"
 
-/* OSF/1-2.x has optional /proc support, try to use it instead of ptrace.  */
-#define USE_PROC_FS
-#define HAVE_OPTIONAL_PROC_FS
-
 /* Don't trace faults under OSF/1, rely on the posting of the appropriate
    signal if fault tracing is disabled.
    Tracing T_IFAULT under Alpha OSF/1 causes a `floating point enable'
@@ -38,7 +34,3 @@
 #define PROCFS_NEED_PIOCSSIG_FOR_KILL
 #define PROCFS_DONT_PIOCSSIG_CURSIG
 
-/* Return sizeof user struct to callers in less machine dependent routines */
-
-#define KERNEL_U_SIZE kernel_u_size()
-extern int kernel_u_size (void);
diff -urNp gdb-orig/gdb/config/alpha/nm-osf.h gdb-head/gdb/config/alpha/nm-osf.h
--- gdb-orig/gdb/config/alpha/nm-osf.h	2007-04-26 01:12:31.000000000 +0200
+++ gdb-head/gdb/config/alpha/nm-osf.h	2007-04-28 19:20:50.632958913 +0200
@@ -25,7 +25,3 @@
    the inferior code.  This is 2 on most implementations.  */
 #define START_INFERIOR_TRAPS_EXPECTED 3
 
-/* ptrace register ``addresses'' are absolute.  */
-
-#define U_REGS_OFFSET 0
-
diff -urNp gdb-orig/gdb/configure.host gdb-head/gdb/configure.host
--- gdb-orig/gdb/configure.host	2007-04-27 15:17:42.000000000 +0200
+++ gdb-head/gdb/configure.host	2007-04-28 19:24:07.083775827 +0200
@@ -13,6 +13,7 @@
 # The default is $host_cpu.
 
 case $host in
+ alpha*-*-osf1* | \
  hppa*-*-hiux* | \
  i[34567]86-ncr-* | \
  i[34567]86-*-dgux* | \
@@ -60,7 +61,6 @@ esac
 
 case "${host}" in
 
-alpha*-*-osf1*)		gdb_host=alpha-osf1 ;;
 alpha*-*-osf2*)		gdb_host=alpha-osf2 ;;
 alpha*-*-osf[3456789]*)	gdb_host=alpha-osf3 ;;
 alpha*-*-linux*)	gdb_host=alpha-linux ;;
diff -urNp gdb-orig/gdb/NEWS gdb-head/gdb/NEWS
--- gdb-orig/gdb/NEWS	2007-04-13 19:13:45.000000000 +0200
+++ gdb-head/gdb/NEWS	2007-04-28 19:43:43.699135294 +0200
@@ -91,6 +91,7 @@ qXfer:features:read:
 
 Support for these obsolete configurations has been removed.
 
+alpha*-*-osf1*
 d10v-*-*
 hppa*-*-hiux*
 i[34567]86-ncr-*
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]