head 1.6; access; symbols pkgsrc-2018Q4:1.5.0.16 pkgsrc-2018Q4-base:1.5 pkgsrc-2018Q3:1.5.0.14 pkgsrc-2018Q3-base:1.5 pkgsrc-2018Q2:1.5.0.12 pkgsrc-2018Q2-base:1.5 pkgsrc-2018Q1:1.5.0.10 pkgsrc-2018Q1-base:1.5 pkgsrc-2017Q4:1.5.0.8 pkgsrc-2017Q4-base:1.5 pkgsrc-2017Q3:1.5.0.6 pkgsrc-2017Q3-base:1.5 pkgsrc-2017Q2:1.5.0.2 pkgsrc-2017Q2-base:1.5 pkgsrc-2017Q1:1.4.0.60 pkgsrc-2017Q1-base:1.4 pkgsrc-2016Q4:1.4.0.58 pkgsrc-2016Q4-base:1.4 pkgsrc-2016Q3:1.4.0.56 pkgsrc-2016Q3-base:1.4 pkgsrc-2016Q2:1.4.0.54 pkgsrc-2016Q2-base:1.4 pkgsrc-2016Q1:1.4.0.52 pkgsrc-2016Q1-base:1.4 pkgsrc-2015Q4:1.4.0.50 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.48 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.46 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.44 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.42 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.40 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.38 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.36 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.34 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.32 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.30 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.4.0.28 pkgsrc-2013Q1-base:1.4 pkgsrc-2012Q4:1.4.0.26 pkgsrc-2012Q4-base:1.4 pkgsrc-2012Q3:1.4.0.24 pkgsrc-2012Q3-base:1.4 pkgsrc-2012Q2:1.4.0.22 pkgsrc-2012Q2-base:1.4 pkgsrc-2012Q1:1.4.0.20 pkgsrc-2012Q1-base:1.4 pkgsrc-2011Q4:1.4.0.18 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.16 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.14 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.12 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.4.0.10 pkgsrc-2010Q4-base:1.4 pkgsrc-2010Q3:1.4.0.8 pkgsrc-2010Q3-base:1.4 pkgsrc-2010Q2:1.4.0.6 pkgsrc-2010Q2-base:1.4 pkgsrc-2010Q1:1.4.0.4 pkgsrc-2010Q1-base:1.4 pkgsrc-2009Q4:1.4.0.2 pkgsrc-2009Q4-base:1.4 pkgsrc-2009Q3:1.3.0.20 pkgsrc-2009Q3-base:1.3 pkgsrc-2009Q2:1.3.0.18 pkgsrc-2009Q2-base:1.3 pkgsrc-2009Q1:1.3.0.16 pkgsrc-2009Q1-base:1.3 pkgsrc-2008Q4:1.3.0.14 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.12 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.10 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.3.0.8 pkgsrc-2008Q2-base:1.3 cwrapper:1.3.0.6 pkgsrc-2008Q1:1.3.0.4 pkgsrc-2008Q1-base:1.3 pkgsrc-2007Q4:1.3.0.2 pkgsrc-2007Q4-base:1.3 pkgsrc-2007Q3:1.2.0.4 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.2.0.2 pkgsrc-2007Q2-base:1.2; locks; strict; comment @# @; 1.6 date 2019.01.22.22.07.33; author christos; state dead; branches; next 1.5; commitid HGFAwVlb79iCoP8B; 1.5 date 2017.06.27.15.26.05; author christos; state Exp; branches; next 1.4; commitid y78i0Gp8GuJOC1Xz; 1.4 date 2009.12.29.22.03.41; author spz; state Exp; branches; next 1.3; 1.3 date 2007.12.05.16.31.01; author christos; state Exp; branches; next 1.2; 1.2 date 2007.04.28.03.42.31; author christos; state Exp; branches; next 1.1; 1.1 date 2007.04.27.19.45.02; author christos; state Exp; branches; next ; desc @@ 1.6 log @make this compile again. @ text @$NetBSD: patch-au,v 1.5 2017/06/27 15:26:05 christos Exp $ --- syscall.c.orig 2006-12-21 17:13:33.000000000 -0500 +++ syscall.c 2017-06-27 11:17:20.342117800 -0400 @@@@ -38,9 +38,9 @@@@ #include #include #include +#include #include #include -#include #if HAVE_ASM_REG_H #if defined (SPARC) || defined (SPARC64) @@@@ -56,6 +56,10 @@@@ #endif #endif +#ifdef NETBSD +#include +#include +#endif #ifdef HAVE_SYS_REG_H #include #ifndef PTRACE_PEEKUSR @@@@ -624,6 +628,7 @@@@ } #endif +#ifndef NETBSD static void decode_subcall(tcp, subcall, nsubcalls, style) struct tcb *tcp; @@@@ -709,6 +714,7 @@@@ #endif /* FREEBSD */ } } +#endif /* !NETBSD */ #endif struct tcb *tcp_last = NULL; @@@@ -747,7 +753,7 @@@@ #endif if ( sys_execve == func -#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) +#if !defined(NETBSD) && (defined(SPARC) || defined(SPARC64) || defined(SUNOS4)) || sys_execv == func #endif #if UNIXWARE > 2 @@@@ -756,11 +762,14 @@@@ ) return internal_exec(tcp); - if ( sys_waitpid == func - || sys_wait4 == func -#if defined(SVR4) || defined(FREEBSD) || defined(SUNOS4) + if ( + sys_wait4 == func +#ifndef NETBSD + || sys_waitpid == func +#if defined(SVR4) || defined(ALLBSD) || defined(SUNOS4) || sys_wait == func #endif +#endif #ifdef ALPHA || sys_osf_wait4 == func #endif @@@@ -811,9 +820,9 @@@@ static long rax; #endif #endif /* LINUX */ -#ifdef FREEBSD - struct reg regs; -#endif /* FREEBSD */ +#ifdef ALLBSD + static struct reg regs; +#endif /* ALLBSD */ int get_scno(tcp) @@@@ -1283,9 +1292,9 @@@@ #ifdef HAVE_PR_SYSCALL scno = tcp->status.PR_SYSCALL; #else /* !HAVE_PR_SYSCALL */ -#ifndef FREEBSD +#ifndef ALLBSD scno = tcp->status.PR_WHAT; -#else /* FREEBSD */ +#else /* ALLBSD */ if (pread(tcp->pfd_reg, ®s, sizeof(regs), 0) < 0) { perror("pread"); return -1; @@@@ -1299,8 +1308,41 @@@@ scno = regs.r_eax; break; } -#endif /* FREEBSD */ +#endif /* ALLBSD */ #endif /* !HAVE_PR_SYSCALL */ +#else /* !USE_PROCFS */ +#ifdef NETBSD + if (ptrace(PTRACE_GETREGS,pid,(char *)®s, 0) < 0) { + perror("GETREGS"); + return -1; + } +#ifdef __i386__ + switch (regs.r_eax) { + case SYS_syscall: + case SYS___syscall: + if ((scno = ptrace(PTRACE_PEEKUSER, pid, + (char *)regs.r_esp + sizeof(int), sizeof(int))) == -1) { + perror("PEEKUSER __syscall"); + return -1; + } + break; + default: + scno = regs.r_eax; + break; + } +#endif +#ifdef __x86_64__ + switch (regs.regs[_REG_RAX]) { + case SYS_syscall: + case SYS___syscall: + scno = regs.regs[_REG_RDI]; + break; + default: + scno = regs.regs[_REG_RAX]; + break; + } +#endif +#endif /* NETBSD */ #endif /* USE_PROCFS */ if (!(tcp->flags & TCB_INSYSCALL)) tcp->scno = scno; @@@@ -1325,7 +1367,9 @@@@ struct tcb *tcp; { #ifndef USE_PROCFS +#ifndef NETBSD int pid = tcp->pid; +#endif #else /* USE_PROCFS */ int scno = known_scno(tcp); @@@@ -1698,17 +1742,36 @@@@ } #endif /* MIPS */ #endif /* SVR4 */ -#ifdef FREEBSD +#ifdef ALLBSD +#ifdef __i386__ if (regs.r_eflags & PSL_C) { tcp->u_rval = -1; u_error = regs.r_eax; } else { tcp->u_rval = regs.r_eax; +#if 0 + /* XXX Linux only */ tcp->u_lrval = ((unsigned long long) regs.r_edx << 32) + regs.r_eax; +#endif u_error = 0; } -#endif /* FREEBSD */ +#endif +#ifdef __x86_64__ + if (regs.regs[_REG_RFL] & PSL_C) { + tcp->u_rval = -1; + u_error = regs.regs[_REG_RAX]; + } else { + tcp->u_rval = regs.regs[_REG_RAX]; +#if 0 + /* XXX Linux only */ + tcp->u_lrval = + ((unsigned long long) regs.regs[_REG_RDX] << 64) + regs.regs[_REG_RAX]; +#endif + u_error = 0; + } +#endif +#endif /* ALLBSD */ tcp->u_error = u_error; return 1; } @@@@ -1891,6 +1954,32 @@@@ return -1; } #endif /* FREEBSD */ +#ifdef NETBSD + if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) + return -1; +#ifdef __i386__ + if (error) { + regs.r_eflags |= PSL_C; + regs.r_eax = error; + } + else { + regs.r_eflags &= ~PSL_C; + regs.r_eax = rval; + } +#endif +#ifdef __x86_64__ + if (error) { + regs.regs[_REG_RFL] |= PSL_C; + regs.regs[_REG_RAX] = error; + } + else { + regs.regs[_REG_RFL] &= ~PSL_C; + regs.regs[_REG_RAX] = rval; + } +#endif + if (ptrace(PTRACE_SETREGS, tcp->pid, (char *)®s, 0) < 0) + return -1; +#endif /* NETBSD */ /* All branches reach here on success (only). */ tcp->u_error = error; @@@@ -1903,7 +1992,9 @@@@ struct tcb *tcp; { #ifndef USE_PROCFS +#ifndef NETBSD int pid = tcp->pid; +#endif #endif /* !USE_PROCFS */ #ifdef LINUX #if defined(S390) || defined(S390X) @@@@ -2201,6 +2292,58 @@@@ I DONT KNOW WHAT TO DO #endif /* !HAVE_PR_SYSCALL */ #endif /* SVR4 */ +#ifdef NETBSD + if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1) + tcp->u_nargs = sysent[tcp->scno].nargs; + else + tcp->u_nargs = 5; +#ifdef __i386__ + switch(regs.r_eax) { + case SYS___syscall: + umoven(tcp, regs.r_esp + sizeof(int) + sizeof(quad_t), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); + break; + case SYS_syscall: + umoven(tcp, regs.r_esp + 2 * sizeof(int), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); + break; + default: + umoven(tcp, regs.r_esp + sizeof(int), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); + break; + } +#endif +#ifdef __x86_64__ +{ + int bias, i; + static int ar[2][6] = { + { _REG_RDI, _REG_RSI, _REG_RDX, + _REG_R10, _REG_R8, _REG_R9 }, /* x86-64 ABI */ + { _REG_RBX, _REG_RCX, _REG_RDX, + _REG_RSI, _REG_RDI, _REG_RBP } /* i386 ABI */ + }; + switch(regs.regs[_REG_RAX]) { + case SYS___syscall: + case SYS_syscall: + bias = 1; + break; + default: + bias = 0; + break; + } + for (i = 0; i < tcp->u_nargs; i++) { + tcp->u_arg[i] = regs.regs[ar[0][i + bias]]; +#if 0 + if (upeek(tcp->pid, ar[0][i + bias] * 8, &tcp->u_arg[i]) < 0) + return -1; +#endif + } +} +#endif +#endif /* NETBSD */ #ifdef FREEBSD if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs > tcp->status.val) @@@@ -2570,6 +2713,19 @@@@ pread(tcp->pfd_reg, ®s, sizeof(regs), 0); val = regs.r_edx; #endif +#ifdef NETBSD + struct reg regs; + if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, sizeof(regs)) < 0) { + perror("PTRACE_GETREGS get edx"); + return -1; + } +#ifdef __i386__ + val = regs.r_edx; +#endif +#ifdef __x86_64__ + val = regs.regs[_REG_RDX]; +#endif +#endif /* NETBSD */ return val; } @ 1.5 log @make this compile again. @ text @d1 1 a1 1 $NetBSD: patch-au,v 1.4 2009/12/29 22:03:41 spz Exp $ @ 1.4 log @compile fixes for a leaf package for non-x86 NetBSD (note that there are no claims of making it actually work) @ text @d1 1 a1 1 $NetBSD: patch-au,v 1.3 2007/12/05 16:31:01 christos Exp $ d3 2 a4 2 --- syscall.c.orig 2006-12-21 23:13:33.000000000 +0100 +++ syscall.c 2009-12-29 21:45:24.000000000 +0100 d52 1 a52 1 @@@@ -756,9 +762,12 @@@@ a62 1 +#endif d66 1 d68 2 @ 1.3 log @Use newer strace 4.5.15; various improvements in syscall parsing and split functions into more files. @ text @d1 1 a1 1 $NetBSD$ d3 2 a4 2 --- syscall.c.orig 2006-12-21 17:13:33.000000000 -0500 +++ syscall.c 2007-12-05 11:16:26.000000000 -0500 d22 1 a22 1 +#include d43 9 @ 1.2 log @make x86_64 work. @ text @d1 1 a1 1 $NetBSD: patch-au,v 1.1 2007/04/27 19:45:02 christos Exp $ d3 2 a4 2 --- syscall.c.orig 2006-01-12 05:18:53.000000000 -0500 +++ syscall.c 2007-04-27 23:32:49.000000000 -0400 d27 1 a27 1 @@@@ -634,6 +638,7 @@@@ d35 1 a35 1 @@@@ -719,6 +724,7 @@@@ d43 17 a59 1 @@@@ -855,9 +861,9 @@@@ d72 1 a72 1 @@@@ -1318,9 +1324,9 @@@@ d84 1 a84 1 @@@@ -1334,8 +1340,41 @@@@ d127 1 a127 1 @@@@ -1360,7 +1399,9 @@@@ d137 1 a137 1 @@@@ -1733,17 +1774,36 @@@@ d176 1 a176 1 @@@@ -1926,6 +1986,32 @@@@ d209 1 a209 1 @@@@ -1938,7 +2024,9 @@@@ d219 1 a219 1 @@@@ -2236,6 +2324,58 @@@@ d278 1 a278 1 @@@@ -2648,6 +2788,19 @@@@ @ 1.1 log @- make this work again on NetBSD/i386 - make this compile on NetBSD/x86_64 [does not work yet] - completely automate the NetBSD header generation. This should make porting to other platforms easier. @ text @d1 1 a1 1 $NetBSD$ d4 1 a4 1 +++ syscall.c 2007-04-26 18:09:23.000000000 -0400 d68 1 a68 1 @@@@ -1334,8 +1340,45 @@@@ d100 1 a100 5 + if ((scno = ptrace(PTRACE_PEEKUSER, pid, + (char *)regs.regs[_REG_URSP] + sizeof(regs.regs[0]), sizeof(regs.regs[0]))) == -1) { + perror("PEEKUSER __syscall"); + return -1; + } d111 1 a111 1 @@@@ -1360,7 +1403,9 @@@@ d121 1 a121 1 @@@@ -1733,17 +1778,36 @@@@ d160 1 a160 1 @@@@ -1926,6 +1990,32 @@@@ d193 1 a193 1 @@@@ -1938,7 +2028,9 @@@@ d203 1 a203 1 @@@@ -2236,6 +2328,50 @@@@ d232 8 a241 4 + umoven(tcp, regs.regs[_REG_URSP] + sizeof(regs.regs[0]) + sizeof(quad_t), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); + break; d243 1 a243 3 + umoven(tcp, regs.regs[_REG_URSP] + 2 * sizeof(regs.regs[0]), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); d246 1 a246 3 + umoven(tcp, regs.regs[_REG_URSP] + sizeof(regs.regs[0]), + tcp->u_nargs * sizeof(unsigned long), + (char *) tcp->u_arg); d249 8 d262 1 a262 1 @@@@ -2648,6 +2784,19 @@@@ @