$NetBSD: patch-ap,v 1.1 2006/03/05 08:17:49 christos Exp $ --- util.c 2005-10-21 18:06:46.000000000 -0400 +++ util.c 2006-03-04 22:32:21.000000000 -0500 @@ -36,9 +36,9 @@ #include "defs.h" #include +#include #include #include -#include #include #if HAVE_SYS_UIO_H #include @@ -58,6 +58,9 @@ # include #endif +#ifdef NETBSD +#include +#endif #ifdef HAVE_SYS_REG_H #include # define PTRACE_PEEKUSR PTRACE_PEEKUSER @@ -96,6 +99,7 @@ # define PTRACE_SETREGS PTRACE_SETREGS64 #endif /* SPARC64 */ + #if !defined(__GLIBC__) #include @@ -759,6 +763,20 @@ return -1; #endif /* USE_PROCFS */ +#ifdef NETBSD + struct ptrace_io_desc piod; + + piod.piod_op = PIOD_READ_D; + piod.piod_offs = (void *)addr; + piod.piod_addr = laddr; + piod.piod_len = len; + + if (ptrace(PT_IO, tcp->pid, (char *)&piod, sizeof(piod)) < 0) { + perror("PT_IO"); + return -1; + } +#endif + return 0; } @@ -1079,6 +1097,14 @@ pread(tcp->pfd_reg, ®s, sizeof(regs), 0); return regs.r_eip; #endif /* FREEBSD */ +#ifdef NETBSD + struct reg regs; + if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) ®s, 0) < 0) { + perror("getpc: ptrace(PTRACE_GETREGS, ...)"); + return -1; + } + return regs.r_eip; +#endif /* NETBSD */ } #endif