1 #include <sys/ptrace.h>
2 #include <stdarg.h>
3 #include <unistd.h>
4 #include "syscall.h"
5
ptrace(int req,...)6 long ptrace(int req, ...)
7 {
8 va_list ap;
9 pid_t pid;
10 void *addr, *data, *addr2 = 0;
11 long ret, result;
12
13 va_start(ap, req);
14 pid = va_arg(ap, pid_t);
15 addr = va_arg(ap, void *);
16 data = va_arg(ap, void *);
17 /* PTRACE_{READ,WRITE}{DATA,TEXT} (16...19) are specific to SPARC. */
18 #ifdef PTRACE_READDATA
19 if ((unsigned)req - PTRACE_READDATA < 4)
20 addr2 = va_arg(ap, void *);
21 #endif
22 va_end(ap);
23
24 if (req-1U < 3) data = &result;
25 ret = syscall(SYS_ptrace, req, pid, addr, data, addr2);
26
27 if (ret < 0 || req-1U >= 3) return ret;
28 return result;
29 }
30