pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/sysutils/strace



Module Name:    pkgsrc
Committed By:   christos
Date:           Tue Jan 22 22:07:33 UTC 2019

Modified Files:
        pkgsrc/sysutils/strace: Makefile distinfo
Added Files:
        pkgsrc/sysutils/strace/patches: patch-process.c patch-signal.c
            patch-syscall.c patch-util.c
Removed Files:
        pkgsrc/sysutils/strace/patches: patch-ao patch-aq patch-au patch-ba

Log Message:
make this compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 pkgsrc/sysutils/strace/Makefile
cvs rdiff -u -r1.22 -r1.23 pkgsrc/sysutils/strace/distinfo
cvs rdiff -u -r1.4 -r0 pkgsrc/sysutils/strace/patches/patch-ao \
    pkgsrc/sysutils/strace/patches/patch-aq
cvs rdiff -u -r1.5 -r0 pkgsrc/sysutils/strace/patches/patch-au
cvs rdiff -u -r1.1 -r0 pkgsrc/sysutils/strace/patches/patch-ba
cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/strace/patches/patch-process.c \
    pkgsrc/sysutils/strace/patches/patch-signal.c \
    pkgsrc/sysutils/strace/patches/patch-syscall.c \
    pkgsrc/sysutils/strace/patches/patch-util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/sysutils/strace/Makefile
diff -u pkgsrc/sysutils/strace/Makefile:1.28 pkgsrc/sysutils/strace/Makefile:1.29
--- pkgsrc/sysutils/strace/Makefile:1.28        Wed Aug 22 05:46:41 2018
+++ pkgsrc/sysutils/strace/Makefile     Tue Jan 22 17:07:33 2019
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.28 2018/08/22 09:46:41 wiz Exp $
+# $NetBSD: Makefile,v 1.29 2019/01/22 22:07:33 christos Exp $
 #
 
 DISTNAME=              strace-4.5.15
-PKGREVISION=           11
+PKGREVISION=           12
 CATEGORIES=            sysutils
 MASTER_SITES=          ${MASTER_SITE_SOURCEFORGE:=strace/}
 EXTRACT_SUFX=          .tar.bz2

Index: pkgsrc/sysutils/strace/distinfo
diff -u pkgsrc/sysutils/strace/distinfo:1.22 pkgsrc/sysutils/strace/distinfo:1.23
--- pkgsrc/sysutils/strace/distinfo:1.22        Thu Jun 29 02:33:29 2017
+++ pkgsrc/sysutils/strace/distinfo     Tue Jan 22 17:07:33 2019
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.22 2017/06/29 06:33:29 wiz Exp $
+$NetBSD: distinfo,v 1.23 2019/01/22 22:07:33 christos Exp $
 
 SHA1 (strace-4.5.15.tar.bz2) = a6bd153eeb1a25a50bb5a1d92887a4911ec9ad48
 RMD160 (strace-4.5.15.tar.bz2) = 0c6aaa8820a0985d89b21a5da9578b27435c8906
@@ -18,20 +18,20 @@ SHA1 (patch-ak) = 1b82f68c3a21bc24ce464f
 SHA1 (patch-al) = ea408e93a15c5fdd8054a65b409c60536ca928eb
 SHA1 (patch-am) = edb9a6a4b76b6f0a39427562fe96a73fea3ecf4a
 SHA1 (patch-an) = 23b55878f0f7c6b83b937219a3c730ec5c6cb7ea
-SHA1 (patch-ao) = 90c47a7437204258b7d17986f5a5a94a196d0a38
 SHA1 (patch-ap) = 8ed16f25eb9ef1c9c1499a77e7f39bf23d50e209
-SHA1 (patch-aq) = e900e4025525a598b0b1c7ce9586cd5fecd63093
 SHA1 (patch-ar) = 12b13f8b7e2054cbe57da6b502f3fe49b91de9ff
 SHA1 (patch-as) = b241a70fb33aabb8282578a124b04aca05f0d3f2
 SHA1 (patch-at) = 22107308d404984f6b1231ddca10bbc05bec864f
