2004-06-08 Andrew Cagney <cagney@gnu.org>

* infptrace.c [ATTACH_DETACH]: Remove #ifdef wrappers.
	(attach, detach): When neither PT_ATTACH / PT_DETACH nor
	PTRACE_ATTACH / PTRACE_DETACH available call error.
	(PT_ATTACH, PT_DETACH): Move definition to attach / detach.
	* infttrace.c (update_thread_state_after_attach, attach, detach):
	Remove #ifdef wrappers.
	* inftarg.c (child_attach, child_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: doc/ChangeLog
2004-06-08  Andrew Cagney  <cagney@gnu.org>

	* gdbint.texinfo (Native Debugging): Delete documentation on
	ATTACH_DETACH.
This commit is contained in:
Andrew Cagney 2004-06-08 19:58:15 +00:00
parent d91670b90d
commit d966f0cbf5
16 changed files with 91 additions and 123 deletions

View file

@ -1,3 +1,23 @@
2004-06-08 Andrew Cagney <cagney@gnu.org>
* infptrace.c [ATTACH_DETACH]: Remove #ifdef wrappers.
(attach, detach): When neither PT_ATTACH / PT_DETACH nor
PTRACE_ATTACH / PTRACE_DETACH available call error.
(PT_ATTACH, PT_DETACH): Move definition to attach / detach.
* infttrace.c (update_thread_state_after_attach, attach, detach):
Remove #ifdef wrappers.
* inftarg.c (child_attach, child_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.
2004-06-08 Corinna Vinschen <vinschen@redhat.com> 2004-06-08 Corinna Vinschen <vinschen@redhat.com>
* configure.in: Set $configdir to the right OS specific value. * configure.in: Set $configdir to the right OS specific value.

View file

@ -32,7 +32,4 @@
#define THREAD_STATE_CLEAR_TRACED(state) \ #define THREAD_STATE_CLEAR_TRACED(state) \
((((struct i386_thread_state *) (state))->efl &= ~0x100), 1) ((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
/* We can attach and detach. */
#define ATTACH_DETACH 1
#endif /* nm-i386gnu.h */ #endif /* nm-i386gnu.h */

View file

@ -25,8 +25,6 @@
#include "i386/nm-i386sco.h" #include "i386/nm-i386sco.h"
#define ATTACH_DETACH
/* SCO, in its wisdom, does not provide <sys/ptrace.h>. infptrace.c /* SCO, in its wisdom, does not provide <sys/ptrace.h>. infptrace.c
does not have defaults for these values. */ does not have defaults for these values. */
#define PTRACE_ATTACH 10 #define PTRACE_ATTACH 10

View file

@ -51,9 +51,6 @@
#define KERNEL_U_SIZE kernel_u_size () #define KERNEL_U_SIZE kernel_u_size ()
extern int kernel_u_size (void); extern int kernel_u_size (void);
/* We can attach and detach. */
#define ATTACH_DETACH
/* Hardware-assisted breakpoints and watchpoints. */ /* Hardware-assisted breakpoints and watchpoints. */
/* We can also do hardware watchpoints. */ /* We can also do hardware watchpoints. */

View file

@ -24,6 +24,3 @@
/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
#define FETCH_INFERIOR_REGISTERS #define FETCH_INFERIOR_REGISTERS
/* We can attach and detach. */
#define ATTACH_DETACH

View file

@ -24,9 +24,6 @@ struct target_ops;
/* GNU/Linux is SVR4-ish but its /proc file system isn't. */ /* GNU/Linux is SVR4-ish but its /proc file system isn't. */
#undef USE_PROC_FS #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> /* Since we're building a native debugger, we can include <signal.h>
to find the range of real-time signals. */ to find the range of real-time signals. */

View file

@ -22,6 +22,4 @@
#define FETCH_INFERIOR_REGISTERS #define FETCH_INFERIOR_REGISTERS
#define ATTACH_DETACH
#include "solib.h" /* Support for shared libraries. */ #include "solib.h" /* Support for shared libraries. */

View file

@ -27,8 +27,3 @@
/* SVR4 has /proc support, so use it instead of ptrace. */ /* SVR4 has /proc support, so use it instead of ptrace. */
#define USE_PROC_FS #define USE_PROC_FS
/* SVR4 machines can easily do attach and detach via /proc (procfs.c)
support */
#define ATTACH_DETACH

View file

@ -91,15 +91,6 @@ extern int hppa_require_detach (int, int);
#define PT_WRITE_I PT_WIUSER #define PT_WRITE_I PT_WIUSER
#define PT_WRITE_D PT_WDUSER #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: */ /* In infptrace or infttrace.c: */
/* Starting with HP-UX 10.30, support is provided (in the form of /* Starting with HP-UX 10.30, support is provided (in the form of

View file

@ -19,10 +19,6 @@
Foundation, Inc., 59 Temple Place - Suite 330, Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ 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. */ /* Override copies of {fetch,store}_inferior_registers in infptrace.c. */
#define FETCH_INFERIOR_REGISTERS #define FETCH_INFERIOR_REGISTERS

View file

@ -1,3 +1,8 @@
2004-06-08 Andrew Cagney <cagney@gnu.org>
* gdbint.texinfo (Native Debugging): Delete documentation on
ATTACH_DETACH.
2004-06-06 Randolph Chung <tausq@debian.org> 2004-06-06 Randolph Chung <tausq@debian.org>
* gdb.texinfo (push_dummy_call): Use @code{struct value}. * gdb.texinfo (push_dummy_call): Use @code{struct value}.

View file

@ -4404,12 +4404,6 @@ defined or left undefined, to control compilation when the host and
target systems are the same. These macros should be defined (or left target systems are the same. These macros should be defined (or left
undefined) in @file{nm-@var{system}.h}. 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 @item CHILD_PREPARE_TO_STORE
@findex CHILD_PREPARE_TO_STORE @findex CHILD_PREPARE_TO_STORE
If the machine stores all registers at once in the child process, then If the machine stores all registers at once in the child process, then

View file

@ -2103,8 +2103,6 @@ gnu_can_run (void)
} }
#ifdef ATTACH_DETACH
/* Attach to process PID, then initialize for debugging it /* Attach to process PID, then initialize for debugging it
and wait for the trace-trap that results from attaching. */ and wait for the trace-trap that results from attaching. */
static void static void
@ -2189,8 +2187,6 @@ gnu_detach (char *args, int from_tty)
unpush_target (&gnu_ops); /* Pop out of handling an inferior */ unpush_target (&gnu_ops); /* Pop out of handling an inferior */
} }
#endif /* ATTACH_DETACH */
static void static void
gnu_terminal_init_inferior (void) gnu_terminal_init_inferior (void)

View file

@ -76,13 +76,6 @@
#define PT_KILL 8 /* Send child a SIGKILL signal */ #define PT_KILL 8 /* Send child a SIGKILL signal */
#endif #endif
#ifndef PT_ATTACH
#define PT_ATTACH PTRACE_ATTACH
#endif
#ifndef PT_DETACH
#define PT_DETACH PTRACE_DETACH
#endif
#include "gdbcore.h" #include "gdbcore.h"
#ifndef NO_SYS_FILE #ifndef NO_SYS_FILE
#include <sys/file.h> #include <sys/file.h>
@ -279,18 +272,25 @@ child_resume (ptid_t ptid, int step, enum target_signal signal)
} }
#endif /* CHILD_RESUME */ #endif /* CHILD_RESUME */
#ifdef ATTACH_DETACH
/* Start debugging the process whose number is PID. */ /* Start debugging the process whose number is PID. */
int int
attach (int pid) attach (int pid)
{ {
errno = 0; errno = 0;
#ifndef PT_ATTACH
#ifdef PTRACE_ATTACH
#define PT_ATTACH PTRACE_ATTACH
#endif
#endif
#ifdef PT_ATTACH
ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0); ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0);
if (errno) if (errno)
perror_with_name ("ptrace"); perror_with_name ("ptrace");
attach_flag = 1; attach_flag = 1;
return pid; return pid;
#else
error ("This system does not support attaching to a process");
#endif
} }
/* Stop debugging the process whose number is PID /* Stop debugging the process whose number is PID
@ -301,13 +301,21 @@ void
detach (int signal) detach (int signal)
{ {
errno = 0; errno = 0;
#ifndef PT_DETACH
#ifdef PTRACE_DETACH
#define PT_DETACH PTRACE_DETACH
#endif
#endif
#ifdef PT_DETACH
ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1, ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1,
signal); signal);
if (errno) if (errno)
print_sys_errmsg ("ptrace", errno); print_sys_errmsg ("ptrace", errno);
attach_flag = 0; attach_flag = 0;
#else
error ("This system does not support detaching from a process");
#endif
} }
#endif /* ATTACH_DETACH */
/* Default the type of the ptrace transfer to int. */ /* Default the type of the ptrace transfer to int. */
#ifndef PTRACE_XFER_TYPE #ifndef PTRACE_XFER_TYPE

