Re: ptrace : newbie problem

From: Mike Coleman (mkc@kc.net)
Date: Tue Mar 14 2000 - 05:04:41 EST


Shourya Sarcar <sarcar@vsnl.com> writes:
> The following piece of code gives me and error while doing the ptrace
> (PTRACE_PEEKDATA,....) call. Why ? strace shows an EIO error.

> int st,err;
> long data[20];
...
> waitpid(cpid,&st,WUNTRACED);
> err=ptrace(PTRACE_PEEKDATA,cpid,st,data);

The third arg should be "&st" rather than "st". This is the address that
you're peeking, and the value in st is likely nonsense as a pointer. See a
recent ptrace(2) for more info.

Note also that the value peeked will show up in 'err' here. The fourth
argument is ignored in the PEEKDATA case. This is because of the way the libc
wrapper works.

--Mike

-- 
Any sufficiently adverse technology is indistinguishable from Microsoft.

- 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/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:27 EST