-SHA1 (patch-au) = f457bd074e88dd457c16b921645f42fd744d3cb7
 SHA1 (patch-av) = 7356db4dfc2f49d75f6bd2e7968ec053f2f3cbff
 SHA1 (patch-aw) = 31f8ddd02911ce083afe7927e99d9f76994a8451
 SHA1 (patch-ax) = c1202f287e53a7b94fa4778692192de3ae06de7c
 SHA1 (patch-ay) = 9a6942117fc4d26a9256a573559597560295d9c0
 SHA1 (patch-az) = af6272c48668785dffd7c5b42b8fa2c8edb562d0
-SHA1 (patch-ba) = be8e2f79bd8818b99bdce63fb73802f1a4014b2f
 SHA1 (patch-bb) = e7e309d96ec9fa2398a968f29f7e6549ff81e37e
 SHA1 (patch-bc) = 7eece85b62383a0f6cb3b8e9dbe2a9a0316c6c02
 SHA1 (patch-bd) = 6ad13b8b0130886cc87218d9acfe46d8f9fc82ef
 SHA1 (patch-be) = 6326b50b3d9be0524d67770d67530069866edd9e
+SHA1 (patch-process.c) = 99c20ea1b267f94e9d544a6ed60b0d840c86fa82
+SHA1 (patch-signal.c) = 414f003437f2b249c2c1d654c0db78a23ca37231
+SHA1 (patch-syscall.c) = d53b6515215a22ce560186a0d11081e02b939fa9
+SHA1 (patch-util.c) = fe19e41c4e7893c1b06d59f68969a2246a4f65f9

Added files:

