Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ptrace(PT_CONTINUE, ...) returns EINVAL



I'm trying to use the ptrace API to test some code for race conditions; I basically just need to single step through it N times, deliver a signal, continue, and see what happens.

I can't get ptrace() to work. If I just attach to the (stopped) child process like this:

retval = ptrace(PT_ATTACH, childpid, 0, 0);

and continue like this:

errno = 0;
retval = ptrace(PT_CONTINUE, childpid, (caddr_t) 1, 0);

the continue call returns -1 and sets errno == EINVAL. None of the conditions listed in the manual page seem to apply. Why would this happen?

I also noticed the manual page and /usr/include/sys/ptrace.h are out of sync. The manual page seems to be from OpenBSD/sparc:

<http://developer.apple.com/documentation/Darwin/Reference/ManPages/ html/ptrace.2.html>

and /usr/include/sys/ptrace.h looks more like FreeBSD's:

<http://www.freebsd.org/cgi/man.cgi? query=ptrace&apropos=0&sektion=0&manpath=FreeBSD+5.2- RELEASE+and+Ports&format=html>

In particular, it has the PT_STEP request and the one described by the manual page does not. Which is accurate? If the header file is wrong, that could account for the EINVAL; the request number would be wrong.

Also, if there is no PT_STEP, how can I single-step through this program? I saw a paper which suggested setting a trace bit in a register (looks like bit 21 in the MSR). Is that the best way? Do PT_GETREGS and PT_SETREGS exist for the PowerPC as described in the sparc-specific portion of manual page?

Thanks,
Scott Lamb
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.