This is the mail archive of the gdb-patches@sources.redhat.com 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]

[patch/rfc] Assume ATTATCH_DETACH


Hello,

Can anyone think of a reason to not simply assume ATTACH_DETACH? The only potential problem area that I'm aware of is cygwin et.al. and for that, this attach/detach code isn't even linked in -> not a problem.

If someone does turn up a system that doesn't support attach/detach then we can handle that using autoconf (or even #ifdef PT_ATTACH e.t.c.).

comments?
Andrew
2004-05-24  Andrew Cagney  <cagney@redhat.com>

	* infttrace.c (update_thread_state_after_attach, attach, detach):
	Remove #ifdef wrappers.
	* inftarg.c (child_attach, child_detach): Remove #ifdef wrappers.
	* infptrace.c [ATTACH_DETACH]: Remove #ifdef wrappers.
	* gnu-nat.c [ATTACH_DETACH]: Remove #ifdef wrappers.
	* config/nm-bsd.h (ATTACH_DETACH): Delete.
	* config/nm-sysv4.h (ATTACH_DETACH): Delete.
	* config/nm-nbsd.h (ATTACH_DETACH): Delete.
	* config/nm-linux.h (ATTACH_DETACH): Delete.
	* config/rs6000/nm-rs6000.h (ATTACH_DETACH): Delete.
	* config/pa/nm-hppah.h (ATTACH_DETACH): Delete.
	* config/i386/nm-i386sco5.h (ATTACH_DETACH): Delete.
	* config/i386/nm-i386sco4.h (ATTACH_DETACH): Delete.
	* config/i386/nm-i386gnu.h (ATTACH_DETACH): Delete.

Index: gnu-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-nat.c,v
retrieving revision 1.29
diff -p -u -r1.29 gnu-nat.c
--- gnu-nat.c	4 Apr 2004 14:23:51 -0000	1.29
+++ gnu-nat.c	25 May 2004 16:25:37 -0000
@@ -2102,8 +2102,6 @@ gnu_can_run (void)
 }
 
 
-#ifdef ATTACH_DETACH
-
 /* Attach to process PID, then initialize for debugging it
    and wait for the trace-trap that results from attaching.  */
 static void
@@ -2188,8 +2186,6 @@ gnu_detach (char *args, int from_tty)
 
   unpush_target (&gnu_ops);	/* Pop out of handling an inferior */
 }
-#endif /* ATTACH_DETACH */
-
 
 static void
 gnu_terminal_init_inferior (void)
Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.29
diff -p -u -r1.29 infptrace.c
--- infptrace.c	2 Oct 2003 20:28:29 -0000	1.29
+++ infptrace.c	25 May 2004 16:25:37 -0000
@@ -279,8 +279,6 @@ child_resume (ptid_t ptid, int step, enu
 }
 #endif /* CHILD_RESUME */
 
-
-#ifdef ATTACH_DETACH
 /* Start debugging the process whose number is PID.  */
 int
 attach (int pid)
@@ -307,7 +305,6 @@ detach (int signal)
     print_sys_errmsg ("ptrace", errno);
   attach_flag = 0;
 }
-#endif /* ATTACH_DETACH */
 
 /* Default the type of the ptrace transfer to int.  */
 #ifndef PTRACE_XFER_TYPE
