2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
#include <string.h>
|
2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/ptrace.h>
|
|
|
|
|
2013-12-10 18:18:13 +01:00
|
|
|
int ptrace(int req, pid_t pid, void *addr, int data)
|
2011-02-17 18:11:09 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
memset(&m, 0, sizeof(m));
|
2014-05-13 10:07:12 +02:00
|
|
|
m.m_lc_pm_ptrace.pid = pid;
|
|
|
|
m.m_lc_pm_ptrace.req = req;
|
|
|
|
m.m_lc_pm_ptrace.addr = addr;
|
|
|
|
m.m_lc_pm_ptrace.data = data;
|
2013-11-04 22:48:08 +01:00
|
|
|
if (_syscall(PM_PROC_NR, PM_PTRACE, &m) < 0) return(-1);
|
2011-02-17 18:11:09 +01: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.
|
|
|
|
*/
|
2014-05-13 10:07:12 +02:00
|
|
|
if (m.m_pm_lc_ptrace.data == -1) errno = 0;
|
|
|
|
return(m.m_pm_lc_ptrace.data);
|
2011-02-17 18:11:09 +01:00
|
|
|
}
|