* [PATCH]: PTRACE_PEEKUSER redux...
@ 2006-04-07 5:04 David S. Miller
2006-04-07 13:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: David S. Miller @ 2006-04-07 5:04 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH]: PTRACE_PEEKUSER redux...
2006-04-07 5:04 [PATCH]: PTRACE_PEEKUSER redux David S. Miller
@ 2006-04-07 13:16 ` Daniel Jacobowitz
2006-04-07 21:35 ` David S. Miller
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2006-04-07 13:16 UTC (permalink / raw)
To: David S. Miller; +Cc: gdb-patches
On Thu, Apr 06, 2006 at 10:03:57PM -0700, David S. Miller wrote:
> 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).
This relies on all platforms doing the permission check before the
operation check. Well, I guess it's still better than what we had
before, right?
> 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.
OK, except, please reverse the changelog and the patch :-) This
comment should be in the source code, or we'll break it again later.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]: PTRACE_PEEKUSER redux...
2006-04-07 13:16 ` Daniel Jacobowitz
@ 2006-04-07 21:35 ` David S. Miller
0 siblings, 0 replies; 3+ messages in thread
From: David S. Miller @ 2006-04-07 21:35 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
From: Daniel Jacobowitz <drow@false.org>
Date: Fri, 7 Apr 2006 09:16:23 -0400
> On Thu, Apr 06, 2006 at 10:03:57PM -0700, David S. Miller wrote:
> > 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).
>
> This relies on all platforms doing the permission check before the
> operation check. Well, I guess it's still better than what we had
> before, right?
I definitely think so.
> > 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.
>
> OK, except, please reverse the changelog and the patch :-) This
> comment should be in the source code, or we'll break it again later.
Ok, will do. Thanks a lot for reviewing.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-07 21:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07 5:04 [PATCH]: PTRACE_PEEKUSER redux David S. Miller
2006-04-07 13:16 ` Daniel Jacobowitz
2006-04-07 21:35 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox