#ifndef _SYS_PTRACE_H_
#define _SYS_PTRACE_H_
#include <sys/siginfo.h>
#include <sys/signal.h>
#define PT_TRACE_ME 0
#define PT_READ_I 1
#define PT_READ_D 2
#define PT_WRITE_I 4
#define PT_WRITE_D 5
#define PT_CONTINUE 7
#define PT_KILL 8
#define PT_ATTACH 9
#define PT_DETACH 10
#define PT_IO 11
#define PT_DUMPCORE 12
#if defined(__LEGACY_PT_LWPINFO) || defined(_KERNEL)
#define PT_LWPINFO 13
#endif
#define PT_SYSCALL 14
#define PT_SYSCALLEMU 15
#define PT_SET_EVENT_MASK 16
#define PT_GET_EVENT_MASK 17
#define PT_GET_PROCESS_STATE 18
#define PT_SET_SIGINFO 19
#define PT_GET_SIGINFO 20
#define PT_RESUME 21
#define PT_SUSPEND 22
#define PT_STOP 23
#define PT_LWPSTATUS 24
#define PT_LWPNEXT 25
#define PT_SET_SIGPASS 26
#define PT_GET_SIGPASS 27
#define PT_FIRSTMACH 32
#include <machine/ptrace.h>
#ifndef PT_MACHDEP_STRINGS
# define PT_MACHDEP_STRINGS
#endif
#define PT_STRINGS \
"PT_TRACE_ME", \
"PT_READ_I", \
"PT_READ_D", \
"*PT_INVALID_3*", \
"PT_WRITE_I", \
"PT_WRITE_D", \
"*PT_INVALID_6*", \
"PT_CONTINUE", \
"PT_KILL", \
"PT_ATTACH", \
"PT_DETACH", \
"PT_IO", \
"PT_DUMPCORE", \
"PT_LWPINFO", \
"PT_SYSCALL", \
"PT_SYSCALLEMU", \
"PT_SET_EVENT_MASK", \
"PT_GET_EVENT_MASK", \
"PT_GET_PROCESS_STATE", \
"PT_SET_SIGINFO", \
"PT_GET_SIGINFO", \
"PT_RESUME", \
"PT_SUSPEND", \
"PT_STOP", \
"PT_LWPSTATUS", \
"PT_LWPNEXT", \
"PT_SET_SIGPASS", \
"PT_GET_SIGPASS", \
"*PT_INVALID_28", \
"*PT_INVALID_29", \
"*PT_INVALID_30", \
"*PT_INVALID_31", \
PT_MACHDEP_STRINGS
typedef struct ptrace_event {
int pe_set_event;
} ptrace_event_t;
typedef struct ptrace_state {
int pe_report_event;
union {
pid_t _pe_other_pid;
lwpid_t _pe_lwp;
} _option;
} ptrace_state_t;
#define pe_other_pid _option._pe_other_pid
#define pe_lwp _option._pe_lwp
#define PTRACE_FORK 0x0001
#define PTRACE_VFORK 0x0002
#define PTRACE_VFORK_DONE 0x0004
#define PTRACE_LWP_CREATE 0x0008
#define PTRACE_LWP_EXIT 0x0010
#define PTRACE_POSIX_SPAWN 0x0020
struct ptrace_io_desc {
int piod_op;
void *piod_offs;
void *piod_addr;
size_t piod_len;
};
#define PIOD_READ_D 1
#define PIOD_WRITE_D 2
#define PIOD_READ_I 3
#define PIOD_WRITE_I 4
#define PIOD_READ_AUXV 5
#if defined(__LEGACY_PT_LWPINFO) || defined(_KERNEL)
struct ptrace_lwpinfo {
lwpid_t pl_lwpid;
int pl_event;
};
#define PL_EVENT_NONE 0
#define PL_EVENT_SIGNAL 1
#define PL_EVENT_SUSPENDED 2
#endif
#define PL_LNAMELEN 20
struct ptrace_lwpstatus {
lwpid_t pl_lwpid;
sigset_t pl_sigpend;
sigset_t pl_sigmask;
char pl_name[PL_LNAMELEN];
void *pl_private;
};
typedef struct ptrace_siginfo {
siginfo_t psi_siginfo;
lwpid_t psi_lwpid;
} ptrace_siginfo_t;
#ifdef _KERNEL
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd32.h"
#endif
#ifdef COMPAT_NETBSD32
#include <compat/netbsd32/netbsd32.h>
#define process_read_lwpstatus32 netbsd32_read_lwpstatus
#define process_lwpstatus32 struct netbsd32_ptrace_lwpstatus
#endif
#ifndef process_lwpstatus32
#define process_lwpstatus32 struct ptrace_lwpstatus
#endif
#ifndef process_lwpstatus64
#define process_lwpstatus64 struct ptrace_lwpstatus
#endif
#if defined(PT_GETREGS) || defined(PT_SETREGS)
struct reg;
#ifndef process_reg32
#define process_reg32 struct reg
#endif
#ifndef process_reg64
#define process_reg64 struct reg
#endif
#endif
#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
struct fpreg;
#ifndef process_fpreg32
#define process_fpreg32 struct fpreg
#endif
#ifndef process_fpreg64
#define process_fpreg64 struct fpreg
#endif
#endif
#if defined(PT_GETDBREGS) || defined(PT_SETDBREGS)
struct dbreg;
#ifndef process_dbreg32
#define process_dbreg32 struct dbreg
#endif
#ifndef process_dbreg64
#define process_dbreg64 struct dbreg
#endif
#endif
struct ptrace_methods {
int (*ptm_copyin_piod)(struct ptrace_io_desc *, const void *, size_t);
int (*ptm_copyout_piod)(const struct ptrace_io_desc *, void *, size_t);
int (*ptm_copyin_siginfo)(struct ptrace_siginfo *, const void *, size_t);
int (*ptm_copyout_siginfo)(const struct ptrace_siginfo *, void *, size_t);
int (*ptm_copyout_lwpstatus)(const struct ptrace_lwpstatus *, void *, size_t);
int (*ptm_doregs)(struct lwp *, struct lwp *, struct uio *);
int (*ptm_dofpregs)(struct lwp *, struct lwp *, struct uio *);
int (*ptm_dodbregs)(struct lwp *, struct lwp *, struct uio *);
};
int ptrace_update_lwp(struct proc *t, struct lwp **lt, lwpid_t lid);
void ptrace_hooks(void);
int process_doregs(struct lwp *, struct lwp *, struct uio *);
int process_validregs(struct lwp *);
int process_dofpregs(struct lwp *, struct lwp *, struct uio *);
int process_validfpregs(struct lwp *);
int process_dodbregs(struct lwp *, struct lwp *, struct uio *);
int process_validdbregs(struct lwp *);
int process_domem(struct lwp *, struct lwp *, struct uio *);
void proc_stoptrace(int, int, const register_t[], const register_t *, int);
void proc_reparent(struct proc *, struct proc *);
void proc_changeparent(struct proc *, struct proc *);
int do_ptrace(struct ptrace_methods *, struct lwp *, int, pid_t, void *,
int, register_t *);
void ptrace_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *);
void process_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *);
#ifndef process_read_lwpstatus32
#define process_read_lwpstatus32 process_read_lwpstatus
#endif
#ifndef process_read_lwpstatus64
#define process_read_lwpstatus64 process_read_lwpstatus
#endif
#ifdef PT_GETDBREGS
int process_read_dbregs(struct lwp *, struct dbreg *, size_t *);
#ifndef process_read_dbregs32
#define process_read_dbregs32 process_read_dbregs
#endif
#ifndef process_read_dbregs64
#define process_read_dbregs64 process_read_dbregs
#endif
#endif
#ifdef PT_GETFPREGS
int process_read_fpregs(struct lwp *, struct fpreg *, size_t *);
#ifndef process_read_fpregs32
#define process_read_fpregs32 process_read_fpregs
#endif
#ifndef process_read_fpregs64
#define process_read_fpregs64 process_read_fpregs
#endif
#endif
#ifdef PT_GETREGS
int process_read_regs(struct lwp *, struct reg *);
#ifndef process_read_regs32
#define process_read_regs32 process_read_regs
#endif
#ifndef process_read_regs64
#define process_read_regs64 process_read_regs
#endif
#endif
int process_set_pc(struct lwp *, void *);
int process_sstep(struct lwp *, int);
#ifdef PT_SETDBREGS
int process_write_dbregs(struct lwp *, const struct dbreg *, size_t);
#ifndef process_write_dbregs32
#define process_write_dbregs32 process_write_dbregs
#endif
#ifndef process_write_dbregs64
#define process_write_dbregs64 process_write_dbregs
#endif
#endif
#ifdef PT_SETFPREGS
int process_write_fpregs(struct lwp *, const struct fpreg *, size_t);
#ifndef process_write_fpregs32
#define process_write_fpregs32 process_write_fpregs
#endif
#ifndef process_write_fpregs64
#define process_write_fpregs64 process_write_fpregs
#endif
#endif
#ifdef PT_SETREGS
int process_write_regs(struct lwp *, const struct reg *);
#ifndef process_write_regs32
#define process_write_regs32 process_write_regs
#endif
#ifndef process_write_regs64
#define process_write_regs64 process_write_regs
#endif
#endif
int ptrace_machdep_dorequest(struct lwp *, struct lwp **, int,
void *, int);
#ifndef FIX_SSTEP
#define FIX_SSTEP(p)
#endif
typedef int (*ptrace_regrfunc_t)(struct lwp *, void *, size_t *);
typedef int (*ptrace_regwfunc_t)(struct lwp *, void *, size_t);
#if defined(PTRACE)
# if defined(PT_SETREGS) || defined(PT_GETREGS)
# define PT_REGS
# endif
# if defined(PT_SETFPREGS) || defined(PT_GETFPREGS)
# define PT_FPREGS
# endif
# if defined(PT_SETDBREGS) || defined(PT_GETDBREGS)
# define PT_DBREGS
# endif
# if defined(PT_REGS) || defined(PT_FPREGS) || defined(PT_DBREGS)
# define PT_REGISTERS
# endif
#endif
#else
#include <sys/cdefs.h>
__BEGIN_DECLS
int ptrace(int _request, pid_t _pid, void *_addr, int _data);
__END_DECLS
#endif
#endif