resending this, here's the thread that initially mentioned... threads
handling:

  http://marc.info/?l=openbsd-ports&m=146326792311581&w=2

Any call to ptrace(PT_*REGS) is changed to use get_ptrace_pid() which
does the right thing for multi-threaded programs.  I don't have the
affected architectures at hand but the diff seems harmless.

Also running the test suite now requires dejagnu.  (Lots of tests fail,
though.)  Threads handling and TEST_DEPENDS parts to be committed
separately.

ok?


Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/gdb/Makefile,v
retrieving revision 1.42
diff -u -p -r1.42 Makefile
--- Makefile    8 Aug 2016 08:58:27 -0000       1.42
+++ Makefile    3 Sep 2016 12:18:18 -0000
@@ -4,6 +4,7 @@ COMMENT=        GNU debugger
 CATEGORIES=    devel
 
 DISTNAME=      gdb-7.11.1
+REVISION=      0
 
 HOMEPAGE=      https://www.gnu.org/software/gdb/
 
@@ -32,6 +33,7 @@ USE_GMAKE=    Yes
 
 MODULES +=     lang/python
 LIB_DEPENDS +=         ${MODPY_LIB_DEPENDS}
+TEST_DEPENDS +=        devel/dejagnu
 MODPY_BUILDDEP = No
 
 .include <bsd.port.mk>