Index: inftarg.c
===================================================================
RCS file: /cvs/src/src/gdb/inftarg.c,v
retrieving revision 1.23
diff -p -u -r1.23 inftarg.c
--- inftarg.c	4 Feb 2004 21:49:55 -0000	1.23
+++ inftarg.c	25 May 2004 16:25:37 -0000
@@ -194,46 +194,40 @@ child_thread_alive (ptid_t ptid)
 static void
 child_attach (char *args, int from_tty)
 {
+  char *exec_file;
+  int pid;
+  char *dummy;
+
   if (!args)
     error_no_arg ("process-id to attach");
 
-#ifndef ATTACH_DETACH
-  error ("Can't attach to a process on this machine.");
-#else
-  {
-    char *exec_file;
-    int pid;
-    char *dummy;
-
-    dummy = args;
-    pid = strtol (args, &dummy, 0);
-    /* Some targets don't set errno on errors, grrr! */
-    if ((pid == 0) && (args == dummy))
+  dummy = args;
+  pid = strtol (args, &dummy, 0);
+  /* Some targets don't set errno on errors, grrr! */
+  if ((pid == 0) && (args == dummy))
       error ("Illegal process-id: %s\n", args);
+  
+  if (pid == getpid ())	/* Trying to masturbate? */
+    error ("I refuse to debug myself!");
+  
+  if (from_tty)
+    {
+      exec_file = (char *) get_exec_file (0);
+      
+      if (exec_file)
+	printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
+			   target_pid_to_str (pid_to_ptid (pid)));
+      else
+	printf_unfiltered ("Attaching to %s\n",
+			   target_pid_to_str (pid_to_ptid (pid)));
+      
+      gdb_flush (gdb_stdout);
+    }
 
-    if (pid == getpid ())	/* Trying to masturbate? */
-      error ("I refuse to debug myself!");
-
-    if (from_tty)
-      {
-	exec_file = (char *) get_exec_file (0);
-
-	if (exec_file)
-	  printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
-			     target_pid_to_str (pid_to_ptid (pid)));
-	else
-	  printf_unfiltered ("Attaching to %s\n",
-	                     target_pid_to_str (pid_to_ptid (pid)));
-
-	gdb_flush (gdb_stdout);
-      }
-
-    attach (pid);
-
-    inferior_ptid = pid_to_ptid (pid);
-    push_target (&child_ops);
-  }
-#endif /* ATTACH_DETACH */
+  attach (pid);
+  
+  inferior_ptid = pid_to_ptid (pid);
+  push_target (&child_ops);
 }
 
 #if !defined(CHILD_POST_ATTACH)
@@ -256,31 +250,25 @@ child_post_attach (int pid)
 static void
 child_detach (char *args, int from_tty)
 {
-#ifdef ATTACH_DETACH
-  {
-    int siggnal = 0;
-    int pid = PIDGET (inferior_ptid);
-
-    if (from_tty)
-      {
-	char *exec_file = get_exec_file (0);
-	if (exec_file == 0)
-	  exec_file = "";
-	printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
-	gdb_flush (gdb_stdout);
-      }
-    if (args)
-      siggnal = atoi (args);
-
-    detach (siggnal);
-
-    inferior_ptid = null_ptid;
-    unpush_target (&child_ops);
-  }
-#else
-  error ("This version of Unix does not support detaching a process.");
-#endif
+  int siggnal = 0;
+  int pid = PIDGET (inferior_ptid);
+  
+  if (from_tty)
+    {
+      char *exec_file = get_exec_file (0);
+      if (exec_file == 0)
+	exec_file = "";
+      printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
+			 target_pid_to_str (pid_to_ptid (pid)));
+      gdb_flush (gdb_stdout);
+    }
+  if (args)
+    siggnal = atoi (args);
+  
+  detach (siggnal);
+  
+  inferior_ptid = null_ptid;
+  unpush_target (&child_ops);
 }
 
 /* Get ready to modify the registers array.  On machines which store
Index: infttrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infttrace.c,v
retrieving revision 1.31
diff -p -u -r1.31 infttrace.c
--- infttrace.c	8 Apr 2004 21:18:12 -0000	1.31
+++ infttrace.c	25 May 2004 16:25:38 -0000
@@ -4560,8 +4560,6 @@ child_resume (ptid_t ptid, int step, enu
 }
 #endif /* CHILD_RESUME */
 
