ptrace PTRACE_PEEKUSER bug ?

Cedric ROUX (roux@ecoledoc.lip6.fr)
Sat, 2 Oct 1999 17:10:41 +0200 (MEST)


Hi kernel hackers,

the following call gives strange results :

(We've got unsigned long d,e and we do ptrace a son that
did a ptrace(PTRACE_TRACEME, 0, 0, 0); then an execl on
a program, any one. We are on a PC plateforme, linux 2.2.12
(I tried it on a 2.0.36, same results.))

if ((d=ptrace(PTRACE_PEEKUSER, sonpid, 12*4, &e))==-1) {
perror("ptrace");
return -1;
}
fprintf(stderr, "eip=%lx or %lx ?\n", d, e);

I am supposed to get in "e" the value of eip and in d the return value
of ptrace (0 if ok, -1 if problems), but in fact, the value get stored
in "d" and "e" is not changed !

I do this ptrace call after a wait and after I've checked the son was
not dead. I do ptrace it with ptrace(PTRACE_SINGLESTEP, sonpid, 1, 0)
and it works fine. The problem is this particular ptrace (PTRACE_PEEKUSER).

Except it all is fine (without it, I get what I expect, ie. the son is
traced on every single instruction).

Another thing is when an illegal instruction occurs (let's say I do a jmp
to a unmapped area). Without tracing, the process generates a core, but
with it, it seems to be blocked on the illegal address, the values returned
by wait don't say the process is dead or something.

Very very strange behavior. Or maybe I missed something ? I must say
I've got no documentation except the kernel sources, so I do it by
trying.

If anyone can explain me waht's going on, that would be grateful.

Thank you by advance,
Sed.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/