$NetBSD: patch-util.c,v 1.1 2019/01/22 22:07:33 christos Exp $ --- util.c.orig 2007-01-11 17:08:38.000000000 -0500 +++ util.c 2019-01-22 16:54:09.288699797 -0500 @@ -36,9 +36,11 @@ #include "defs.h" #include +#include #include +#ifndef NETBSD #include -#include +#endif #include #if HAVE_SYS_UIO_H #include @@ -58,6 +60,9 @@ # include #endif +#ifdef NETBSD +#include +#endif #ifdef HAVE_SYS_REG_H #include # define PTRACE_PEEKUSR PTRACE_PEEKUSER @@ -96,6 +101,7 @@ # define PTRACE_SETREGS PTRACE_SETREGS64 #endif /* SPARC64 */ + #if !defined(__GLIBC__) #include @@ -777,6 +783,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; } @@ -1097,6 +1117,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