Index: patches/patch-gdb_alphabsd-nat_c
===================================================================
RCS file: patches/patch-gdb_alphabsd-nat_c
diff -N patches/patch-gdb_alphabsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_alphabsd-nat_c    3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+--- gdb/alphabsd-nat.c.orig    Wed Feb 10 04:19:39 2016
++++ gdb/alphabsd-nat.c Sat May 14 22:54:35 2016
+@@ -91,7 +91,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *
+     {
+       struct reg gregs;
+ 
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
+       perror_with_name (_("Couldn't get registers"));
+ 
+@@ -105,7 +105,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+@@ -123,13 +123,13 @@ alphabsd_store_inferior_registers (struct target_ops *
+   if (regno == -1 || getregs_supplies (regno))
+     {
+       struct reg gregs;
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                   (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
+         perror_with_name (_("Couldn't get registers"));
+ 
+       alphabsd_fill_reg (regcache, (char *) &gregs, regno);
+ 
+-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+                   (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
+         perror_with_name (_("Couldn't write registers"));
+ 
+@@ -142,13 +142,13 @@ alphabsd_store_inferior_registers (struct target_ops *
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+       alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
+ 
+-      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't write floating point status"));
+     }
Index: patches/patch-gdb_armnbsd-nat_c
===================================================================
RCS file: patches/patch-gdb_armnbsd-nat_c
diff -N patches/patch-gdb_armnbsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_armnbsd-nat_c     3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,93 @@
+$OpenBSD$
+--- gdb/armnbsd-nat.c.orig     Wed Feb 10 04:19:39 2016
++++ gdb/armnbsd-nat.c  Sat May 14 22:54:35 2016
+@@ -77,7 +77,7 @@ fetch_register (struct regcache *regcache, int regno)
+   struct reg inferior_registers;
+   int ret;
+ 
+-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+ 
+   if (ret < 0)
+@@ -130,7 +130,7 @@ fetch_regs (struct regcache *regcache)
+   int ret;
+   int regno;
+ 
+-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+ 
+   if (ret < 0)
+@@ -148,7 +148,7 @@ fetch_fp_register (struct regcache *regcache, int regn
+   struct fpreg inferior_fp_registers;
+   int ret;
+ 
+-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+ 
+   if (ret < 0)
+@@ -178,7 +178,7 @@ fetch_fp_regs (struct regcache *regcache)
+   int ret;
+   int regno;
+ 
+-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+ 
+   if (ret < 0)
+@@ -216,7 +216,7 @@ store_register (const struct regcache *regcache, int r
+   struct reg inferior_registers;
+   int ret;
+ 
+-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+ 
+   if (ret < 0)
+@@ -279,7 +279,7 @@ store_register (const struct regcache *regcache, int r
+       break;
+     }
+ 
+-  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+ 
+   if (ret < 0)
+@@ -327,7 +327,7 @@ store_regs (const struct regcache *regcache)
+       inferior_registers.r_pc = pc_val | psr_val;
+     }
+ 
+-  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+ 
+   if (ret < 0)
+@@ -340,7 +340,7 @@ store_fp_register (const struct regcache *regcache, in
+   struct fpreg inferior_fp_registers;
+   int ret;
+ 
+-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+ 
+   if (ret < 0)
+@@ -362,7 +362,7 @@ store_fp_register (const struct regcache *regcache, in
+       break;
+     }
+ 
+-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+ 
+   if (ret < 0)
+@@ -384,7 +384,7 @@ store_fp_regs (const struct regcache *regcache)
+   regcache_raw_collect (regcache, ARM_FPS_REGNUM,
+                       (char *) &inferior_fp_registers.fpr_fpsr);
+ 
+-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++  ret = ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+ 
+   if (ret < 0)
Index: patches/patch-gdb_hppaobsd-nat_c
===================================================================
RCS file: patches/patch-gdb_hppaobsd-nat_c
diff -N patches/patch-gdb_hppaobsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_hppaobsd-nat_c    3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+--- gdb/hppaobsd-nat.c.orig    Wed Feb 10 04:19:39 2016
++++ gdb/hppaobsd-nat.c Sat May 14 22:54:35 2016
+@@ -193,7 +193,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
+     {
+       struct reg regs;
+ 
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+       perror_with_name (_("Couldn't get registers"));
+ 
+@@ -204,7 +204,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+@@ -223,13 +223,13 @@ hppaobsd_store_registers (struct target_ops *ops,
+     {
+       struct reg regs;
+ 
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                   (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+         perror_with_name (_("Couldn't get registers"));
+ 
+       hppaobsd_collect_gregset (regcache, &regs, regnum);
+ 
+-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+         perror_with_name (_("Couldn't write registers"));
+     }
+@@ -238,13 +238,13 @@ hppaobsd_store_registers (struct target_ops *ops,
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+       hppaobsd_collect_fpregset (regcache, &fpregs, regnum);
+ 
+-      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't write floating point status"));
+     }
Index: patches/patch-gdb_m88kbsd-nat_c
===================================================================
RCS file: patches/patch-gdb_m88kbsd-nat_c
diff -N patches/patch-gdb_m88kbsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_m88kbsd-nat_c     3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,28 @@
+$OpenBSD$
+--- gdb/m88kbsd-nat.c.orig     Wed Feb 10 04:19:39 2016
++++ gdb/m88kbsd-nat.c  Sat May 14 22:54:35 2016
+@@ -68,7 +68,7 @@ m88kbsd_fetch_inferior_registers (struct target_ops *o
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+@@ -84,13 +84,13 @@ m88kbsd_store_inferior_registers (struct target_ops *o
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+   m88kbsd_collect_gregset (regcache, &regs, regnum);
+ 
+-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't write registers"));
+ }
Index: patches/patch-gdb_mips64obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_mips64obsd-nat_c
diff -N patches/patch-gdb_mips64obsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_mips64obsd-nat_c  3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,28 @@
+$OpenBSD$
+--- gdb/mips64obsd-nat.c.orig  Wed Feb 10 04:19:39 2016
++++ gdb/mips64obsd-nat.c       Sat May 14 22:54:35 2016
+@@ -83,7 +83,7 @@ mips64obsd_fetch_inferior_registers (struct target_ops
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+@@ -99,13 +99,13 @@ mips64obsd_store_inferior_registers (struct target_ops
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+   mips64obsd_collect_gregset (regcache, &regs, regnum);
+ 
+-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't write registers"));
+ }
Index: patches/patch-gdb_ppcobsd-nat_c
===================================================================
RCS file: patches/patch-gdb_ppcobsd-nat_c
diff -N patches/patch-gdb_ppcobsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_ppcobsd-nat_c     3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,56 @@
+$OpenBSD$
+--- gdb/ppcobsd-nat.c.orig     Wed Feb 10 04:19:39 2016
++++ gdb/ppcobsd-nat.c  Sat May 14 22:54:35 2016
+@@ -76,7 +76,7 @@ ppcobsd_fetch_registers (struct target_ops *ops,
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+@@ -93,7 +93,7 @@ ppcobsd_fetch_registers (struct target_ops *ops,
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+@@ -112,7 +112,7 @@ ppcobsd_store_registers (struct target_ops *ops,
+ {
+   struct reg regs;
+ 
+-  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't get registers"));
+ 
+@@ -123,7 +123,7 @@ ppcobsd_store_registers (struct target_ops *ops,
+                       regnum, &regs, sizeof regs);
+ #endif
+ 
+-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++  if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+     perror_with_name (_("Couldn't write registers"));
+ 
+@@ -133,14 +133,14 @@ ppcobsd_store_registers (struct target_ops *ops,
+     {
+       struct fpreg fpregs;
+ 
+-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't get floating point status"));
+ 
+       ppc_collect_fpregset (&ppcobsd_fpregset, regcache,
+                           regnum, &fpregs, sizeof fpregs);
+ 
+-      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+       perror_with_name (_("Couldn't write floating point status"));
+     }
Index: patches/patch-gdb_shnbsd-nat_c
===================================================================
RCS file: patches/patch-gdb_shnbsd-nat_c
diff -N patches/patch-gdb_shnbsd-nat_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_shnbsd-nat_c      3 Sep 2016 12:18:18 -0000
@@ -0,0 +1,30 @@
+$OpenBSD$
+--- gdb/shnbsd-nat.c.orig      Wed Feb 10 04:19:39 2016
++++ gdb/shnbsd-nat.c   Sat May 14 22:54:35 2016
+@@ -49,7 +49,7 @@ shnbsd_fetch_inferior_registers (struct target_ops *op
+     {
+       struct reg inferior_registers;
+ 
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+       perror_with_name (_("Couldn't get registers"));
+ 
+@@ -70,7 +70,7 @@ shnbsd_store_inferior_registers (struct target_ops *op
+     {
+       struct reg inferior_registers;
+ 
+-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+       perror_with_name (_("Couldn't get registers"));
+ 
+@@ -78,7 +78,7 @@ shnbsd_store_inferior_registers (struct target_ops *op
+                                 (char *) &inferior_registers,
+                                 SHNBSD_SIZEOF_GREGS);
+ 
+-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+                 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+       perror_with_name (_("Couldn't set registers"));
+ 

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to