Index: pkgsrc/sysutils/strace/patches/patch-process.c
diff -u /dev/null pkgsrc/sysutils/strace/patches/patch-process.c:1.1
--- /dev/null   Tue Jan 22 17:07:33 2019
+++ pkgsrc/sysutils/strace/patches/patch-process.c      Tue Jan 22 17:07:33 2019
@@ -0,0 +1,191 @@
+$NetBSD: patch-process.c,v 1.1 2019/01/22 22:07:33 christos Exp $
+
+--- process.c.orig     2007-01-11 17:08:38.000000000 -0500
++++ process.c  2019-01-22 16:54:25.476690976 -0500
+@@ -40,19 +40,22 @@
+ #include "defs.h"
+ 
+ #include <fcntl.h>
++#include <sys/param.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ #include <sys/wait.h>
+ #include <sys/resource.h>
+ #include <sys/utsname.h>
++#ifndef NETBSD
+ #include <sys/user.h>
++#endif
+ #include <sys/syscall.h>
+ #include <signal.h>
+ #ifdef SUNOS4
+ #include <machine/reg.h>
+ #endif /* SUNOS4 */
+ 
+-#ifdef FREEBSD
++#ifdef ALLBSD
+ #include <sys/ptrace.h>
+ #endif
+ 
+@@ -305,7 +308,7 @@
+ 
+ #endif /* HAVE_PRCTL */
+ 
+-#if defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
++#if defined(ALLBSD) || defined(SUNOS4) || defined(SVR4)
+ int
+ sys_gethostid(tcp)
+ struct tcb *tcp;
+@@ -314,7 +317,7 @@
+               return RVAL_HEX;
+       return 0;
+ }
+-#endif /* FREEBSD || SUNOS4 || SVR4 */
++#endif /* ALLBSD || SUNOS4 || SVR4 */
+ 
+ int
+ sys_sethostname(tcp)
+@@ -327,7 +330,7 @@
+       return 0;
+ }
+ 
+-#if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
++#if defined(ALPHA) || defined(ALLBSD) || defined(SUNOS4) || defined(SVR4)
+ int
+ sys_gethostname(tcp)
+ struct tcb *tcp;
+@@ -341,7 +344,7 @@
+       }
+       return 0;
+ }
+-#endif /* ALPHA || FREEBSD || SUNOS4 || SVR4 */
++#endif /* ALPHA || ALLBSD || SUNOS4 || SVR4 */
+ 
+ int
+ sys_setdomainname(tcp)
+@@ -1058,7 +1061,7 @@
+ 
+ #endif /* !USE_PROCFS */
+ 
+-#if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD)
++#if defined(SUNOS4) || defined(LINUX) || defined(ALLBSD)
+ 
+ int
+ sys_vfork(tcp)
+@@ -1069,7 +1072,7 @@
+       return 0;
+ }
+ 
+-#endif /* SUNOS4 || LINUX || FREEBSD */
++#endif /* SUNOS4 || LINUX || ALLBSD */
+ 
+ #ifndef LINUX
+ 
+@@ -2051,7 +2054,7 @@
+ 
+ #endif /* SVR4 */
+ 
+-#ifdef FREEBSD
++#ifdef ALLBSD
+ int
+ sys_wait(tcp)
+ struct tcb *tcp;
+@@ -2070,12 +2073,14 @@
+ }
+ #endif
+ 
++#ifndef NETBSD
+ int
+ sys_waitpid(tcp)
+ struct tcb *tcp;
+ {
+       return printwaitn(tcp, 3, 0);
+ }
++#endif
+ 
+ int
+ sys_wait4(tcp)
+@@ -2205,7 +2210,7 @@
+ #ifndef SVR4
+ 
+ static const struct xlat ptrace_cmds[] = {
+-#ifndef FREEBSD
++#ifndef ALLBSD
+       { PTRACE_TRACEME,       "PTRACE_TRACEME"        },
+       { PTRACE_PEEKTEXT,      "PTRACE_PEEKTEXT",      },
+       { PTRACE_PEEKDATA,      "PTRACE_PEEKDATA",      },
+@@ -2271,7 +2276,7 @@
+ #endif /* !I386 */
+       { PTRACE_GETUCODE,      "PTRACE_GETUCODE"       },
+ #endif /* SUNOS4 */
+-#else /* FREEBSD */
++#else /* ALLBSD */
+       { PT_TRACE_ME,          "PT_TRACE_ME"           },
+       { PT_READ_I,            "PT_READ_I"             },
+       { PT_READ_D,            "PT_READ_D"             },
+@@ -2282,20 +2287,26 @@
+ #endif
+       { PT_CONTINUE,          "PT_CONTINUE"           },
+       { PT_KILL,              "PT_KILL"               },
++#if !(defined(NETBSD) && (defined(ALPHA) || defined(SPARC) || defined(SPARC64)))
+       { PT_STEP,              "PT_STEP"               },
++#endif
+       { PT_ATTACH,            "PT_ATTACH"             },
+       { PT_DETACH,            "PT_DETACH"             },
+       { PT_GETREGS,           "PT_GETREGS"            },
+       { PT_SETREGS,           "PT_SETREGS"            },
+       { PT_GETFPREGS,         "PT_GETFPREGS"          },
+       { PT_SETFPREGS,         "PT_SETFPREGS"          },
++#ifdef PT_GETDBREGS
+       { PT_GETDBREGS,         "PT_GETDBREGS"          },
++#endif
++#ifdef PT_SETDBREGS
+       { PT_SETDBREGS,         "PT_SETDBREGS"          },
+-#endif /* FREEBSD */
++#endif
++#endif /* ALLBSD */
+       { 0,                    NULL                    },
+ };
+ 
+-#ifndef FREEBSD
++#ifndef ALLBSD
+ #ifndef SUNOS4_KERNEL_ARCH_KLUDGE
+ static
+ #endif /* !SUNOS4_KERNEL_ARCH_KLUDGE */
+@@ -2982,12 +2993,14 @@
+ sys_ptrace(tcp)
+ struct tcb *tcp;
+ {
++#ifndef NETBSD
+       const struct xlat *x;
++#endif
+       long addr;
+ 
+       if (entering(tcp)) {
+               printxval(ptrace_cmds, tcp->u_arg[0],
+-#ifndef FREEBSD
++#ifndef ALLBSD
+                         "PTRACE_???"
+ #else
+                         "PT_???"
+@@ -2995,7 +3008,7 @@
+                       );
+               tprintf(", %lu, ", tcp->u_arg[1]);
+               addr = tcp->u_arg[2];
+-#ifndef FREEBSD
++#ifndef ALLBSD
+               if (tcp->u_arg[0] == PTRACE_PEEKUSER
+                       || tcp->u_arg[0] == PTRACE_POKEUSER) {
+                       for (x = struct_user_offsets; x->str; x++) {
+@@ -3057,10 +3070,10 @@
+               }
+       }
+ #endif /* SUNOS4 */
+-#ifdef FREEBSD
++#ifdef ALLBSD
+               tprintf("%lu", tcp->u_arg[3]);
+       }
+-#endif /* FREEBSD */
++#endif /* ALLBSD */
+       return 0;
+ }
+ 
Index: pkgsrc/sysutils/strace/patches/patch-signal.c
diff -u /dev/null pkgsrc/sysutils/strace/patches/patch-signal.c:1.1
--- /dev/null   Tue Jan 22 17:07:33 2019
+++ pkgsrc/sysutils/strace/patches/patch-signal.c       Tue Jan 22 17:07:33 2019
@@ -0,0 +1,128 @@
+$NetBSD: patch-signal.c,v 1.1 2019/01/22 22:07:33 christos Exp $
+
+--- signal.c.orig      2007-01-11 17:08:38.000000000 -0500
++++ signal.c   2019-01-22 16:54:46.145801860 -0500
+@@ -36,12 +36,29 @@
+ #include "defs.h"
+ 
+ #include <signal.h>
++#include <sys/param.h>
++#ifndef NETBSD
+ #include <sys/user.h>
++#endif
+ #include <fcntl.h>
+ 
+-#ifdef SVR4
++#if defined(SVR4) || defined(NETBSD)
+ #include <sys/ucontext.h>
+ #endif /* SVR4 */
++#ifdef NETBSD
++#if !defined(UC_CPU) && defined(_UC_CPU)
++#define UC_CPU _UC_CPU
++#endif
++#if !defined(UC_SIGMASK) && defined(_UC_SIGMASK)
++#define UC_SIGMASK _UC_SIGMASK
++#endif
++#if !defined(UC_STACK) && defined(_UC_STACK)
++#define UC_STACK _UC_STACK
++#endif
++#if !defined(UC_FPU) && defined(_UC_FPU)
++#define UC_FPU _UC_FPU
++#endif
++#endif
+ 
+ #ifdef HAVE_SYS_REG_H
+ # include <sys/reg.h>
+@@ -1056,14 +1073,14 @@
+       return 0;
+ }
+ 
+-#if defined(SUNOS4) || defined(FREEBSD)
++#if defined(SUNOS4) || defined(ALLBSD)
+ int
+ sys_sigblock(tcp)
+ struct tcb *tcp;
+ {
+       return sys_sigsetmask(tcp);
+ }
+-#endif /* SUNOS4 || FREEBSD */
++#endif /* SUNOS4 || ALLBSD */
+ 
+ #endif /* !SVR4 */
+ 
+@@ -1165,13 +1182,13 @@
+               printsignal(tcp->u_arg[0]);
+               tprintf(", ");
+               switch (tcp->u_arg[1]) {
+-              case (int) SIG_ERR:
++              case (long) SIG_ERR:
+                       tprintf("SIG_ERR");
+                       break;
+-              case (int) SIG_DFL:
++              case (long) SIG_DFL:
+                       tprintf("SIG_DFL");
+                       break;
+-              case (int) SIG_IGN:
++              case (long) SIG_IGN:
+ #ifndef USE_PROCFS
+                       if (tcp->u_arg[0] == SIGTRAP) {
+                               tcp->flags |= TCB_SIGTRAPPED;
+@@ -1193,11 +1210,11 @@
+       }
+       else {
+               switch (tcp->u_rval) {
+-                  case (int) SIG_ERR:
++                  case (long) SIG_ERR:
+                       tcp->auxstr = "SIG_ERR"; break;
+-                  case (int) SIG_DFL:
++                  case (long) SIG_DFL:
+                       tcp->auxstr = "SIG_DFL"; break;
+-                  case (int) SIG_IGN:
++                  case (long) SIG_IGN:
+                       tcp->auxstr = "SIG_IGN"; break;
+                   default:
+                       tcp->auxstr = NULL;
+@@ -1489,7 +1506,7 @@
+ 
+ #endif /* LINUX */
+ 
+-#if defined(SVR4) || defined(FREEBSD)
++#if defined(SVR4) || defined(ALLBSD)
+ 
+ int
+ sys_sigsuspend(tcp)
+@@ -1521,7 +1538,7 @@
+ #endif /* !FREEBSD */
+ #endif /* SVR4 || FREEBSD */
+ 
+-#if defined SVR4 || defined LINUX || defined FREEBSD
++#if defined SVR4 || defined LINUX || defined ALLBSD
+ #if defined LINUX && !defined SS_ONSTACK
+ #define SS_ONSTACK      1
+ #define SS_DISABLE      2
+@@ -1613,7 +1630,7 @@
+ 
+ #endif /* SVR4 */
+ 
+-#if defined(LINUX) || defined(FREEBSD)
++#if defined(LINUX) || defined(ALLBSD)
+ 
+ static int
+ print_stack_t(tcp, addr)
+@@ -1702,14 +1719,14 @@
+       return 0;
+ }
+ 
+-#if defined(FREEBSD) || defined(SUNOS4)
++#if defined(ALLBSD) || defined(SUNOS4)
+ int
+ sys_killpg(tcp)
+ struct tcb *tcp;
+ {
+       return sys_kill(tcp);
+ }
+-#endif /* FREEBSD || SUNOS4 */
++#endif /* ALLBSD || SUNOS4 */
+ 
+ #ifdef LINUX
+ int
Index: pkgsrc/sysutils/strace/patches/patch-syscall.c
diff -u /dev/null pkgsrc/sysutils/strace/patches/patch-syscall.c:1.1
--- /dev/null   Tue Jan 22 17:07:33 2019
+++ pkgsrc/sysutils/strace/patches/patch-syscall.c      Tue Jan 22 17:07:33 2019
@@ -0,0 +1,349 @@
+$NetBSD: patch-syscall.c,v 1.1 2019/01/22 22:07:33 christos Exp $
+
+--- syscall.c.orig     2006-12-21 17:13:33.000000000 -0500
++++ syscall.c  2019-01-22 16:53:51.213106690 -0500
+@@ -38,9 +38,11 @@
+ #include <signal.h>
+ #include <time.h>
+ #include <errno.h>
++#include <sys/param.h>
++#ifndef NETBSD
+ #include <sys/user.h>
++#endif
+ #include <sys/syscall.h>
+-#include <sys/param.h>
+ 
+ #if HAVE_ASM_REG_H
+ #if defined (SPARC) || defined (SPARC64)
+@@ -56,6 +58,10 @@
+ #endif
+ #endif
+ 
++#ifdef NETBSD
++#include <machine/reg.h>
++#include <machine/psl.h>
++#endif
+ #ifdef HAVE_SYS_REG_H
+ #include <sys/reg.h>
+ #ifndef PTRACE_PEEKUSR
+@@ -467,16 +473,19 @@
+       for (p = strtok(s, ","); p; p = strtok(NULL, ",")) {
+               if (opt->bitflag == QUAL_TRACE && (n = lookup_class(p)) > 0) {
+                       for (i = 0; i < MAX_QUALS; i++) {
+-                              if (sysent0[i].sys_flags & n)
++                              if (i < __arraycount(sysent0) 
++                                  && (sysent0[i].sys_flags & n))
+                                       qualify_one(i, opt, not, 0);
+ 
+ #if SUPPORTED_PERSONALITIES >= 2
+-                              if (sysent1[i].sys_flags & n)
++                              if (i < __arraycount(sysent1) 
++                                  && (sysent1[i].sys_flags & n))
+                                       qualify_one(i, opt, not, 1);
+ #endif /* SUPPORTED_PERSONALITIES >= 2 */
+ 
+ #if SUPPORTED_PERSONALITIES >= 3
+-                              if (sysent2[i].sys_flags & n)
++                              if (i < __arraycount(sysent2) 
++                                  && (sysent2[i].sys_flags & n))
+                                       qualify_one(i, opt, not, 2);
+ #endif /* SUPPORTED_PERSONALITIES >= 3 */
+                       }
+@@ -580,6 +589,7 @@
+ 
+ #if !(defined(LINUX) && ( defined(ALPHA) || defined(MIPS) ))
+ 
++#if defined (SPARC) || defined (SPARC64)
+ static const int socket_map [] = {
+              /* SYS_SOCKET      */ 97,
+              /* SYS_BIND        */ 104,
+@@ -600,7 +610,6 @@
+              /* SYS_RECVMSG     */ 113
+ };
+ 
+-#if defined (SPARC) || defined (SPARC64)
+ static void
+ sparc_socket_decode (tcp)
+ struct tcb *tcp;
+@@ -624,6 +633,7 @@
+ }
+ #endif
+ 
++#ifndef NETBSD
+ static void
+ decode_subcall(tcp, subcall, nsubcalls, style)
+ struct tcb *tcp;
+@@ -709,6 +719,7 @@
+ #endif /* FREEBSD */
+       }
+ }
++#endif /* !NETBSD */
+ #endif
+ 
+ struct tcb *tcp_last = NULL;
+@@ -747,7 +758,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 +767,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 +825,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 +1297,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, &regs, sizeof(regs), 0) < 0) {
+               perror("pread");
+                 return -1;
+@@ -1299,8 +1313,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 *)&regs, 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 +1372,9 @@
+ struct tcb *tcp;
+ {
+ #ifndef USE_PROCFS
++#ifndef NETBSD
+       int pid = tcp->pid;
++#endif
+ #else /* USE_PROCFS */
+       int scno = known_scno(tcp);
+ 
+@@ -1698,17 +1747,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 +1959,32 @@
+                 return -1;
+         }
+ #endif /* FREEBSD */
++#ifdef NETBSD
++      if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 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 *)&regs, 0) < 0)
++              return -1;
++#endif /* NETBSD */
+ 
+       /* All branches reach here on success (only).  */
+       tcp->u_error = error;
+@@ -1903,7 +1997,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 +2297,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 +2718,19 @@
+       pread(tcp->pfd_reg, &regs, sizeof(regs), 0);
+       val = regs.r_edx;
+ #endif
++#ifdef NETBSD
++      struct reg regs;
++      if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 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;
+ }
+ 
Index: pkgsrc/sysutils/strace/patches/patch-util.c
diff -u /dev/null pkgsrc/sysutils/strace/patches/patch-util.c:1.1
--- /dev/null   Tue Jan 22 17:07:33 2019
+++ pkgsrc/sysutils/strace/patches/patch-util.c Tue Jan 22 17:07:33 2019
@@ -0,0 +1,71 @@
+$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 <signal.h>
++#include <sys/param.h>
+ #include <sys/syscall.h>
++#ifndef NETBSD
+ #include <sys/user.h>
+-#include <sys/param.h>
++#endif
+ #include <fcntl.h>
+ #if HAVE_SYS_UIO_H
+ #include <sys/uio.h>
+@@ -58,6 +60,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 +101,7 @@
+ # define PTRACE_SETREGS PTRACE_SETREGS64
+ #endif /* SPARC64 */
+ 
++
+ #if !defined(__GLIBC__)
+ 
+ #include <linux/unistd.h>
+@@ -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, &regs, sizeof(regs), 0);
+       return regs.r_eip;
+ #endif /* FREEBSD */
++#ifdef NETBSD
++      struct reg regs;
++      if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) &regs, 0) < 0) {
++              perror("getpc: ptrace(PTRACE_GETREGS, ...)");
++              return -1;
++      }
++      return regs.r_eip;
++#endif /* NETBSD */
+ }
+ #endif
+ 



Home | Main Index | Thread Index | Old Index