This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[COMMIT] Inline attach and detach in inf-ptrace.c
- From: Mark Kettenis <kettenis at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 25 Sep 2004 14:32:15 +0200 (CEST)
- Subject: [COMMIT] Inline attach and detach in inf-ptrace.c
This makes it possible to get rid of infptrace.o on hosts that use
inf-ptrace.o.
Andrew, you might want to check whether that works on NetBSD/powerpc.
I'm going to attack the i386 BSD's now.
Committed,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* inf-ptrace.c (inf_ptrace_attach): Remove redundant parenthesis.
Inline attach call.
(inf_ptrace_detach): Inline detach call.
Index: inf-ptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/inf-ptrace.c,v
retrieving revision 1.4
diff -u -p -r1.4 inf-ptrace.c
--- inf-ptrace.c 24 Sep 2004 22:43:37 -0000 1.4
+++ inf-ptrace.c 25 Sep 2004 12:27:49 -0000
@@ -336,7 +336,7 @@ inf_ptrace_attach (char *args, int from_
dummy = args;
pid = strtol (args, &dummy, 0);
/* Some targets don't set errno on errors, grrr! */
- if ((pid == 0) && (args == dummy))
+ if (pid == 0 && args == dummy)
error ("Illegal process-id: %s\n", args);
if (pid == getpid ()) /* Trying to masturbate? */
@@ -356,7 +356,15 @@ inf_ptrace_attach (char *args, int from_
gdb_flush (gdb_stdout);
}
- attach (pid);
+#ifdef PT_ATTACH
+ errno = 0;
+ ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3) 0, 0);
+ if (errno != 0)
+ perror_with_name ("ptrace");
+ attach_flag = 1;
+#else
+ error ("This system does not support attaching to a process");
+#endif
inferior_ptid = pid_to_ptid (pid);
push_target (ptrace_ops_hack);
@@ -379,7 +387,7 @@ inf_ptrace_post_attach (int pid)
static void
inf_ptrace_detach (char *args, int from_tty)
{
- int siggnal = 0;
+ int sig = 0;
int pid = PIDGET (inferior_ptid);
if (from_tty)
@@ -392,9 +400,17 @@ inf_ptrace_detach (char *args, int from_
gdb_flush (gdb_stdout);
}
if (args)
- siggnal = atoi (args);
+ sig = atoi (args);
- detach (siggnal);
+#ifdef PT_DETACH
+ errno = 0;
+ ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3) 1, sig);
+ if (errno != 0)
+ perror_with_name ("ptrace");
+ attach_flag = 0;
+#else
+ error ("This system does not support detaching from a process");
+#endif
inferior_ptid = null_ptid;
unpush_target (ptrace_ops_hack);