-
-#ifdef ATTACH_DETACH
 /*
  * Like it says.
  *
@@ -4733,10 +4731,8 @@ update_thread_state_after_attach (int pi
 
   attach_flag = 1;
 }
-#endif /* ATTACH_DETACH */
 
 
-#ifdef ATTACH_DETACH
 /* Start debugging the process whose number is PID.
  * (A _real_ pid).
  */
@@ -4803,7 +4799,6 @@ detach (int signal)
 
   /* Process-state? */
 }
-#endif /* ATTACH_DETACH */
 
 
 /* Default the type of the ttrace transfer to int.  */
Index: config/nm-bsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-bsd.h,v
retrieving revision 1.1
diff -p -u -r1.1 nm-bsd.h
--- config/nm-bsd.h	13 Mar 2004 13:07:18 -0000	1.1
+++ config/nm-bsd.h	25 May 2004 16:25:39 -0000
@@ -24,6 +24,3 @@
 
 /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'.  */
 #define FETCH_INFERIOR_REGISTERS
-
-/* We can attach and detach.  */
-#define ATTACH_DETACH
Index: config/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-linux.h,v
retrieving revision 1.20
diff -p -u -r1.20 nm-linux.h
--- config/nm-linux.h	1 Feb 2004 22:35:22 -0000	1.20
+++ config/nm-linux.h	25 May 2004 16:25:39 -0000
@@ -24,9 +24,6 @@ struct target_ops;
 /* GNU/Linux is SVR4-ish but its /proc file system isn't.  */
 #undef USE_PROC_FS
 
-/* Tell GDB that we can attach and detach other processes.  */
-#define ATTACH_DETACH
-
 /* Since we're building a native debugger, we can include <signal.h>
    to find the range of real-time signals.  */
 
Index: config/nm-nbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-nbsd.h,v
retrieving revision 1.3
diff -p -u -r1.3 nm-nbsd.h
--- config/nm-nbsd.h	22 May 2002 03:59:53 -0000	1.3
+++ config/nm-nbsd.h	25 May 2004 16:25:39 -0000
@@ -22,6 +22,4 @@
 
 #define FETCH_INFERIOR_REGISTERS
 
-#define ATTACH_DETACH
-
 #include "solib.h"		/* Support for shared libraries. */
Index: config/nm-sysv4.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-sysv4.h,v
retrieving revision 1.2
diff -p -u -r1.2 nm-sysv4.h
--- config/nm-sysv4.h	6 Mar 2001 08:21:20 -0000	1.2
+++ config/nm-sysv4.h	25 May 2004 16:25:39 -0000
@@ -27,8 +27,3 @@
 /* SVR4 has /proc support, so use it instead of ptrace. */
 
 #define USE_PROC_FS
