2005-04-21 16:53:53 +02:00
|
|
|
#include <lib.h>
|
|
|
|
#define ptrace _ptrace
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2010-04-21 13:05:22 +02:00
|
|
|
PUBLIC long ptrace(int req, pid_t pid, long addr, long data)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
|
|
|
m.m2_i1 = pid;
|
|
|
|
m.m2_i2 = req;
|
2009-09-21 16:45:46 +02:00
|
|
|
m.PMTRACE_ADDR = addr;
|
2005-04-21 16:53:53 +02:00
|
|
|
m.m2_l2 = data;
|
2010-06-08 15:58:01 +02:00
|
|
|
if (_syscall(PM_PROC_NR, PTRACE, &m) < 0) return(-1);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* There was no error, but -1 is a legal return value. Clear errno if
|
|
|
|
* necessary to distinguish this case. _syscall has set errno to nonzero
|
|
|
|
* for the error case.
|
|
|
|
*/
|
|
|
|
if (m.m2_l2 == -1) errno = 0;
|
|
|
|
return(m.m2_l2);
|
|
|
|
}
|