Index: devel/gdb/Makefile
===================================================================
--- devel/gdb/Makefile (revision 379209)
+++ devel/gdb/Makefile (working copy)
@@ -3,6 +3,7 @@
PORTNAME= gdb
PORTVERSION= 7.8.2
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= GNU
@@ -69,11 +70,6 @@
EXCLUDE+= readline
.endif
-.if ${PORT_OPTIONS:MTHREADS}
-EXTRA_PATCHES+= ${FILESDIR}/extrapatch-gdb-configure.tgt \
- ${FILESDIR}/extrapatch-gdb-Makefile.in
-.endif
-
.if ${ARCH} == "amd64"
CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL}
.endif
@@ -81,9 +77,9 @@
post-patch:
@${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \
${WRKSRC}/gdb/version.in
-
.if ${PORT_OPTIONS:MTHREADS}
@${CP} ${FILESDIR}/fbsd-threads.c ${WRKSRC}/gdb/
+ @${PATCH} ${PATCH_ARGS} < ${FILESDIR}/extrapatch-threads
.endif
do-install:
Index: devel/gdb/files/extrapatch-gdb-Makefile.in
===================================================================
--- devel/gdb/files/extrapatch-gdb-Makefile.in (revision 379209)
+++ devel/gdb/files/extrapatch-gdb-Makefile.in (working copy)
@@ -1,28 +0,0 @@
---- gdb/Makefile.in.orig 2013-04-02 19:38:43.000000000 +0200
-+++ gdb/Makefile.in 2013-05-18 13:08:47.000000000 +0200
-@@ -585,6 +585,7 @@
- xtensa-config.o xtensa-tdep.o xtensa-linux-tdep.o \
- glibc-tdep.o \
- bsd-uthread.o \
-+ fbsd-threads.o \
- nbsd-tdep.o obsd-tdep.o \
- sol2-tdep.o \
- solib-frv.o solib-irix.o solib-svr4.o \
-@@ -1173,7 +1174,7 @@
- # Removing the old gdb first works better if it is running, at least on SunOS.
- gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
- rm -f gdb$(EXEEXT)
-- $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
-+ $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) -Wl,-E \
- -o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
- $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
-
-@@ -1442,7 +1443,7 @@
- armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \
- avr-tdep.c \
- bfin-linux-tdep.c bfin-tdep.c \
-- bsd-uthread.c bsd-kvm.c \
-+ bsd-uthread.c fbsd-threads.c bsd-kvm.c \
- core-regset.c \
- dcache.c dicos-tdep.c darwin-nat.c \
- exec.c \
Index: devel/gdb/files/extrapatch-gdb-configure.tgt
===================================================================
--- devel/gdb/files/extrapatch-gdb-configure.tgt (revision 379209)
+++ devel/gdb/files/extrapatch-gdb-configure.tgt (working copy)
@@ -1,29 +0,0 @@
---- gdb/configure.tgt.orig 2013-03-05 14:37:10.000000000 +0100
-+++ gdb/configure.tgt 2013-05-18 13:11:06.000000000 +0200
-@@ -188,7 +188,7 @@
- i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
- # Target: FreeBSD/i386
- gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
-- bsd-uthread.o solib-svr4.o"
-+ fbsd-threads.o solib-svr4.o"
- ;;
- i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
- # Target: NetBSD/i386
-@@ -398,7 +398,7 @@
- powerpc*-*-freebsd*)
- # Target: FreeBSD/powerpc
- gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
-- ppcfbsd-tdep.o solib-svr4.o \
-+ ppcfbsd-tdep.o solib-svr4.o fbsd-threads.o \
- ravenscar-thread.o ppc-ravenscar-thread.o"
- ;;
-
-@@ -650,7 +650,7 @@
- # Target: FreeBSD/amd64
- gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \
- i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
-- bsd-uthread.o solib-svr4.o"
-+ fbsd-threads.o solib-svr4.o"
- ;;
- x86_64-*-mingw* | x86_64-*-cygwin*)
- # Target: MingW/amd64
Index: devel/gdb/files/extrapatch-threads
===================================================================
--- devel/gdb/files/extrapatch-threads (revision 0)
+++ devel/gdb/files/extrapatch-threads (working copy)
@@ -0,0 +1,712 @@
+diff --git a/gdb/Makefile.in b/gdb/Makefile.in
+index ea27cf5..d17752f 100644
+--- gdb/Makefile.in
++++ gdb/Makefile.in
+@@ -668,6 +668,7 @@ ALL_TARGET_OBS = \
+ xtensa-config.o xtensa-tdep.o xtensa-linux-tdep.o \
+ glibc-tdep.o \
+ bsd-uthread.o \
++ fbsd-threads.o \
+ nbsd-tdep.o obsd-tdep.o \
+ sol2-tdep.o \
+ solib-frv.o solib-irix.o solib-svr4.o \
+@@ -1327,7 +1328,7 @@ libgdb.a: $(LIBGDB_OBS)
+ # Removing the old gdb first works better if it is running, at least on SunOS.
+ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
+ rm -f gdb$(EXEEXT)
+- $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
++ $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) -Wl,-E \
+ -o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
+ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
+
+@@ -1600,7 +1601,7 @@ ALLDEPFILES = \
+ armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \
+ avr-tdep.c \
+ bfin-linux-tdep.c bfin-tdep.c \
+- bsd-uthread.c bsd-kvm.c \
++ bsd-uthread.c fbsd-threads.c bsd-kvm.c \
+ core-regset.c \
+ dcache.c dicos-tdep.c darwin-nat.c \
+ exec.c \
+diff --git a/gdb/amd64bsd-nat.c b/gdb/amd64bsd-nat.c
+index 9e6a0df..7aff6f0 100644
+--- gdb/amd64bsd-nat.c
++++ gdb/amd64bsd-nat.c
+@@ -41,6 +41,19 @@
+ size_t x86_xsave_len;
+ #endif
+
++static pid_t
++ptrace_pid (ptid_t ptid)
++{
++ pid_t pid;
++
++#ifdef __FreeBSD__
++ pid = ptid_get_lwp (ptid);
++ if (pid == 0)
++#endif
++ pid = ptid_get_pid (ptid);
++ return pid;
++}
++
+ /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
+ for all registers (including the floating-point registers). */
+
+@@ -54,7 +67,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+@@ -72,7 +85,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+ if (x86_xsave_len != 0)
+ {
+ xstateregs = alloca(x86_xsave_len);
+- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+@@ -81,7 +94,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+ }
+ #endif
+
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+@@ -104,11 +117,11 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
+
+ memset( ®s, 0, sizeof(struct reg));
+ memset( &oldregs, 0, sizeof(struct reg));
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+- ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &oldregs, 0);
+ amd64_collect_native_gregset (regcache, ®s, regnum);
+
+@@ -118,7 +131,7 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
+ regs.r_rflags ^= (regs.r_rflags ^ oldregs.r_rflags ) & ~PSL_USERCHANGE;
+ //printf(" allowed regs.r_rflags = 0x%8.8X\n", regs.r_rflags );
+ }
+- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+@@ -135,26 +148,26 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
+ if (x86_xsave_len != 0)
+ {
+ xstateregs = alloca(x86_xsave_len);
+- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+ amd64_collect_xsave (regcache, regnum, xstateregs, 0);
+
+- if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1)
+ perror_with_name (_("Couldn't write extended state status"));
+ return;
+ }
+ #endif
+
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ amd64_collect_fxsave (regcache, regnum, &fpregs);
+
+- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+@@ -184,7 +197,7 @@ amd64bsd_dr_get (ptid_t ptid, int regnum)
+ {
+ struct dbreg dbregs;
+
+- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't read debug registers"));
+
+@@ -196,7 +209,7 @@ amd64bsd_dr_set (int regnum, unsigned long value)
+ {
+ struct dbreg dbregs;
+
+- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't get debug registers"));
+
+@@ -207,7 +220,7 @@ amd64bsd_dr_set (int regnum, unsigned long value)
+
+ DBREG_DRX ((&dbregs), regnum) = value;
+
+- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't write debug registers"));
+ }
+diff --git a/gdb/amd64fbsd-nat.c b/gdb/amd64fbsd-nat.c
+index eea2472..9ce6a54 100644
+--- gdb/amd64fbsd-nat.c
++++ gdb/amd64fbsd-nat.c
+@@ -18,6 +18,7 @@
+ along with this program. If not, see . */
+
+ #include "defs.h"
++#include "gregset.h"
+ #include "inferior.h"
+ #include "regcache.h"
+ #include "target.h"
+@@ -95,6 +96,46 @@ static int amd64fbsd32_r_reg_offset[I386_NUM_GREGS] =
+ };
+
+
++/* Transfering the registers between GDB, inferiors and core files. */
++
++/* Fill GDB's register array with the general-purpose register values
++ in *GREGSETP. */
++
++void
++supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
++{
++ amd64_supply_native_gregset (regcache, gregsetp, -1);
++}
++
++/* Fill register REGNUM (if it is a general-purpose register) in
++ *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
++ do this for all registers. */
++
++void
++fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
++{
++ amd64_collect_native_gregset (regcache, gregsetp, regnum);
++}
++
++/* Fill GDB's register array with the floating-point register values
++ in *FPREGSETP. */
++
++void
++supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
++{
++ amd64_supply_fxsave (regcache, -1, fpregsetp);
++}
++
++/* Fill register REGNUM (if it is a floating-point register) in
++ *FPREGSETP with the value in GDB's register array. If REGNUM is -1,
++ do this for all registers. */
++
++void
++fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
++{
++ amd64_collect_fxsave (regcache, regnum, fpregsetp);
++}
++
+ /* Support for debugging kernel virtual memory images. */
+
+ #include
+diff --git a/gdb/amd64fbsd-tdep.c b/gdb/amd64fbsd-tdep.c
+index 582ae50..8e07369 100644
+--- gdb/amd64fbsd-tdep.c
++++ gdb/amd64fbsd-tdep.c
+@@ -31,7 +31,6 @@
+ #include
+
+ #include "amd64-tdep.h"
+-#include "bsd-uthread.h"
+ #include "solib-svr4.h"
+
+ /* Supported register note sections. */
+@@ -178,46 +177,6 @@ amd64fbsd_core_read_description (struct gdbarch *gdbarch,
+ }
+
+ static void
+-amd64fbsd_supply_uthread (struct regcache *regcache,
+- int regnum, CORE_ADDR addr)
+-{
+- gdb_byte buf[8];
+- int i;
+-
+- gdb_assert (regnum >= -1);
+-
+- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++)
+- {
+- if (amd64fbsd_jmp_buf_reg_offset[i] != -1
+- && (regnum == -1 || regnum == i))
+- {
+- read_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8);
+- regcache_raw_supply (regcache, i, buf);
+- }
+- }
+-}
+-
+-static void
+-amd64fbsd_collect_uthread (const struct regcache *regcache,
+- int regnum, CORE_ADDR addr)
+-{
+- gdb_byte buf[8];
+- int i;
+-
+- gdb_assert (regnum >= -1);
+-
+- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++)
+- {
+- if (amd64fbsd_jmp_buf_reg_offset[i] != -1
+- && (regnum == -1 || regnum == i))
+- {
+- regcache_raw_collect (regcache, i, buf);
+- write_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8);
+- }
+- }
+-}
+-
+-static void
+ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+@@ -245,10 +204,6 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ set_gdbarch_core_read_description (gdbarch,
+ amd64fbsd_core_read_description);
+
+- /* FreeBSD provides a user-level threads implementation. */
+- bsd_uthread_set_supply_uthread (gdbarch, amd64fbsd_supply_uthread);
+- bsd_uthread_set_collect_uthread (gdbarch, amd64fbsd_collect_uthread);
+-
+ /* FreeBSD uses SVR4-style shared libraries. */
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
+diff --git a/gdb/configure.tgt b/gdb/configure.tgt
+index 01311b2..0929a25 100644
+--- gdb/configure.tgt
++++ gdb/configure.tgt
+@@ -189,7 +189,7 @@ i[34567]86-*-dicos*)
+ i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
+ # Target: FreeBSD/i386
+ gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
+- bsd-uthread.o solib-svr4.o"
++ fbsd-threads.o solib-svr4.o"
+ ;;
+ i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
+ # Target: NetBSD/i386
+@@ -415,7 +415,7 @@ nios2*-*-*)
+ powerpc*-*-freebsd*)
+ # Target: FreeBSD/powerpc
+ gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
+- ppcfbsd-tdep.o solib-svr4.o \
++ ppcfbsd-tdep.o solib-svr4.o fbsd-threads.o \
+ ravenscar-thread.o ppc-ravenscar-thread.o"
+ ;;
+
+@@ -667,7 +667,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
+ # Target: FreeBSD/amd64
+ gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \
+ i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
+- bsd-uthread.o solib-svr4.o"
++ fbsd-threads.o solib-svr4.o"
+ ;;
+ x86_64-*-mingw* | x86_64-*-cygwin*)
+ # Target: MingW/amd64
+diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c
+index c26e830..246acdd 100644
+--- gdb/i386bsd-nat.c
++++ gdb/i386bsd-nat.c
+@@ -89,9 +89,22 @@ size_t x86_xsave_len;
+ #endif
+
+
++static pid_t
++ptrace_pid (ptid_t ptid)
++{
++ pid_t pid;
++
++#ifdef __FreeBSD__
++ pid = ptid_get_lwp (ptid);
++ if (pid == 0)
++#endif
++ pid = ptid_get_pid (ptid);
++ return pid;
++}
++
+ /* Supply the general-purpose registers in GREGS, to REGCACHE. */
+
+-static void
++void
+ i386bsd_supply_gregset (struct regcache *regcache, const void *gregs)
+ {
+ const char *regs = gregs;
+@@ -110,7 +123,7 @@ i386bsd_supply_gregset (struct regcache *regcache, const void *gregs)
+ GREGS. If REGNUM is -1, collect and store all appropriate
+ registers. */
+
+-static void
++void
+ i386bsd_collect_gregset (const struct regcache *regcache,
+ void *gregs, int regnum)
+ {
+@@ -140,7 +153,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+@@ -162,7 +175,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+ char *xstateregs;
+
+ xstateregs = alloca(x86_xsave_len);
+- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+@@ -174,7 +187,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+
+ #ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
++ && ptrace(PT_GETXMMREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+ {
+ have_ptrace_xmmregs = 1;
+@@ -184,7 +197,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+ {
+ have_ptrace_xmmregs = 0;
+ #endif
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+@@ -206,13 +219,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
+ {
+ struct reg regs;
+
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ i386bsd_collect_gregset (regcache, ®s, regnum);
+
+- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+@@ -233,13 +246,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
+ char *xstateregs;
+
+ xstateregs = alloca(x86_xsave_len);
+- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
+ perror_with_name (_("Couldn't get extended state status"));
+
+ i387_collect_xsave (regcache, -1, xstateregs, 0);
+
+- if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETXSTATE, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1)
+ perror_with_name (_("Couldn't write extended state status"));
+ }
+@@ -247,14 +260,14 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
+
+ #ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
++ && ptrace(PT_GETXMMREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+ {
+ have_ptrace_xmmregs = 1;
+
+ i387_collect_fxsave (regcache, regnum, xmmregs);
+
+- if (ptrace (PT_SETXMMREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETXMMREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
+ perror_with_name (_("Couldn't write XMM registers"));
+ }
+@@ -262,13 +275,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
+ {
+ have_ptrace_xmmregs = 0;
+ #endif
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ i387_collect_fsave (regcache, regnum, &fpregs);
+
+- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ #ifdef HAVE_PT_GETXMMREGS
+@@ -307,7 +320,7 @@ i386bsd_dr_get (ptid_t ptid, int regnum)
+ {
+ struct dbreg dbregs;
+
+- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't read debug registers"));
+
+@@ -319,7 +332,7 @@ i386bsd_dr_set (int regnum, unsigned int value)
+ {
+ struct dbreg dbregs;
+
+- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't get debug registers"));
+
+@@ -330,7 +343,7 @@ i386bsd_dr_set (int regnum, unsigned int value)
+
+ DBREG_DRX ((&dbregs), regnum) = value;
+
+- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETDBREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't write debug registers"));
+ }
+diff --git a/gdb/i386bsd-nat.h b/gdb/i386bsd-nat.h
+index 044f530..2fca773 100644
+--- gdb/i386bsd-nat.h
++++ gdb/i386bsd-nat.h
+@@ -38,6 +38,14 @@ extern CORE_ADDR i386bsd_dr_get_addr (int regnum);
+
+ extern unsigned long i386bsd_dr_get_status (void);
+
++/* low level i386 register functions used in i386fbsd-nat.c. */
++
++extern void i386bsd_supply_gregset (struct regcache *regcache,
++ const void *gregs);
++
++extern void i386bsd_collect_gregset (const struct regcache *regcache,
++ void *gregs, int regnum);
++
+ extern unsigned long i386bsd_dr_get_control (void);
+
+ #endif /* i386bsd-nat.h */
+diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c
+index b9620e1..71abcdf 100644
+--- gdb/i386fbsd-nat.c
++++ gdb/i386fbsd-nat.c
+@@ -21,6 +21,7 @@
+ #include "inferior.h"
+ #include "regcache.h"
+ #include "target.h"
++#include "gregset.h"
+
+ #include
+ #include
+@@ -82,6 +83,49 @@ i386fbsd_resume (struct target_ops *ops,
+ }
+
+
++/* Transfering the registers between GDB, inferiors and core files. */
++
++/* Fill GDB's register array with the general-purpose register values
++ in *GREGSETP. */
++
++void
++supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
++{
++ i386bsd_supply_gregset (regcache, gregsetp);
++}
++
++/* Fill register REGNUM (if it is a general-purpose register) in
++ *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
++ do this for all registers. */
++
++void
++fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
++{
++ i386bsd_collect_gregset (regcache, gregsetp, regnum);
++}
++
++#include "i387-tdep.h"
++
++/* Fill GDB's register array with the floating-point register values
++ in *FPREGSETP. */
++
++void
++supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
++{
++ i387_supply_fsave (regcache, -1, fpregsetp);
++}
++
++/* Fill register REGNUM (if it is a floating-point register) in
++ *FPREGSETP with the value in GDB's register array. If REGNUM is -1,
++ do this for all registers. */
++
++void
++fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
++{
++ i387_collect_fsave (regcache, regnum, fpregsetp);
++}
++
++
+ /* Support for debugging kernel virtual memory images. */
+
+ #include
+diff --git a/gdb/i386fbsd-tdep.c b/gdb/i386fbsd-tdep.c
+index 8f7109f..fcb85d8 100644
+--- gdb/i386fbsd-tdep.c
++++ gdb/i386fbsd-tdep.c
+@@ -30,7 +30,6 @@
+
+ #include "i386-tdep.h"
+ #include "i387-tdep.h"
+-#include "bsd-uthread.h"
+ #include "solib-svr4.h"
+
+ /* FreeBSD 3.0-RELEASE or later. */
+@@ -153,46 +152,6 @@ i386fbsd_core_read_description (struct gdbarch *gdbarch,
+ }
+
+ static void
+-i386fbsd_supply_uthread (struct regcache *regcache,
+- int regnum, CORE_ADDR addr)
+-{
+- gdb_byte buf[4];
+- int i;
+-
+- gdb_assert (regnum >= -1);
+-
+- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
+- {
+- if (i386fbsd_jmp_buf_reg_offset[i] != -1
+- && (regnum == -1 || regnum == i))
+- {
+- read_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
+- regcache_raw_supply (regcache, i, buf);
+- }
+- }
+-}
+-
+-static void
+-i386fbsd_collect_uthread (const struct regcache *regcache,
+- int regnum, CORE_ADDR addr)
+-{
+- gdb_byte buf[4];
+- int i;
+-
+- gdb_assert (regnum >= -1);
+-
+- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
+- {
+- if (i386fbsd_jmp_buf_reg_offset[i] != -1
+- && (regnum == -1 || regnum == i))
+- {
+- regcache_raw_collect (regcache, i, buf);
+- write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
+- }
+- }
+-}
+-
+-static void
+ i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+@@ -217,10 +176,6 @@ i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ /* FreeBSD has a more complete `struct sigcontext'. */
+ tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
+ tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
+-
+- /* FreeBSD provides a user-level threads implementation. */
+- bsd_uthread_set_supply_uthread (gdbarch, i386fbsd_supply_uthread);
+- bsd_uthread_set_collect_uthread (gdbarch, i386fbsd_collect_uthread);
+ }
+
+ static void
+diff --git a/gdb/ppcfbsd-nat.c b/gdb/ppcfbsd-nat.c
+index 079bd12..74922f2 100644
+--- gdb/ppcfbsd-nat.c
++++ gdb/ppcfbsd-nat.c
+@@ -39,6 +39,19 @@
+ #include "inf-ptrace.h"
+ #include "bsd-kvm.h"
+
++static pid_t
++ptrace_pid (ptid_t ptid)
++{
++ pid_t pid;
++
++#ifdef __FreeBSD__
++ pid = ptid_get_lwp (ptid);
++ if (pid == 0)
++#endif
++ pid = ptid_get_pid (ptid);
++ return pid;
++}
++
+ /* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+@@ -123,7 +136,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
+ {
+ gdb_gregset_t regs;
+
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+@@ -134,7 +147,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
+ const struct regset *fpregset = ppc_fbsd_fpregset ();
+ gdb_fpregset_t fpregs;
+
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get FP registers"));
+
+@@ -151,13 +164,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops,
+ {
+ gdb_gregset_t regs;
+
+- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ fill_gregset (regcache, ®s, regno);
+
+- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ perror_with_name (_("Couldn't write registers"));
+
+@@ -165,13 +178,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops,
+ {
+ gdb_fpregset_t fpregs;
+
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get FP registers"));
+
+ fill_fpregset (regcache, &fpregs, regno);
+
+- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
++ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't set FP registers"));
+ }
Property changes on: devel/gdb/files/extrapatch-threads
___________________________________________________________________
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: devel/gdb/files/fbsd-threads.c
===================================================================
--- devel/gdb/files/fbsd-threads.c (revision 379209)
+++ devel/gdb/files/fbsd-threads.c (working copy)
@@ -803,47 +803,6 @@
}
static void
-fbsd_lwp_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
-{
- gregset_t gregs;
- fpregset_t fpregs;
- lwpid_t lwp;
-#ifdef PT_GETXMMREGS
- char xmmregs[512];
-#endif
-
- if (!target_has_execution)
- {
- struct target_ops *beneath = find_target_beneath (ops);
-
- beneath->to_fetch_registers (ops, regcache, regnum);
- return;
- }
-
- lwp = GET_LWP (inferior_ptid);
-
- if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1)
- error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno));
- supply_gregset (regcache, &gregs);
-
-#ifdef PT_GETXMMREGS
- if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == 0)
- {
- i387_supply_fxsave (regcache, -1, xmmregs);
- }
- else
- {
-#endif
- if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1)
- error ("Cannot get lwp %d registers: %s\n ", lwp, safe_strerror (errno));
- supply_fpregset (regcache, &fpregs);
-#ifdef PT_GETXMMREGS
- }
-#endif
-}
-
-static void
fbsd_thread_fetch_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
@@ -857,7 +816,9 @@
if (!IS_THREAD (inferior_ptid))
{
- fbsd_lwp_fetch_registers (ops, regcache, regnum);
+ struct target_ops *beneath = find_target_beneath (ops);
+
+ beneath->to_fetch_registers (ops, regcache, regnum);
return;
}
@@ -895,60 +856,6 @@
}
static void
-fbsd_lwp_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
-{
- gregset_t gregs;
- fpregset_t fpregs;
- lwpid_t lwp;
-#ifdef PT_GETXMMREGS
- char xmmregs[512];
-#endif
-
- /* FIXME, is it possible ? */
- if (!IS_LWP (inferior_ptid))
- {
- struct target_ops *beneath = find_target_beneath (ops);
-
- beneath->to_store_registers (ops, regcache, regnum);
- return ;
- }
-
- lwp = GET_LWP (inferior_ptid);
- if (regnum != -1)
- if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1)
- error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno));
-
- fill_gregset (regcache, &gregs, regnum);
- if (ptrace (PT_SETREGS, lwp, (caddr_t) &gregs, 0) == -1)
- error ("Cannot set lwp %d registers: %s\n", lwp, safe_strerror (errno));
-
-#ifdef PT_GETXMMREGS
- if (regnum != -1)
- if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == -1)
- goto noxmm;
-
- i387_collect_fxsave (regcache, regnum, xmmregs);
- if (ptrace (PT_SETXMMREGS, lwp, xmmregs, 0) == -1)
- goto noxmm;
-
- return;
-
-noxmm:
-#endif
-
- if (regnum != -1)
- if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1)
- error ("Cannot get lwp %d float registers: %s\n", lwp,
- safe_strerror (errno));
-
- fill_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1)
- error ("Cannot set lwp %d float registers: %s\n", lwp,
- safe_strerror (errno));
-}
-
-static void
fbsd_thread_store_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
@@ -962,7 +869,9 @@
if (!IS_THREAD (inferior_ptid))
{
- fbsd_lwp_store_registers (ops, regcache, regnum);
+ struct target_ops *beneath = find_target_beneath (ops);
+
+ beneath->to_store_registers (ops, regcache, regnum);
return;
}
Index: devel/gdb/files/patch-gdb-amd64fbsd-nat.c
===================================================================
--- devel/gdb/files/patch-gdb-amd64fbsd-nat.c (revision 379209)
+++ devel/gdb/files/patch-gdb-amd64fbsd-nat.c (working copy)
@@ -1,10 +1,9 @@
--- gdb/amd64fbsd-nat.c.orig 2014-06-11 18:34:41.000000000 +0200
+++ gdb/amd64fbsd-nat.c 2014-09-24 18:27:50.618458853 +0200
-@@ -21,13 +21,17 @@
+@@ -21,13 +21,16 @@
#include "inferior.h"
#include "regcache.h"
#include "target.h"
-+#include "gregset.h"
#include "gdb_assert.h"
#include
@@ -18,53 +17,6 @@
#include
#include "fbsd-nat.h"
-@@ -93,6 +97,46 @@
- };
-
-
-+/* Transfering the registers between GDB, inferiors and core files. */
-+
-+/* Fill GDB's register array with the general-purpose register values
-+ in *GREGSETP. */
-+
-+void
-+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
-+{
-+ amd64_supply_native_gregset (regcache, gregsetp, -1);
-+}
-+
-+/* Fill register REGNUM (if it is a general-purpose register) in
-+ *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
-+ do this for all registers. */
-+
-+void
-+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
-+{
-+ amd64_collect_native_gregset (regcache, gregsetp, regnum);
-+}
-+
-+/* Fill GDB's register array with the floating-point register values
-+ in *FPREGSETP. */
-+
-+void
-+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
-+{
-+ amd64_supply_fxsave (regcache, -1, fpregsetp);
-+}
-+
-+/* Fill register REGNUM (if it is a floating-point register) in
-+ *FPREGSETP with the value in GDB's register array. If REGNUM is -1,
-+ do this for all registers. */
-+
-+void
-+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
-+{
-+ amd64_collect_fxsave (regcache, regnum, fpregsetp);
-+}
-+
- /* Support for debugging kernel virtual memory images. */
-
- #include
@@ -247,6 +291,10 @@
SC_RBP_OFFSET = offset;
Index: devel/gdb/files/patch-gdb-amd64fbsd-tdep.c
===================================================================
--- devel/gdb/files/patch-gdb-amd64fbsd-tdep.c (revision 379209)
+++ devel/gdb/files/patch-gdb-amd64fbsd-tdep.c (working copy)
@@ -1,13 +1,5 @@
--- gdb/amd64fbsd-tdep.c.orig 2010-01-01 02:31:29.000000000 -0500
+++ gdb/amd64fbsd-tdep.c 2011-01-05 17:27:29.264869000 -0500
-@@ -29,7 +29,6 @@
- #include "gdb_string.h"
-
- #include "amd64-tdep.h"
--#include "bsd-uthread.h"
- #include "solib-svr4.h"
-
- /* Support for signal handlers. */
@@ -40,12 +39,16 @@
static CORE_ADDR
amd64fbsd_sigcontext_addr (struct frame_info *this_frame)
@@ -26,61 +18,3 @@
return sp + 16;
}
-@@ -142,46 +145,6 @@
- };
-
- static void
--amd64fbsd_supply_uthread (struct regcache *regcache,
-- int regnum, CORE_ADDR addr)
--{
-- gdb_byte buf[8];
-- int i;
--
-- gdb_assert (regnum >= -1);
--
-- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++)
-- {
-- if (amd64fbsd_jmp_buf_reg_offset[i] != -1
-- && (regnum == -1 || regnum == i))
-- {
-- read_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8);
-- regcache_raw_supply (regcache, i, buf);
-- }
-- }
--}
--
--static void
--amd64fbsd_collect_uthread (const struct regcache *regcache,
-- int regnum, CORE_ADDR addr)
--{
-- gdb_byte buf[8];
-- int i;
--
-- gdb_assert (regnum >= -1);
--
-- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++)
-- {
-- if (amd64fbsd_jmp_buf_reg_offset[i] != -1
-- && (regnum == -1 || regnum == i))
-- {
-- regcache_raw_collect (regcache, i, buf);
-- write_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8);
-- }
-- }
--}
--
--static void
- amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- {
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-@@ -201,10 +164,6 @@
- tdep->sc_reg_offset = amd64fbsd_sc_reg_offset;
- tdep->sc_num_regs = ARRAY_SIZE (amd64fbsd_sc_reg_offset);
-
-- /* FreeBSD provides a user-level threads implementation. */
-- bsd_uthread_set_supply_uthread (gdbarch, amd64fbsd_supply_uthread);
-- bsd_uthread_set_collect_uthread (gdbarch, amd64fbsd_collect_uthread);
--
- /* FreeBSD uses SVR4-style shared libraries. */
- set_solib_svr4_fetch_link_map_offsets
- (gdbarch, svr4_lp64_fetch_link_map_offsets);
Index: devel/gdb/files/patch-gdb-i386bsd-nat.c
===================================================================
--- devel/gdb/files/patch-gdb-i386bsd-nat.c (revision 379209)
+++ devel/gdb/files/patch-gdb-i386bsd-nat.c (working copy)
@@ -1,20 +0,0 @@
---- gdb/i386bsd-nat.c.orig 2010-10-21 11:18:03.171107000 -0400
-+++ gdb/i386bsd-nat.c 2010-10-21 11:18:18.849642000 -0400
-@@ -88,7 +88,7 @@
-
- /* Supply the general-purpose registers in GREGS, to REGCACHE. */
-
--static void
-+void
- i386bsd_supply_gregset (struct regcache *regcache, const void *gregs)
- {
- const char *regs = gregs;
-@@ -107,7 +107,7 @@
- GREGS. If REGNUM is -1, collect and store all appropriate
- registers. */
-
--static void
-+void
- i386bsd_collect_gregset (const struct regcache *regcache,
- void *gregs, int regnum)
- {
Index: devel/gdb/files/patch-gdb-i386bsd-nat.h
===================================================================
--- devel/gdb/files/patch-gdb-i386bsd-nat.h (revision 379209)
+++ devel/gdb/files/patch-gdb-i386bsd-nat.h (working copy)
@@ -1,15 +0,0 @@
---- gdb/i386bsd-nat.h.orig 2010-10-21 11:18:08.097659000 -0400
-+++ gdb/i386bsd-nat.h 2010-10-21 11:20:49.341989000 -0400
-@@ -35,4 +35,12 @@
-
- extern unsigned long i386bsd_dr_get_status (void);
-
-+/* low level i386 register functions used in i386fbsd-nat.c. */
-+
-+extern void i386bsd_supply_gregset (struct regcache *regcache,
-+ const void *gregs);
-+
-+extern void i386bsd_collect_gregset (const struct regcache *regcache,
-+ void *gregs, int regnum);
-+
- #endif /* i386bsd-nat.h */
Index: devel/gdb/files/patch-gdb-i386fbsd-nat.c
===================================================================
--- devel/gdb/files/patch-gdb-i386fbsd-nat.c (revision 379209)
+++ devel/gdb/files/patch-gdb-i386fbsd-nat.c (working copy)
@@ -1,67 +1,19 @@
--- gdb/i386fbsd-nat.c.orig 2012-05-24 18:39:09.000000000 +0200
+++ gdb/i386fbsd-nat.c 2012-08-29 17:19:57.000000000 +0200
-@@ -21,8 +21,10 @@
+@@ -21,10 +21,12 @@
#include "inferior.h"
#include "regcache.h"
#include "target.h"
-+#include "gregset.h"
#include
+#include
#include
#include
++#include
-@@ -80,6 +82,49 @@
- }
-
-
-+/* Transfering the registers between GDB, inferiors and core files. */
-+
-+/* Fill GDB's register array with the general-purpose register values
-+ in *GREGSETP. */
-+
-+void
-+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
-+{
-+ i386bsd_supply_gregset (regcache, gregsetp);
-+}
-+
-+/* Fill register REGNUM (if it is a general-purpose register) in
-+ *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
-+ do this for all registers. */
-+
-+void
-+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
-+{
-+ i386bsd_collect_gregset (regcache, gregsetp, regnum);
-+}
-+
-+#include "i387-tdep.h"
-+
-+/* Fill GDB's register array with the floating-point register values
-+ in *FPREGSETP. */
-+
-+void
-+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
-+{
-+ i387_supply_fsave (regcache, -1, fpregsetp);
-+}
-+
-+/* Fill register REGNUM (if it is a floating-point register) in
-+ *FPREGSETP with the value in GDB's register array. If REGNUM is -1,
-+ do this for all registers. */
-+
-+void
-+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
-+{
-+ i387_collect_fsave (regcache, regnum, fpregsetp);
-+}
-+
-+
- /* Support for debugging kernel virtual memory images. */
-
- #include
-@@ -141,7 +186,6 @@
+ #include "fbsd-nat.h"
+ #include "i386-tdep.h"
+@@ -140,7 +141,6 @@
#endif /* HAVE_PT_GETDBREGS */
@@ -69,3 +21,38 @@
t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
t->to_find_memory_regions = fbsd_find_memory_regions;
t->to_make_corefile_notes = fbsd_make_corefile_notes;
+@@ -149,13 +149,33 @@ _initialize_i386fbsd_nat (void)
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (i386fbsd_supply_pcb);
+
++#ifdef KERN_PROC_SIGTRAMP
++ /* FreeBSD provides a kern.proc.sigtramp sysctl that we can use to
++ locate the sigtramp. That way we can still recognize a sigtramp
++ if its location is changed in a new kernel. */
++ {
++ int mib[4];
++ struct kinfo_sigtramp kst;
++ size_t len;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_SIGTRAMP;
++ mib[3] = getpid();
++ len = sizeof (kst);
++ if (sysctl (mib, sizeof(mib)/sizeof(mib[0]), &kst, &len, NULL, 0) == 0)
++ {
++ i386fbsd_sigtramp_start_addr = (uintptr_t)kst.ksigtramp_start;
++ i386fbsd_sigtramp_end_addr = (uintptr_t)kst.ksigtramp_end;
++ }
++ }
++#elif defined(KERN_PS_STRINGS)
+ /* FreeBSD provides a kern.ps_strings sysctl that we can use to
+ locate the sigtramp. That way we can still recognize a sigtramp
+ if its location is changed in a new kernel. Of course this is
+ still based on the assumption that the sigtramp is placed
+ directly under the location where the program arguments and
+ environment can be found. */
+-#ifdef KERN_PS_STRINGS
+ {
+ int mib[2];
+ u_long ps_strings;
Index: devel/gdb/files/patch-gdb-i386fbsd-tdep.c
===================================================================
--- devel/gdb/files/patch-gdb-i386fbsd-tdep.c (revision 379209)
+++ devel/gdb/files/patch-gdb-i386fbsd-tdep.c (working copy)
@@ -1,68 +0,0 @@
---- gdb/i386fbsd-tdep.c.orig 2010-09-30 13:39:50.654492000 -0400
-+++ gdb/i386fbsd-tdep.c 2010-09-30 13:40:43.858675000 -0400
-@@ -28,7 +28,6 @@
-
- #include "i386-tdep.h"
- #include "i387-tdep.h"
--#include "bsd-uthread.h"
- #include "solib-svr4.h"
-
- /* FreeBSD 3.0-RELEASE or later. */
-@@ -84,46 +83,6 @@
- };
-
- static void
--i386fbsd_supply_uthread (struct regcache *regcache,
-- int regnum, CORE_ADDR addr)
--{
-- gdb_byte buf[4];
-- int i;
--
-- gdb_assert (regnum >= -1);
--
-- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
-- {
-- if (i386fbsd_jmp_buf_reg_offset[i] != -1
-- && (regnum == -1 || regnum == i))
-- {
-- read_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
-- regcache_raw_supply (regcache, i, buf);
-- }
-- }
--}
--
--static void
--i386fbsd_collect_uthread (const struct regcache *regcache,
-- int regnum, CORE_ADDR addr)
--{
-- gdb_byte buf[4];
-- int i;
--
-- gdb_assert (regnum >= -1);
--
-- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++)
-- {
-- if (i386fbsd_jmp_buf_reg_offset[i] != -1
-- && (regnum == -1 || regnum == i))
-- {
-- regcache_raw_collect (regcache, i, buf);
-- write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4);
-- }
-- }
--}
--
--static void
- i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- {
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-@@ -148,10 +107,6 @@
- /* FreeBSD has a more complete `struct sigcontext'. */
- tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
- tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
--
-- /* FreeBSD provides a user-level threads implementation. */
-- bsd_uthread_set_supply_uthread (gdbarch, i386fbsd_supply_uthread);
-- bsd_uthread_set_collect_uthread (gdbarch, i386fbsd_collect_uthread);
- }
-
- static void
Index: devel/gdb/files/patch-xsave
===================================================================
--- devel/gdb/files/patch-xsave (revision 0)
+++ devel/gdb/files/patch-xsave (working copy)
@@ -0,0 +1,606 @@
+diff --git a/bfd/elf.c b/bfd/elf.c
+index 3f377d1..9481435 100644
+--- bfd/elf.c
++++ bfd/elf.c
+@@ -8609,6 +8609,9 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
+ if (note->namesz == 6
+ && strcmp (note->namedata, "LINUX") == 0)
+ return elfcore_grok_xstatereg (abfd, note);
++ else if (note->namesz == 8
++ && strcmp (note->namedata, "FreeBSD") == 0)
++ return elfcore_grok_xstatereg (abfd, note);
+ else
+ return TRUE;
+
+diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
+index f1b039e..7a4c1dc 100644
+--- gdb/amd64-tdep.h
++++ gdb/amd64-tdep.h
+@@ -84,6 +84,11 @@ enum amd64_regnum
+
+ #define AMD64_NUM_REGS (AMD64_ZMM31H_REGNUM + 1)
+
++extern struct target_desc *tdesc_amd64;
++extern struct target_desc *tdesc_amd64_avx;
++extern struct target_desc *tdesc_amd64_mpx;
++extern struct target_desc *tdesc_amd64_avx512;
++
+ extern struct displaced_step_closure *amd64_displaced_step_copy_insn
+ (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to,
+ struct regcache *regs);
+diff --git a/gdb/amd64bsd-nat.c b/gdb/amd64bsd-nat.c
+index 4b0a231..9e6a0df 100644
+--- gdb/amd64bsd-nat.c
++++ gdb/amd64bsd-nat.c
+@@ -37,6 +37,10 @@
+ #include "inf-ptrace.h"
+
+
++#ifdef PT_GETXSTATE_INFO
++size_t x86_xsave_len;
++#endif
++
+ /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
+ for all registers (including the floating-point registers). */
+
+@@ -62,6 +66,20 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+ if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
+ {
+ struct fpreg fpregs;
++#ifdef PT_GETXSTATE_INFO
++ char *xstateregs;
++
++ if (x86_xsave_len != 0)
++ {
++ xstateregs = alloca(x86_xsave_len);
++ if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ perror_with_name (_("Couldn't get extended state status"));
++
++ amd64_supply_xsave (regcache, -1, xstateregs);
++ return;
++ }
++#endif
+
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+@@ -111,6 +129,24 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
+ if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
+ {
+ struct fpreg fpregs;
++#ifdef PT_GETXSTATE_INFO
++ char *xstateregs;
++
++ if (x86_xsave_len != 0)
++ {
++ xstateregs = alloca(x86_xsave_len);
++ if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ perror_with_name (_("Couldn't get extended state status"));
++
++ amd64_collect_xsave (regcache, regnum, xstateregs, 0);
++
++ if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1)
++ perror_with_name (_("Couldn't write extended state status"));
++ return;
++ }
++#endif
+
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+diff --git a/gdb/amd64bsd-nat.h b/gdb/amd64bsd-nat.h
+index 7ff95f3..9d85a1f 100644
+--- gdb/amd64bsd-nat.h
++++ gdb/amd64bsd-nat.h
+@@ -20,6 +20,9 @@
+ #ifndef AMD64BSD_NAT_H
+ #define AMD64BSD_NAT_H
+
++/* Low level amd64 XSAVE info. */
++extern size_t x86_xsave_len;
++
+ /* Low level amd64 debug register functions. */
+
+ extern void amd64bsd_dr_set_control (unsigned long control);
+diff --git a/gdb/amd64fbsd-nat.c b/gdb/amd64fbsd-nat.c
+index 08de9a1..eea2472 100644
+--- gdb/amd64fbsd-nat.c
++++ gdb/amd64fbsd-nat.c
+@@ -36,6 +36,7 @@
+ #include "amd64-nat.h"
+ #include "amd64bsd-nat.h"
+ #include "i386-nat.h"
++#include "i386-xstate.h"
+
+
+ /* Offset in `struct reg' where MEMBER is stored. */
+@@ -153,6 +154,68 @@ amd64fbsd_mourn_inferior (struct target_ops *ops)
+ super_mourn_inferior (ops);
+ }
+
++static const struct target_desc *
++amd64fbsd_read_description (struct target_ops *ops)
++{
++#ifdef PT_GETXSTATE_INFO
++ static int xsave_probed;
++ static uint64_t xcr0;
++#endif
++ struct reg regs;
++ int is64;
++
++ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) ®s, 0) == -1)
++ perror_with_name (_("Couldn't get registers"));
++ is64 = (regs.r_cs == GSEL(GUCODE_SEL, SEL_UPL));
++#ifdef PT_GETXSTATE_INFO
++ if (!xsave_probed)
++ {
++ struct ptrace_xstate_info info;
++
++ if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) &info, sizeof(info)) == 0)
++ {
++ x86_xsave_len = info.xsave_len;
++ xcr0 = info.xsave_mask;
++ }
++ xsave_probed = 1;
++ }
++
++ if (x86_xsave_len != 0)
++ {
++ switch (xcr0 & I386_XSTATE_ALL_MASK)
++ {
++ case I386_XSTATE_MPX_AVX512_MASK:
++ case I386_XSTATE_AVX512_MASK:
++ if (is64)
++ return tdesc_amd64_avx512;
++ else
++ return tdesc_i386_avx512;
++ case I386_XSTATE_MPX_MASK:
++ if (is64)
++ return tdesc_amd64_mpx;
++ else
++ return tdesc_i386_mpx;
++ case I386_XSTATE_AVX_MASK:
++ if (is64)
++ return tdesc_amd64_avx;
++ else
++ return tdesc_i386_avx;
++ default:
++ if (is64)
++ return tdesc_amd64;
++ else
++ return tdesc_i386;
++ }
++ }
++#endif
++ if (is64)
++ return tdesc_amd64;
++ else
++ return tdesc_i386;
++}
++
+ /* Provide a prototype to silence -Wmissing-prototypes. */
+ void _initialize_amd64fbsd_nat (void);
+
+@@ -183,6 +246,7 @@ _initialize_amd64fbsd_nat (void)
+
+ super_mourn_inferior = t->to_mourn_inferior;
+ t->to_mourn_inferior = amd64fbsd_mourn_inferior;
++ t->to_read_description = amd64fbsd_read_description;
+
+ t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+ t->to_find_memory_regions = fbsd_find_memory_regions;
+diff --git a/gdb/amd64fbsd-tdep.c b/gdb/amd64fbsd-tdep.c
+index 884fbc4..582ae50 100644
+--- gdb/amd64fbsd-tdep.c
++++ gdb/amd64fbsd-tdep.c
+@@ -23,6 +23,9 @@
+ #include "gdbcore.h"
+ #include "regcache.h"
+ #include "osabi.h"
++#include "regset.h"
++#include "i386fbsd-tdep.h"
++#include "i386-xstate.h"
+
+ #include "gdb_assert.h"
+ #include
+@@ -31,6 +34,15 @@
+ #include "bsd-uthread.h"
+ #include "solib-svr4.h"
+
++/* Supported register note sections. */
++static struct core_regset_section amd64fbsd_regset_sections[] =
++{
++ { ".reg", 22 * 8, "general-purpose" },
++ { ".reg2", 512, "floating-point" },
++ { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
++ { NULL, 0 }
++};
++
+ /* Support for signal handlers. */
+
+ /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
+@@ -144,6 +156,27 @@ static int amd64fbsd_jmp_buf_reg_offset[] =
+ 0 * 8 /* %rip */
+ };
+
++static const struct target_desc *
++amd64fbsd_core_read_description (struct gdbarch *gdbarch,
++ struct target_ops *target,
++ bfd *abfd)
++{
++ uint64_t xcr0 = i386fbsd_core_read_xcr0 (abfd);
++
++ switch (xcr0 & I386_XSTATE_ALL_MASK)
++ {
++ case I386_XSTATE_MPX_AVX512_MASK:
++ case I386_XSTATE_AVX512_MASK:
++ return tdesc_amd64_avx512;
++ case I386_XSTATE_MPX_MASK:
++ return tdesc_amd64_mpx;
++ case I386_XSTATE_AVX_MASK:
++ return tdesc_amd64_avx;
++ default:
++ return tdesc_amd64;
++ }
++}
++
+ static void
+ amd64fbsd_supply_uthread (struct regcache *regcache,
+ int regnum, CORE_ADDR addr)
+@@ -204,6 +237,14 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ tdep->sc_reg_offset = amd64fbsd_sc_reg_offset;
+ tdep->sc_num_regs = ARRAY_SIZE (amd64fbsd_sc_reg_offset);
+
++ tdep->xsave_xcr0_offset = I386_FBSD_XSAVE_XCR0_OFFSET;
++
++ /* Install supported register note sections. */
++ set_gdbarch_core_regset_sections (gdbarch, amd64fbsd_regset_sections);
++
++ set_gdbarch_core_read_description (gdbarch,
++ amd64fbsd_core_read_description);
++
+ /* FreeBSD provides a user-level threads implementation. */
+ bsd_uthread_set_supply_uthread (gdbarch, amd64fbsd_supply_uthread);
+ bsd_uthread_set_collect_uthread (gdbarch, amd64fbsd_collect_uthread);
+diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
+index e0950a3..0498445 100644
+--- gdb/i386-tdep.h
++++ gdb/i386-tdep.h
+@@ -325,6 +325,11 @@ enum record_i386_regnum
+ /* Size of the largest register. */
+ #define I386_MAX_REGISTER_SIZE 64
+
++extern struct target_desc *tdesc_i386;
++extern struct target_desc *tdesc_i386_avx;
++extern struct target_desc *tdesc_i386_mpx;
++extern struct target_desc *tdesc_i386_avx512;
++
+ /* Types for i386-specific registers. */
+ extern struct type *i387_ext_type (struct gdbarch *gdbarch);
+
+diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c
+index acae6cb..c26e830 100644
+--- gdb/i386bsd-nat.c
++++ gdb/i386bsd-nat.c
+@@ -83,6 +83,10 @@ static int i386bsd_r_reg_offset[] =
+ so that we try PT_GETXMMREGS the first time around. */
+ static int have_ptrace_xmmregs = -1;
+ #endif
++
++#ifdef PT_GETXSTATE_INFO
++size_t x86_xsave_len;
++#endif
+
+
+ /* Supply the general-purpose registers in GREGS, to REGCACHE. */
+@@ -150,7 +154,25 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+ struct fpreg fpregs;
+ #ifdef HAVE_PT_GETXMMREGS
+ char xmmregs[512];
++#endif
++
++#ifdef PT_GETXSTATE_INFO
++ if (x86_xsave_len != 0)
++ {
++ char *xstateregs;
++
++ xstateregs = alloca(x86_xsave_len);
++ if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ perror_with_name (_("Couldn't get extended state status"));
+
++ i387_supply_xsave (regcache, -1, xstateregs);
++ return;
++ }
++ else
++#endif
++
++#ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+ && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+@@ -160,18 +182,15 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
+ }
+ else
+ {
++ have_ptrace_xmmregs = 0;
++#endif
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ i387_supply_fsave (regcache, -1, &fpregs);
++#ifdef HAVE_PT_GETXMMREGS
+ }
+-#else
+- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+- perror_with_name (_("Couldn't get floating point status"));
+-
+- i387_supply_fsave (regcache, -1, &fpregs);
+ #endif
+ }
+ }
+@@ -206,7 +225,27 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
+ struct fpreg fpregs;
+ #ifdef HAVE_PT_GETXMMREGS
+ char xmmregs[512];
++#endif
++
++#ifdef PT_GETXSTATE_INFO
++ if (x86_xsave_len != 0)
++ {
++ char *xstateregs;
+
++ xstateregs = alloca(x86_xsave_len);
++ if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
++ perror_with_name (_("Couldn't get extended state status"));
++
++ i387_collect_xsave (regcache, -1, xstateregs, 0);
++
++ if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1)
++ perror_with_name (_("Couldn't write extended state status"));
++ }
++#endif
++
++#ifdef HAVE_PT_GETXMMREGS
+ if (have_ptrace_xmmregs != 0
+ && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
+ (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+diff --git a/gdb/i386bsd-nat.h b/gdb/i386bsd-nat.h
+index a92fa56..044f530 100644
+--- gdb/i386bsd-nat.h
++++ gdb/i386bsd-nat.h
+@@ -25,6 +25,9 @@
+
+ extern struct target_ops *i386bsd_target (void);
+
++/* Low level i386 XSAVE info. */
++extern size_t x86_xsave_len;
++
+ /* low level i386 debug register functions used in i386fbsd-nat.c. */
+
+ extern void i386bsd_dr_set_control (unsigned long control);
+diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c
+index fb80991..b9620e1 100644
+--- gdb/i386fbsd-nat.c
++++ gdb/i386fbsd-nat.c
+@@ -31,6 +31,7 @@
+ #include "i386-tdep.h"
+ #include "i386-nat.h"
+ #include "i386bsd-nat.h"
++#include "i386-xstate.h"
+
+ /* Resume execution of the inferior process. If STEP is nonzero,
+ single-step it. If SIGNAL is nonzero, give it that signal. */
+@@ -116,6 +117,46 @@ i386fbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+ }
+
+
++#ifdef PT_GETXSTATE_INFO
++static const struct target_desc *
++i386fbsd_read_description (struct target_ops *ops)
++{
++ static int xsave_probed;
++ static uint64_t xcr0;
++
++ if (!xsave_probed)
++ {
++ struct ptrace_xstate_info info;
++
++ if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid),
++ (PTRACE_TYPE_ARG3) &info, sizeof(info)) == 0)
++ {
++ x86_xsave_len = info.xsave_len;
++ xcr0 = info.xsave_mask;
++ }
++ xsave_probed = 1;
++ }
++
++ if (x86_xsave_len != 0)
++ {
++ switch (xcr0 & I386_XSTATE_ALL_MASK)
++ {
++ case I386_XSTATE_MPX_AVX512_MASK:
++ case I386_XSTATE_AVX512_MASK:
++ return tdesc_i386_avx512;
++ case I386_XSTATE_MPX_MASK:
++ return tdesc_i386_mpx;
++ case I386_XSTATE_AVX_MASK:
++ return tdesc_i386_avx;
++ default:
++ return tdesc_i386;
++ }
++ }
++ else
++ return tdesc_i386;
++}
++#endif
++
+ /* Prevent warning from -Wmissing-prototypes. */
+ void _initialize_i386fbsd_nat (void);
+
+@@ -140,6 +181,9 @@ _initialize_i386fbsd_nat (void)
+
+ #endif /* HAVE_PT_GETDBREGS */
+
++#ifdef PT_GETXSTATE_INFO
++ t->to_read_description = i386fbsd_read_description;
++#endif
+
+ t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+ t->to_find_memory_regions = fbsd_find_memory_regions;
+diff --git a/gdb/i386fbsd-tdep.c b/gdb/i386fbsd-tdep.c
+index ed6df6b..8f7109f 100644
+--- gdb/i386fbsd-tdep.c
++++ gdb/i386fbsd-tdep.c
+@@ -22,6 +22,9 @@
+ #include "gdbcore.h"
+ #include "osabi.h"
+ #include "regcache.h"
++#include "regset.h"
++#include "i386fbsd-tdep.h"
++#include "i386-xstate.h"
+
+ #include "gdb_assert.h"
+
+@@ -32,6 +35,15 @@
+
+ /* FreeBSD 3.0-RELEASE or later. */
+
++/* Supported register note sections. */
++static struct core_regset_section i386fbsd_regset_sections[] =
++{
++ { ".reg", 19 * 4, "general-purpose" },
++ { ".reg2", 512, "floating-point" },
++ { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
++ { NULL, 0 }
++};
++
+ /* From . */
+ static int i386fbsd_r_reg_offset[] =
+ {
+@@ -82,6 +94,64 @@ static int i386fbsd_jmp_buf_reg_offset[] =
+ 0 * 4 /* %eip */
+ };
+
++/* Get XSAVE extended state xcr0 from core dump. */
++
++uint64_t
++i386fbsd_core_read_xcr0 (bfd *abfd)
++{
++ asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate");
++ uint64_t xcr0;
++
++ if (xstate)
++ {
++ size_t size = bfd_section_size (abfd, xstate);
++
++ /* Check extended state size. */
++ if (size < I386_XSTATE_AVX_SIZE)
++ xcr0 = I386_XSTATE_SSE_MASK;
++ else
++ {
++ char contents[8];
++
++ if (! bfd_get_section_contents (abfd, xstate, contents,
++ I386_FBSD_XSAVE_XCR0_OFFSET,
++ 8))
++ {
++ warning (_("Couldn't read `xcr0' bytes from "
++ "`.reg-xstate' section in core file."));
++ return 0;
++ }
++
++ xcr0 = bfd_get_64 (abfd, contents);
++ }
++ }
++ else
++ xcr0 = 0;
++
++ return xcr0;
++}
++
++static const struct target_desc *
++i386fbsd_core_read_description (struct gdbarch *gdbarch,
++ struct target_ops *target,
++ bfd *abfd)
++{
++ uint64_t xcr0 = i386fbsd_core_read_xcr0 (abfd);
++
++ switch (xcr0 & I386_XSTATE_ALL_MASK)
++ {
++ case I386_XSTATE_MPX_AVX512_MASK:
++ case I386_XSTATE_AVX512_MASK:
++ return tdesc_i386_avx512;
++ case I386_XSTATE_MPX_MASK:
++ return tdesc_i386_mpx;
++ case I386_XSTATE_AVX_MASK:
++ return tdesc_i386_avx;
++ default:
++ return tdesc_i386;
++ }
++}
++
+ static void
+ i386fbsd_supply_uthread (struct regcache *regcache,
+ int regnum, CORE_ADDR addr)
+@@ -218,6 +288,14 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ /* FreeBSD 4.0 introduced a new `struct sigcontext'. */
+ tdep->sc_reg_offset = i386fbsd4_sc_reg_offset;
+ tdep->sc_num_regs = ARRAY_SIZE (i386fbsd4_sc_reg_offset);
++
++ tdep->xsave_xcr0_offset = I386_FBSD_XSAVE_XCR0_OFFSET;
++
++ /* Install supported register note sections. */
++ set_gdbarch_core_regset_sections (gdbarch, i386fbsd_regset_sections);
++
++ set_gdbarch_core_read_description (gdbarch,
++ i386fbsd_core_read_description);
+ }
+
+
+diff --git a/gdb/i386fbsd-tdep.h b/gdb/i386fbsd-tdep.h
+new file mode 100644
+index 0000000..8935255
+--- /dev/null
++++ gdb/i386fbsd-tdep.h
+@@ -0,0 +1,33 @@
++/* Target-dependent code for FreeBSD x86.
++
++ Copyright (C) 2014 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see . */
++
++#ifndef I386FBSD_TDEP_H
++#define I386FBSD_TDEP_H
++
++/* Get XSAVE extended state xcr0 from core dump. */
++extern uint64_t i386fbsd_core_read_xcr0 (bfd *abfd);
++
++/*
++ * The format of the XSAVE extended area is determined by hardware.
++ * Cores store the XSAVE extended area in a NT_X86_XSTATE note that
++ * matches the layout on Linux.
++ */
++#define I386_FBSD_XSAVE_XCR0_OFFSET 464
++
++#endif /* i386fbsd-tdep.h */
Property changes on: devel/gdb/files/patch-xsave
___________________________________________________________________
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property