$NetBSD: patch-ba,v 1.1 2007/04/27 19:45:03 christos Exp $ --- util.c.orig 2005-10-21 18:06:46.000000000 -0400 +++ util.c 2007-04-27 11:31:51.000000000 -0400 @@ -36,9 +36,9 @@ #include "defs.h" #include <signal.h> +#include <sys/param.h> #include <sys/syscall.h> #include <sys/user.h> -#include <sys/param.h> #include <fcntl.h> #if HAVE_SYS_UIO_H #include <sys/uio.h> @@ -58,6 +58,9 @@ # include <asm/rse.h> #endif +#ifdef NETBSD +#include <machine/reg.h> +#endif #ifdef HAVE_SYS_REG_H #include <sys/reg.h> # define PTRACE_PEEKUSR PTRACE_PEEKUSER @@ -96,6 +99,7 @@ # define PTRACE_SETREGS PTRACE_SETREGS64 #endif /* SPARC64 */ + #if !defined(__GLIBC__) #include <linux/unistd.h> @@ -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