View file

@ -194,50 +194,40 @@ child_thread_alive (ptid_t ptid)
static void static void
child_attach (char *args, int from_tty) child_attach (char *args, int from_tty)
{ {
char *exec_file;
int pid;
char *dummy;
if (!args) if (!args)
error_no_arg ("process-id to attach"); error_no_arg ("process-id to attach");
#ifndef ATTACH_DETACH dummy = args;
error ("Can't attach to a process on this machine."); pid = strtol (args, &dummy, 0);
#else /* Some targets don't set errno on errors, grrr! */
{ if ((pid == 0) && (args == dummy))
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))
error ("Illegal process-id: %s\n", args); 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? */ attach (pid);
error ("I refuse to debug myself!");
inferior_ptid = pid_to_ptid (pid);
if (from_tty) push_target (&child_ops);
{
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);
/* Do this first, before anything has had a chance to query the
inferiors symbol table or similar. */
observer_notify_inferior_created (&current_target, from_tty);
}
#endif /* ATTACH_DETACH */
} }
#if !defined(CHILD_POST_ATTACH) #if !defined(CHILD_POST_ATTACH)
@ -260,31 +250,25 @@ child_post_attach (int pid)
static void static void
child_detach (char *args, int from_tty) child_detach (char *args, int from_tty)
{ {
#ifdef ATTACH_DETACH int siggnal = 0;
{ int pid = PIDGET (inferior_ptid);
int siggnal = 0;
int pid = PIDGET (inferior_ptid); if (from_tty)
{
if (from_tty) char *exec_file = get_exec_file (0);
{ if (exec_file == 0)
char *exec_file = get_exec_file (0); exec_file = "";
if (exec_file == 0) printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
exec_file = ""; target_pid_to_str (pid_to_ptid (pid)));
printf_unfiltered ("Detaching from program: %s, %s\n", exec_file, gdb_flush (gdb_stdout);
target_pid_to_str (pid_to_ptid (pid))); }
gdb_flush (gdb_stdout); if (args)
} siggnal = atoi (args);
if (args)
siggnal = atoi (args); detach (siggnal);
detach (siggnal); inferior_ptid = null_ptid;
unpush_target (&child_ops);
inferior_ptid = null_ptid;
unpush_target (&child_ops);
}
#else
error ("This version of Unix does not support detaching a process.");
#endif
} }
/* Get ready to modify the registers array. On machines which store /* Get ready to modify the registers array. On machines which store

View file

@ -4560,8 +4560,6 @@ child_resume (ptid_t ptid, int step, enum target_signal signal)
} }
#endif /* CHILD_RESUME */ #endif /* CHILD_RESUME */
#ifdef ATTACH_DETACH
/* /*
* Like it says. * Like it says.
* *
@ -4733,10 +4731,8 @@ update_thread_state_after_attach (int pid, attach_continue_t kind_of_go)
attach_flag = 1; attach_flag = 1;
} }
#endif /* ATTACH_DETACH */
#ifdef ATTACH_DETACH
/* Start debugging the process whose number is PID. /* Start debugging the process whose number is PID.
* (A _real_ pid). * (A _real_ pid).
*/ */
@ -4803,7 +4799,6 @@ detach (int signal)
/* Process-state? */ /* Process-state? */
} }
#endif /* ATTACH_DETACH */
/* Default the type of the ttrace transfer to int. */ /* Default the type of the ttrace transfer to int. */