-
-/* SVR4 machines can easily do attach and detach via /proc (procfs.c)
-   support */
-
-#define ATTACH_DETACH
Index: config/i386/nm-i386gnu.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386gnu.h,v
retrieving revision 1.1
diff -p -u -r1.1 nm-i386gnu.h
--- config/i386/nm-i386gnu.h	15 Aug 2002 22:24:01 -0000	1.1
+++ config/i386/nm-i386gnu.h	25 May 2004 16:25:39 -0000
@@ -32,7 +32,4 @@
 #define THREAD_STATE_CLEAR_TRACED(state) \
   	((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
 
-/* We can attach and detach.  */
-#define ATTACH_DETACH 1
-
 #endif /* nm-i386gnu.h */
Index: config/i386/nm-i386sco4.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386sco4.h,v
retrieving revision 1.1.1.2
diff -p -u -r1.1.1.2 nm-i386sco4.h
--- config/i386/nm-i386sco4.h	7 Jul 1999 20:12:44 -0000	1.1.1.2
+++ config/i386/nm-i386sco4.h	25 May 2004 16:25:39 -0000
@@ -25,8 +25,6 @@
 
 #include "i386/nm-i386sco.h"
 
-#define ATTACH_DETACH
-
 /* SCO, in its wisdom, does not provide <sys/ptrace.h>.  infptrace.c
    does not have defaults for these values.  */
 #define PTRACE_ATTACH 10
Index: config/i386/nm-i386sco5.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386sco5.h,v
retrieving revision 1.4
diff -p -u -r1.4 nm-i386sco5.h
--- config/i386/nm-i386sco5.h	24 Feb 2003 21:56:51 -0000	1.4
+++ config/i386/nm-i386sco5.h	25 May 2004 16:25:39 -0000
@@ -51,9 +51,6 @@
 #define KERNEL_U_SIZE kernel_u_size ()
 extern int kernel_u_size (void);
 
-/* We can attach and detach.  */
-#define ATTACH_DETACH
-
 /* Hardware-assisted breakpoints and watchpoints.  */
 
 /* We can also do hardware watchpoints.  */
Index: config/pa/nm-hppah.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/nm-hppah.h,v
retrieving revision 1.18
diff -p -u -r1.18 nm-hppah.h
--- config/pa/nm-hppah.h	19 Sep 2003 20:09:44 -0000	1.18
+++ config/pa/nm-hppah.h	25 May 2004 16:25:39 -0000
@@ -91,15 +91,6 @@ extern int hppa_require_detach (int, int
 #define PT_WRITE_I	PT_WIUSER
 #define PT_WRITE_D	PT_WDUSER
 
-/* attach/detach works to some extent under BSD and HPUX.  So long
-   as the process you're attaching to isn't blocked waiting on io,
-   blocked waiting on a signal, or in a system call things work 
-   fine.  (The problems in those cases are related to the fact that
-   the kernel can't provide complete register information for the
-   target process...  Which really pisses off GDB.)  */
-
-#define ATTACH_DETACH
-
 /* In infptrace or infttrace.c: */
 
 /* Starting with HP-UX 10.30, support is provided (in the form of
Index: config/rs6000/nm-rs6000.h
===================================================================
RCS file: /cvs/src/src/gdb/config/rs6000/nm-rs6000.h,v
retrieving revision 1.10
diff -p -u -r1.10 nm-rs6000.h
--- config/rs6000/nm-rs6000.h	3 Sep 2003 21:01:44 -0000	1.10
+++ config/rs6000/nm-rs6000.h	25 May 2004 16:25:39 -0000
@@ -19,10 +19,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* Do implement the attach and detach commands.  */
-
-#define ATTACH_DETACH
-
 /* Override copies of {fetch,store}_inferior_registers in infptrace.c.  */
 
 #define FETCH_INFERIOR_REGISTERS
Index: doc/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
retrieving revision 1.416
diff -p -u -r1.416 ChangeLog
--- doc/ChangeLog	21 May 2004 16:04:02 -0000	1.416
+++ doc/ChangeLog	25 May 2004 16:25:40 -0000
@@ -1,3 +1,8 @@
+2004-05-24  Andrew Cagney  <cagney@redhat.com>
+
+	* gdbint.texinfo (Native Debugging): Delete documentation on
+	ATTACH_DETACH.
+
 2004-05-21  Andrew Cagney  <cagney@redhat.com>
 
 	* observer.texi (GDB Observers): Document "inferior_created".
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.203
diff -p -u -r1.203 gdbint.texinfo
--- doc/gdbint.texinfo	8 May 2004 22:26:10 -0000	1.203
+++ doc/gdbint.texinfo	25 May 2004 16:25:43 -0000
@@ -4401,12 +4401,6 @@ defined or left undefined, to control co
 target systems are the same.  These macros should be defined (or left
 undefined) in @file{nm-@var{system}.h}.
 
-@table @code
-@item ATTACH_DETACH
-@findex ATTACH_DETACH
-If defined, then @value{GDBN} will include support for the @code{attach} and
-@code{detach} commands.
-
 @item CHILD_PREPARE_TO_STORE
 @findex CHILD_PREPARE_TO_STORE
 If the machine stores all registers at once in the child process, then

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