This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH]: PTRACE_PEEKUSER redux...
- From: "David S. Miller" <davem at davemloft dot net>
- To: drow at false dot org
- Cc: gdb-patches at sources dot redhat dot com
- Date: Thu, 06 Apr 2006 22:03:57 -0700 (PDT)
- Subject: [PATCH]: PTRACE_PEEKUSER redux...
Daniel, I've been thinking about that PTRACE_PEEKUSER dependency issue
in linux-nat.c some more. And it's kind of unreasonable to expect
people to get the latest and greatest Sparc Linux kernel in order to
get a working gdb setup.
Especially when we can handle this gracefully, and without much pain.
In all cases, no matter what ptrace operation is specified, if the
child does not exist the error return we will get is -ESRCH (task not
found for pid) or -EPERM (trying to trace init or similar).
Specifically checking for those two error codes allows us to cleanly
handle Linux targets that do not need to implement PTRACE_PEEKUSER.
Therefore, what do you think about the following patch?
2006-04-06 David S. Miller <davem@sunset.davemloft.net>
* linux-nat.c (linux_nat_thread_alive): Thread is alive
as long as errno is neither -ESRCH nor -EPERM. This allows
to handle cleanly the case where PTRACE_PEEKUSER is not
a supported ptrace operation for a given Linux target.
--- linux-nat.c.~1~ 2006-04-05 18:08:11.000000000 -0700
+++ linux-nat.c 2006-04-06 21:55:49.000000000 -0700
@@ -2382,7 +2383,7 @@ linux_nat_thread_alive (ptid_t ptid)
"LLTA: PTRACE_PEEKUSER %s, 0, 0 (%s)\n",
target_pid_to_str (ptid),
errno ? safe_strerror (errno) : "OK");
- if (errno)
+ if (errno == -ESRCH || errno == -EPERM)
return 0;
return 1;