View | Details | Raw Unified | Return to bug 203170
Collapse All | Expand All

(-)devel/gdb/Makefile (-25 / +12 lines)
Lines 2-8 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	gdb
4
PORTNAME=	gdb
5
PORTVERSION=	7.9.1
5
PORTVERSION=	7.10
6
CATEGORIES=	devel
6
CATEGORIES=	devel
7
MASTER_SITES=	GNU
7
MASTER_SITES=	GNU
8
8
Lines 17-23 CPE_VENDOR= gnu Link Here
17
GNU_CONFIGURE=	yes
17
GNU_CONFIGURE=	yes
18
CONFIGURE_ENV=	CONFIGURED_M4=m4 CONFIGURED_BISON=byacc
18
CONFIGURE_ENV=	CONFIGURED_M4=m4 CONFIGURED_BISON=byacc
19
CONFIGURE_ARGS=	--program-suffix=${PORTVERSION:S/.//g} \
19
CONFIGURE_ARGS=	--program-suffix=${PORTVERSION:S/.//g} \
20
		--enable-targets=all \
20
		--enable-targets=all --enable-64-bit-bfd \
21
		--with-gdb-datadir=${PREFIX}/share/gdb${PORTVERSION:S/.//g} \
21
		--with-gdb-datadir=${PREFIX}/share/gdb${PORTVERSION:S/.//g} \
22
		--with-separate-debug-dir=/usr/lib/debug \
22
		--with-separate-debug-dir=/usr/lib/debug \
23
		${ICONV_CONFIGURE_ARG} \
23
		${ICONV_CONFIGURE_ARG} \
Lines 26-37 CFLAGS:= ${CFLAGS:C/ +$//} # blanks at EOL creep in sometimes Link Here
26
CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
26
CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
27
EXCLUDE=	dejagnu expect sim texinfo intl
27
EXCLUDE=	dejagnu expect sim texinfo intl
28
EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
28
EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
29
EXTRA_PATCHES=	${FILESDIR}/commit-c5cb74e \
30
		${FILESDIR}/commit-cf424ae \
31
		${FILESDIR}/commit-773eacf \
32
		${FILESDIR}/commit-2526815 \
33
		${FILESDIR}/commit-3ce5b6e \
34
		${FILESDIR}/commit-97de354
35
29
36
VER=		${PORTVERSION:S/.//g}
30
VER=		${PORTVERSION:S/.//g}
37
PLIST_SUB=	VER=${VER}
31
PLIST_SUB=	VER=${VER}
Lines 63-72 EXPAT_LIB_DEPENDS= libexpat.so:${PORTSDIR}/textproc/expat2 Link Here
63
GUILE_CONFIGURE_ON=	--with-guile
57
GUILE_CONFIGURE_ON=	--with-guile
64
GUILE_USES=		pkgconfig
58
GUILE_USES=		pkgconfig
65
GUILE_LIB_DEPENDS=	libguile-2.0.so:${PORTSDIR}/lang/guile2
59
GUILE_LIB_DEPENDS=	libguile-2.0.so:${PORTSDIR}/lang/guile2
60
PORT_READLINE_USES=	readline:port
66
PYTHON_CONFIGURE_ON=	--with-python=${PYTHON_CMD}
61
PYTHON_CONFIGURE_ON=	--with-python=${PYTHON_CMD}
67
PYTHON_CONFIGURE_OFF=	--without-python
62
PYTHON_CONFIGURE_OFF=	--without-python
68
PYTHON_USES=		python:2
63
PYTHON_USES=		python:2
69
PORT_READLINE_USES=	readline:port
70
TUI_CONFIGURE_ENABLE=	tui
64
TUI_CONFIGURE_ENABLE=	tui
71
65
72
.include <bsd.port.options.mk>
66
.include <bsd.port.options.mk>
Lines 82-91 CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} Link Here
82
post-patch:
76
post-patch:
83
	@${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \
77
	@${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \
84
		${WRKSRC}/gdb/version.in
78
		${WRKSRC}/gdb/version.in
85
.if ${PORT_OPTIONS:MTHREADS}
79
80
post-patch-THREADS-on:
86
	@${CP} ${FILESDIR}/fbsd-threads.c ${WRKSRC}/gdb/
81
	@${CP} ${FILESDIR}/fbsd-threads.c ${WRKSRC}/gdb/
87
	@${PATCH} ${PATCH_ARGS} < ${FILESDIR}/extrapatch-threads
82
	@${PATCH} ${PATCH_ARGS} < ${FILESDIR}/extrapatch-threads
88
.endif
89
83
90
do-install:
84
do-install:
91
	${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb \
85
	${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb \
Lines 93-122 do-install: Link Here
93
	${INSTALL_MAN} ${WRKSRC}/gdb/doc/gdb.1 \
87
	${INSTALL_MAN} ${WRKSRC}/gdb/doc/gdb.1 \
94
		${STAGEDIR}${MAN1PREFIX}/man/man1/gdb${VER}.1
88
		${STAGEDIR}${MAN1PREFIX}/man/man1/gdb${VER}.1
95
89
96
.if ${PORT_OPTIONS:MTUI}
90
do-install-TUI-on:
97
	${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdbtui${VER}
91
	${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdbtui${VER}
98
.endif
99
92
100
.if ${PORT_OPTIONS:MGDB_LINK}
93
do-install-GDB_LINK-on:
101
	${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdb
94
	${LN} -sf gdb${VER} ${STAGEDIR}${PREFIX}/bin/gdb
102
.endif
103
95
104
.if ${PORT_OPTIONS:MPYTHON}
96
do-install-PYTHON-on:
105
	(cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python )
97
	(cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python )
106
	(cd ${WRKSRC}/gdb/data-directory ; \
98
	(cd ${WRKSRC}/gdb/data-directory ; \
107
		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python )
99
		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-python )
108
.endif
100
. for f in gdb gdb/command gdb/function
101
	@(cd ${STAGEDIR}${PREFIX}/share/gdb${VER}/python/${f} ; ${CHMOD} 644 *.py* )
102
. endfor
109
103
110
.if ${PORT_OPTIONS:MGUILE}
104
do-install-GUILE-on:
111
	(cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile )
105
	(cd ${WRKSRC}/gdb; ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile )
112
	(cd ${WRKSRC}/gdb/data-directory ; \
106
	(cd ${WRKSRC}/gdb/data-directory ; \
113
		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile )
107
		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-guile )
114
.endif
115
116
.if ${PORT_OPTIONS:MPYTHON}
117
. for f in gdb gdb/command gdb/function
118
	@(cd ${STAGEDIR}${PREFIX}/share/gdb${VER}/python/${f} ; ${CHMOD} 644 *.py* )
119
. endfor
120
.endif
121
108
122
.include <bsd.port.mk>
109
.include <bsd.port.mk>
(-)devel/gdb/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (gdb-7.9.1.tar.xz) = cd9c543a411a05b2b647dd38936034b68c2b5d6f10e0d51dc168c166c973ba40
1
SHA256 (gdb-7.10.tar.xz) = 7ebdaa44f9786ce0c142da4e36797d2020c55fa091905ac5af1846b5756208a8
2
SIZE (gdb-7.9.1.tar.xz) = 17867692
2
SIZE (gdb-7.10.tar.xz) = 18540820
(-)devel/gdb/files/commit-2526815 (-186 lines)
Removed Link Here
1
diff --git gdb/config.in gdb/config.in
2
index 3ccac37..8a27df0 100644
3
--- gdb/config.in
4
+++ gdb/config.in
5
@@ -213,6 +213,9 @@
6
 /* Define to 1 if you have the <inttypes.h> header file. */
7
 #undef HAVE_INTTYPES_H
8
 
9
+/* Define to 1 if your system has the kinfo_getvmmap function. */
10
+#undef HAVE_KINFO_GETVMMAP
11
+
12
 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
13
 #undef HAVE_LANGINFO_CODESET
14
 
15
diff --git gdb/configure gdb/configure
16
index cca0aeb..78d206b 100755
17
--- gdb/configure
18
+++ gdb/configure
19
@@ -7159,6 +7159,66 @@ if test "$ac_res" != no; then :
20
 fi
21
 
22
 
23
+# On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
24
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kinfo_getvmmap" >&5
25
+$as_echo_n "checking for library containing kinfo_getvmmap... " >&6; }
26
+if test "${ac_cv_search_kinfo_getvmmap+set}" = set; then :
27
+  $as_echo_n "(cached) " >&6
28
+else
29
+  ac_func_search_save_LIBS=$LIBS
30
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
31
+/* end confdefs.h.  */
32
+
33
+/* Override any GCC internal prototype to avoid an error.
34
+   Use char because int might match the return type of a GCC
35
+   builtin and then its argument prototype would still apply.  */
36
+#ifdef __cplusplus
37
+extern "C"
38
+#endif
39
+char kinfo_getvmmap ();
40
+int
41
+main ()
42
+{
43
+return kinfo_getvmmap ();
44
+  ;
45
+  return 0;
46
+}
47
+_ACEOF
48
+for ac_lib in '' util; do
49
+  if test -z "$ac_lib"; then
50
+    ac_res="none required"
51
+  else
52
+    ac_res=-l$ac_lib
53
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
54
+  fi
55
+  if ac_fn_c_try_link "$LINENO"; then :
56
+  ac_cv_search_kinfo_getvmmap=$ac_res
57
+fi
58
+rm -f core conftest.err conftest.$ac_objext \
59
+    conftest$ac_exeext
60
+  if test "${ac_cv_search_kinfo_getvmmap+set}" = set; then :
61
+  break
62
+fi
63
+done
64
+if test "${ac_cv_search_kinfo_getvmmap+set}" = set; then :
65
+
66
+else
67
+  ac_cv_search_kinfo_getvmmap=no
68
+fi
69
+rm conftest.$ac_ext
70
+LIBS=$ac_func_search_save_LIBS
71
+fi
72
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kinfo_getvmmap" >&5
73
+$as_echo "$ac_cv_search_kinfo_getvmmap" >&6; }
74
+ac_res=$ac_cv_search_kinfo_getvmmap
75
+if test "$ac_res" != no; then :
76
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
77
+
78
+$as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
79
+
80
+fi
81
+
82
+
83
 
84
 
85
 
86
diff --git gdb/configure.ac gdb/configure.ac
87
index 4a0b6a3..38747e8 100644
88
--- gdb/configure.ac
89
+++ gdb/configure.ac
90
@@ -537,6 +537,11 @@ AM_ZLIB
91
 # On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
92
 AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
93
 
94
+# On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
95
+AC_SEARCH_LIBS(kinfo_getvmmap, util,
96
+  [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
97
+            [Define to 1 if your system has the kinfo_getvmmap function. ])])
98
+
99
 AM_ICONV
100
 
101
 # GDB may fork/exec the iconv program to get the list of supported character
102
diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
103
index 062eede..1ce197d 100644
104
--- gdb/fbsd-nat.c
105
+++ gdb/fbsd-nat.c
106
@@ -26,6 +26,10 @@
107
 #include <sys/types.h>
108
 #include <sys/procfs.h>
109
 #include <sys/sysctl.h>
110
+#ifdef HAVE_KINFO_GETVMMAP
111
+#include <sys/user.h>
112
+#include <libutil.h>
113
+#endif
114
 
115
 #include "elf-bfd.h"
116
 #include "fbsd-nat.h"
117
@@ -62,6 +66,64 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
118
   return NULL;
119
 }
120
 
121
+#ifdef HAVE_KINFO_GETVMMAP
122
+/* Iterate over all the memory regions in the current inferior,
123
+   calling FUNC for each memory region.  OBFD is passed as the last
124
+   argument to FUNC.  */
125
+
126
+int
127
+fbsd_find_memory_regions (struct target_ops *self,
128
+			  find_memory_region_ftype func, void *obfd)
129
+{
130
+  pid_t pid = ptid_get_pid (inferior_ptid);
131
+  struct kinfo_vmentry *vmentl, *kve;
132
+  uint64_t size;
133
+  struct cleanup *cleanup;
134
+  int i, nitems;
135
+
136
+  vmentl = kinfo_getvmmap (pid, &nitems);
137
+  if (vmentl == NULL)
138
+    perror_with_name (_("Couldn't fetch VM map entries."));
139
+  cleanup = make_cleanup (free, vmentl);
140
+
141
+  for (i = 0; i < nitems; i++)
142
+    {
143
+      kve = &vmentl[i];
144
+
145
+      /* Skip unreadable segments and those where MAP_NOCORE has been set.  */
146
+      if (!(kve->kve_protection & KVME_PROT_READ)
147
+	  || kve->kve_flags & KVME_FLAG_NOCOREDUMP)
148
+	continue;
149
+
150
+      /* Skip segments with an invalid type.  */
151
+      if (kve->kve_type != KVME_TYPE_DEFAULT
152
+	  && kve->kve_type != KVME_TYPE_VNODE
153
+	  && kve->kve_type != KVME_TYPE_SWAP
154
+	  && kve->kve_type != KVME_TYPE_PHYS)
155
+	continue;
156
+
157
+      size = kve->kve_end - kve->kve_start;
158
+      if (info_verbose)
159
+	{
160
+	  fprintf_filtered (gdb_stdout, 
161
+			    "Save segment, %ld bytes at %s (%c%c%c)\n",
162
+			    (long) size,
163
+			    paddress (target_gdbarch (), kve->kve_start),
164
+			    kve->kve_protection & KVME_PROT_READ ? 'r' : '-',
165
+			    kve->kve_protection & KVME_PROT_WRITE ? 'w' : '-',
166
+			    kve->kve_protection & KVME_PROT_EXEC ? 'x' : '-');
167
+	}
168
+
169
+      /* Invoke the callback function to create the corefile segment.
170
+	 Pass MODIFIED as true, we do not know the real modification state.  */
171
+      func (kve->kve_start, size, kve->kve_protection & KVME_PROT_READ,
172
+	    kve->kve_protection & KVME_PROT_WRITE,
173
+	    kve->kve_protection & KVME_PROT_EXEC, 1, obfd);
174
+    }
175
+  do_cleanups (cleanup);
176
+  return 0;
177
+}
178
+#else
179
 static int
180
 fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
181
 		   char *protection)
182
@@ -137,3 +199,4 @@ fbsd_find_memory_regions (struct target_ops *self,
183
   do_cleanups (cleanup);
184
   return 0;
185
 }
186
+#endif
(-)devel/gdb/files/commit-3ce5b6e (-21 lines)
Removed Link Here
1
diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
2
index 5d17f03..9609cd8 100644
3
--- gdb/fbsd-tdep.c
4
+++ gdb/fbsd-tdep.c
5
@@ -89,7 +89,7 @@ fbsd_collect_regset_section_cb (const char *sect_name, int size,
6
 static char *
7
 fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
8
 {
9
-  const struct regcache *regcache = get_current_regcache ();
10
+  struct regcache *regcache = get_current_regcache ();
11
   char *note_data;
12
   Elf_Internal_Ehdr *i_ehdrp;
13
   struct fbsd_collect_regset_section_cb_data data;
14
@@ -104,6 +104,7 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
15
   data.obfd = obfd;
16
   data.note_data = NULL;
17
   data.note_size = note_size;
18
+  target_fetch_registers (regcache, -1);
19
   gdbarch_iterate_over_regset_sections (gdbarch,
20
 					fbsd_collect_regset_section_cb,
21
 					&data, regcache);
(-)devel/gdb/files/commit-773eacf (-99 lines)
Removed Link Here
1
diff --git gdb/amd64fbsd-tdep.c gdb/amd64fbsd-tdep.c
2
index e11b0f3..62dcb83 100644
3
--- gdb/amd64fbsd-tdep.c
4
+++ gdb/amd64fbsd-tdep.c
5
@@ -51,8 +51,8 @@ amd64fbsd_sigtramp_p (struct frame_info *this_frame)
6
 
7
   if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
8
     return 0;
9
-  if (memcmp (buf, amd64fbsd_sigtramp_code, sizeof amd64fbsd_sigtramp_code) !=
10
-      0)
11
+  if (memcmp (buf, amd64fbsd_sigtramp_code, sizeof amd64fbsd_sigtramp_code)
12
+      != 0)
13
     return 0;
14
 
15
   return 1;
16
diff --git gdb/i386fbsd-tdep.c gdb/i386fbsd-tdep.c
17
index d4516ee..ed41706 100644
18
--- gdb/i386fbsd-tdep.c
19
+++ gdb/i386fbsd-tdep.c
20
@@ -105,24 +105,24 @@ static const gdb_byte i386fbsd_osigtramp_end[] =
21
 };
22
 
23
 /* The three different trampolines are all the same size.  */
24
-gdb_static_assert (sizeof i386fbsd_sigtramp_start ==
25
-		   sizeof i386fbsd_freebsd4_sigtramp_start);
26
-gdb_static_assert (sizeof i386fbsd_sigtramp_start ==
27
-		   sizeof i386fbsd_osigtramp_start);
28
-gdb_static_assert (sizeof i386fbsd_sigtramp_middle ==
29
-		   sizeof i386fbsd_freebsd4_sigtramp_middle);
30
-gdb_static_assert (sizeof i386fbsd_sigtramp_middle ==
31
-		   sizeof i386fbsd_osigtramp_middle);
32
-gdb_static_assert (sizeof i386fbsd_sigtramp_end ==
33
-		   sizeof i386fbsd_freebsd4_sigtramp_end);
34
-gdb_static_assert (sizeof i386fbsd_sigtramp_end ==
35
-		   sizeof i386fbsd_osigtramp_end);
36
+gdb_static_assert (sizeof i386fbsd_sigtramp_start
37
+		   == sizeof i386fbsd_freebsd4_sigtramp_start);
38
+gdb_static_assert (sizeof i386fbsd_sigtramp_start
39
+		   == sizeof i386fbsd_osigtramp_start);
40
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle
41
+		   == sizeof i386fbsd_freebsd4_sigtramp_middle);
42
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle
43
+		   == sizeof i386fbsd_osigtramp_middle);
44
+gdb_static_assert (sizeof i386fbsd_sigtramp_end
45
+		   == sizeof i386fbsd_freebsd4_sigtramp_end);
46
+gdb_static_assert (sizeof i386fbsd_sigtramp_end
47
+		   == sizeof i386fbsd_osigtramp_end);
48
 
49
 /* We assume that the middle is the largest chunk below.  */
50
-gdb_static_assert (sizeof i386fbsd_sigtramp_middle >
51
-		   sizeof i386fbsd_sigtramp_start);
52
-gdb_static_assert (sizeof i386fbsd_sigtramp_middle >
53
-		   sizeof i386fbsd_sigtramp_end);
54
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle
55
+		   > sizeof i386fbsd_sigtramp_start);
56
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle
57
+		   > sizeof i386fbsd_sigtramp_end);
58
 
59
 static int
60
 i386fbsd_sigtramp_p (struct frame_info *this_frame)
61
@@ -135,19 +135,25 @@ i386fbsd_sigtramp_p (struct frame_info *this_frame)
62
   if (!safe_frame_unwind_memory (this_frame, pc, buf,
63
 				 sizeof i386fbsd_sigtramp_start))
64
     return 0;
65
-  if (memcmp (buf, i386fbsd_sigtramp_start, sizeof i386fbsd_sigtramp_start) ==
66
-      0) {
67
-    middle = i386fbsd_sigtramp_middle;
68
-    end = i386fbsd_sigtramp_end;
69
-  } else if (memcmp (buf, i386fbsd_freebsd4_sigtramp_start,
70
-		     sizeof i386fbsd_freebsd4_sigtramp_start) == 0) {
71
-    middle = i386fbsd_freebsd4_sigtramp_middle;
72
-    end = i386fbsd_freebsd4_sigtramp_end;
73
-  } else if (memcmp (buf, i386fbsd_osigtramp_start,
74
-		     sizeof i386fbsd_osigtramp_start) == 0) {
75
-    middle = i386fbsd_osigtramp_middle;
76
-    end = i386fbsd_osigtramp_end;
77
-  } else
78
+  if (memcmp (buf, i386fbsd_sigtramp_start, sizeof i386fbsd_sigtramp_start)
79
+      == 0)
80
+    {
81
+      middle = i386fbsd_sigtramp_middle;
82
+      end = i386fbsd_sigtramp_end;
83
+    }
84
+  else if (memcmp (buf, i386fbsd_freebsd4_sigtramp_start,
85
+		   sizeof i386fbsd_freebsd4_sigtramp_start) == 0)
86
+    {
87
+      middle = i386fbsd_freebsd4_sigtramp_middle;
88
+      end = i386fbsd_freebsd4_sigtramp_end;
89
+    }
90
+  else if (memcmp (buf, i386fbsd_osigtramp_start,
91
+		   sizeof i386fbsd_osigtramp_start) == 0)
92
+    {
93
+      middle = i386fbsd_osigtramp_middle;
94
+      end = i386fbsd_osigtramp_end;
95
+    }
96
+  else
97
     return 0;
98
 
99
   /* Since the end is shorter than the middle, check for a matching end
(-)devel/gdb/files/commit-97de354 (-690 lines)
Removed Link Here
1
diff --git bfd/elf.c bfd/elf.c
2
index a031b9e..41fb023 100644
3
--- bfd/elf.c
4
+++ bfd/elf.c
5
@@ -8737,6 +8737,9 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
6
       if (note->namesz == 6
7
 	  && strcmp (note->namedata, "LINUX") == 0)
8
 	return elfcore_grok_xstatereg (abfd, note);
9
+      else if (note->namesz == 8
10
+	  && strcmp (note->namedata, "FreeBSD") == 0)
11
+	return elfcore_grok_xstatereg (abfd, note);
12
       else
13
 	return TRUE;
14
 
15
@@ -9556,7 +9559,11 @@ char *
16
 elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
17
 			 const void *xfpregs, int size)
18
 {
19
-  char *note_name = "LINUX";
20
+  char *note_name;
21
+  if (get_elf_backend_data (abfd)->elf_osabi == ELFOSABI_FREEBSD)
22
+    note_name = "FreeBSD";
23
+  else
24
+    note_name = "LINUX";
25
   return elfcore_write_note (abfd, buf, bufsiz,
26
 			     note_name, NT_X86_XSTATE, xfpregs, size);
27
 }
28
diff --git gdb/amd64-tdep.c gdb/amd64-tdep.c
29
index 3e5d1bd..461b701 100644
30
--- gdb/amd64-tdep.c
31
+++ gdb/amd64-tdep.c
32
@@ -39,6 +39,7 @@
33
 #include "disasm.h"
34
 #include "amd64-tdep.h"
35
 #include "i387-tdep.h"
36
+#include "x86-xstate.h"
37
 
38
 #include "features/i386/amd64.c"
39
 #include "features/i386/amd64-avx.c"
40
@@ -3118,6 +3119,25 @@ amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
41
   set_gdbarch_ptr_bit (gdbarch, 32);
42
 }
43
 
44
+/* Return the target description for a specified XSAVE feature mask.  */
45
+
46
+const struct target_desc *
47
+amd64_target_description (uint64_t xcr0)
48
+{
49
+  switch (xcr0 & X86_XSTATE_ALL_MASK)
50
+    {
51
+    case X86_XSTATE_MPX_AVX512_MASK:
52
+    case X86_XSTATE_AVX512_MASK:
53
+      return tdesc_amd64_avx512;
54
+    case X86_XSTATE_MPX_MASK:
55
+      return tdesc_amd64_mpx;
56
+    case X86_XSTATE_AVX_MASK:
57
+      return tdesc_amd64_avx;
58
+    default:
59
+      return tdesc_amd64;
60
+    }
61
+}
62
+
63
 /* Provide a prototype to silence -Wmissing-prototypes.  */
64
 void _initialize_amd64_tdep (void);
65
 
66
diff --git gdb/amd64-tdep.h gdb/amd64-tdep.h
67
index 318fd43..704225e 100644
68
--- gdb/amd64-tdep.h
69
+++ gdb/amd64-tdep.h
70
@@ -84,6 +84,8 @@ enum amd64_regnum
71
 
72
 #define AMD64_NUM_REGS		(AMD64_ZMM31H_REGNUM + 1)
73
 
74
+extern struct target_desc *tdesc_amd64;
75
+
76
 extern struct displaced_step_closure *amd64_displaced_step_copy_insn
77
   (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to,
78
    struct regcache *regs);
79
@@ -95,6 +97,7 @@ extern void amd64_displaced_step_fixup (struct gdbarch *gdbarch,
80
 extern void amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
81
 extern void amd64_x32_init_abi (struct gdbarch_info info,
82
 				struct gdbarch *gdbarch);
83
+extern const struct target_desc *amd64_target_description (uint64_t xcr0);
84
 
85
 /* Fill register REGNUM in REGCACHE with the appropriate
86
    floating-point or SSE register value from *FXSAVE.  If REGNUM is
87
diff --git gdb/amd64bsd-nat.c gdb/amd64bsd-nat.c
88
index 31060a123..66d4289 100644
89
--- gdb/amd64bsd-nat.c
90
+++ gdb/amd64bsd-nat.c
91
@@ -35,6 +35,10 @@
92
 #include "inf-ptrace.h"
93
 
94
 
95
+#ifdef PT_GETXSTATE_INFO
96
+size_t amd64bsd_xsave_len;
97
+#endif
98
+
99
 /* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
100
    for all registers (including the floating-point registers).  */
101
 
102
@@ -60,6 +64,20 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
103
   if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
104
     {
105
       struct fpreg fpregs;
106
+#ifdef PT_GETXSTATE_INFO
107
+      char *xstateregs;
108
+
109
+      if (amd64bsd_xsave_len != 0)
110
+	{
111
+	  xstateregs = alloca (amd64bsd_xsave_len);
112
+	  if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
113
+		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
114
+	    perror_with_name (_("Couldn't get extended state status"));
115
+
116
+	  amd64_supply_xsave (regcache, -1, xstateregs);
117
+	  return;
118
+	}
119
+#endif
120
 
121
       if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
122
 		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
123
@@ -99,6 +117,24 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
124
   if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
125
     {
126
       struct fpreg fpregs;
127
+#ifdef PT_GETXSTATE_INFO
128
+      char *xstateregs;
129
+
130
+      if (amd64bsd_xsave_len != 0)
131
+	{
132
+	  xstateregs = alloca (amd64bsd_xsave_len);
133
+	  if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
134
+		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
135
+	    perror_with_name (_("Couldn't get extended state status"));
136
+
137
+	  amd64_collect_xsave (regcache, regnum, xstateregs, 0);
138
+
139
+	  if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
140
+		      (PTRACE_TYPE_ARG3) xstateregs, amd64bsd_xsave_len) == -1)
141
+	    perror_with_name (_("Couldn't write extended state status"));
142
+	  return;
143
+	}
144
+#endif
145
 
146
       if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
147
 		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
148
diff --git gdb/amd64bsd-nat.h gdb/amd64bsd-nat.h
149
index 167eb56..09776ee 100644
150
--- gdb/amd64bsd-nat.h
151
+++ gdb/amd64bsd-nat.h
152
@@ -20,6 +20,9 @@
153
 #ifndef AMD64BSD_NAT_H
154
 #define AMD64BSD_NAT_H
155
 
156
+/* Low level amd64 XSAVE info.  */
157
+extern size_t amd64bsd_xsave_len;
158
+
159
 /* Low level amd64 debug register functions.  */
160
 
161
 extern void amd64bsd_dr_set_control (unsigned long control);
162
diff --git gdb/amd64fbsd-nat.c gdb/amd64fbsd-nat.c
163
index b1b261c..a721f48 100644
164
--- gdb/amd64fbsd-nat.c
165
+++ gdb/amd64fbsd-nat.c
166
@@ -151,6 +151,50 @@ amd64fbsd_mourn_inferior (struct target_ops *ops)
167
   super_mourn_inferior (ops);
168
 }
169
 
170
+/* Implement the to_read_description method.  */
171
+
172
+static const struct target_desc *
173
+amd64fbsd_read_description (struct target_ops *ops)
174
+{
175
+#ifdef PT_GETXSTATE_INFO
176
+  static int xsave_probed;
177
+  static uint64_t xcr0;
178
+#endif
179
+  struct reg regs;
180
+  int is64;
181
+
182
+  if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
183
+	      (PTRACE_TYPE_ARG3) &regs, 0) == -1)
184
+    perror_with_name (_("Couldn't get registers"));
185
+  is64 = (regs.r_cs == GSEL (GUCODE_SEL, SEL_UPL));
186
+#ifdef PT_GETXSTATE_INFO
187
+  if (!xsave_probed)
188
+    {
189
+      struct ptrace_xstate_info info;
190
+
191
+      if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid),
192
+		  (PTRACE_TYPE_ARG3) &info, sizeof (info)) == 0)
193
+	{
194
+	  amd64bsd_xsave_len = info.xsave_len;
195
+	  xcr0 = info.xsave_mask;
196
+	}
197
+      xsave_probed = 1;
198
+    }
199
+
200
+  if (amd64bsd_xsave_len != 0)
201
+    {
202
+      if (is64)
203
+	return amd64_target_description (xcr0);
204
+      else
205
+	return i386_target_description (xcr0);
206
+    }
207
+#endif
208
+  if (is64)
209
+    return tdesc_amd64;
210
+  else
211
+    return tdesc_i386;
212
+}
213
+
214
 /* Provide a prototype to silence -Wmissing-prototypes.  */
215
 void _initialize_amd64fbsd_nat (void);
216
 
217
@@ -181,6 +225,7 @@ _initialize_amd64fbsd_nat (void)
218
 
219
   super_mourn_inferior = t->to_mourn_inferior;
220
   t->to_mourn_inferior = amd64fbsd_mourn_inferior;
221
+  t->to_read_description = amd64fbsd_read_description;
222
 
223
   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
224
   t->to_find_memory_regions = fbsd_find_memory_regions;
225
diff --git gdb/amd64fbsd-tdep.c gdb/amd64fbsd-tdep.c
226
index 62dcb83..52705d9 100644
227
--- gdb/amd64fbsd-tdep.c
228
+++ gdb/amd64fbsd-tdep.c
229
@@ -23,6 +23,9 @@
230
 #include "gdbcore.h"
231
 #include "regcache.h"
232
 #include "osabi.h"
233
+#include "regset.h"
234
+#include "i386fbsd-tdep.h"
235
+#include "x86-xstate.h"
236
 
237
 #include "amd64-tdep.h"
238
 #include "bsd-uthread.h"
239
@@ -169,6 +172,59 @@ static int amd64fbsd_jmp_buf_reg_offset[] =
240
   0 * 8				/* %rip */
241
 };
242
 
243
+/* Implement the core_read_description gdbarch method.  */
244
+
245
+static const struct target_desc *
246
+amd64fbsd_core_read_description (struct gdbarch *gdbarch,
247
+				 struct target_ops *target,
248
+				 bfd *abfd)
249
+{
250
+  return amd64_target_description (i386fbsd_core_read_xcr0 (abfd));
251
+}
252
+
253
+/* Similar to amd64_supply_fpregset, but use XSAVE extended state.  */
254
+
255
+static void
256
+amd64fbsd_supply_xstateregset (const struct regset *regset,
257
+			       struct regcache *regcache, int regnum,
258
+			       const void *xstateregs, size_t len)
259
+{
260
+  amd64_supply_xsave (regcache, regnum, xstateregs);
261
+}
262
+
263
+/* Similar to amd64_collect_fpregset, but use XSAVE extended state.  */
264
+
265
+static void
266
+amd64fbsd_collect_xstateregset (const struct regset *regset,
267
+				const struct regcache *regcache,
268
+				int regnum, void *xstateregs, size_t len)
269
+{
270
+  amd64_collect_xsave (regcache, regnum, xstateregs, 1);
271
+}
272
+
273
+static const struct regset amd64fbsd_xstateregset =
274
+  {
275
+    NULL,
276
+    amd64fbsd_supply_xstateregset,
277
+    amd64fbsd_collect_xstateregset
278
+  };
279
+
280
+/* Iterate over core file register note sections.  */
281
+
282
+static void
283
+amd64fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
284
+					iterate_over_regset_sections_cb *cb,
285
+					void *cb_data,
286
+					const struct regcache *regcache)
287
+{
288
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
289
+
290
+  cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data);
291
+  cb (".reg2", tdep->sizeof_fpregset, &amd64_fpregset, NULL, cb_data);
292
+  cb (".reg-xstate", X86_XSTATE_SIZE(tdep->xcr0),
293
+      &amd64fbsd_xstateregset, "XSAVE extended state", cb_data);
294
+}
295
+
296
 static void
297
 amd64fbsd_supply_uthread (struct regcache *regcache,
298
 			  int regnum, CORE_ADDR addr)
299
@@ -233,6 +289,15 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
300
   tdep->sc_reg_offset = amd64fbsd_sc_reg_offset;
301
   tdep->sc_num_regs = ARRAY_SIZE (amd64fbsd_sc_reg_offset);
302
 
303
+  tdep->xsave_xcr0_offset = I386_FBSD_XSAVE_XCR0_OFFSET;
304
+
305
+  /* Iterate over core file register note sections.  */
306
+  set_gdbarch_iterate_over_regset_sections
307
+    (gdbarch, amd64fbsd_iterate_over_regset_sections);
308
+
309
+  set_gdbarch_core_read_description (gdbarch,
310
+				     amd64fbsd_core_read_description);
311
+
312
   /* FreeBSD provides a user-level threads implementation.  */
313
   bsd_uthread_set_supply_uthread (gdbarch, amd64fbsd_supply_uthread);
314
   bsd_uthread_set_collect_uthread (gdbarch, amd64fbsd_collect_uthread);
315
diff --git gdb/i386-tdep.c gdb/i386-tdep.c
316
index 4d97915..0c7eb5a 100644
317
--- gdb/i386-tdep.c
318
+++ gdb/i386-tdep.c
319
@@ -8598,6 +8598,25 @@ i386_coff_osabi_sniffer (bfd *abfd)
320
 }
321
 
322
 
323
+/* Return the target description for a specified XSAVE feature mask.  */
324
+
325
+const struct target_desc *
326
+i386_target_description (uint64_t xcr0)
327
+{
328
+  switch (xcr0 & X86_XSTATE_ALL_MASK)
329
+    {
330
+    case X86_XSTATE_MPX_AVX512_MASK:
331
+    case X86_XSTATE_AVX512_MASK:
332
+      return tdesc_i386_avx512;
333
+    case X86_XSTATE_MPX_MASK:
334
+      return tdesc_i386_mpx;
335
+    case X86_XSTATE_AVX_MASK:
336
+      return tdesc_i386_avx;
337
+    default:
338
+      return tdesc_i386;
339
+    }
340
+}
341
+
342
 /* Provide a prototype to silence -Wmissing-prototypes.  */
343
 void _initialize_i386_tdep (void);
344
 
345
diff --git gdb/i386-tdep.h gdb/i386-tdep.h
346
index 8bfd412..7880f6c 100644
347
--- gdb/i386-tdep.h
348
+++ gdb/i386-tdep.h
349
@@ -328,6 +328,8 @@ enum record_i386_regnum
350
 /* Size of the largest register.  */
351
 #define I386_MAX_REGISTER_SIZE	64
352
 
353
+extern struct target_desc *tdesc_i386;
354
+
355
 /* Types for i386-specific registers.  */
356
 extern struct type *i387_ext_type (struct gdbarch *gdbarch);
357
 
358
@@ -416,6 +418,7 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
359
 
360
 extern int i386_process_record (struct gdbarch *gdbarch,
361
                                 struct regcache *regcache, CORE_ADDR addr);
362
+extern const struct target_desc *i386_target_description (uint64_t xcr0);
363
 
364
 
365
 
366
diff --git gdb/i386bsd-nat.c gdb/i386bsd-nat.c
367
index 16e0707..ac8a19b 100644
368
--- gdb/i386bsd-nat.c
369
+++ gdb/i386bsd-nat.c
370
@@ -81,6 +81,10 @@ static int i386bsd_r_reg_offset[] =
371
    so that we try PT_GETXMMREGS the first time around.  */
372
 static int have_ptrace_xmmregs = -1;
373
 #endif
374
+
375
+#ifdef PT_GETXSTATE_INFO
376
+size_t i386bsd_xsave_len;
377
+#endif
378
 
379
 
380
 /* Supply the general-purpose registers in GREGS, to REGCACHE.  */
381
@@ -148,7 +152,24 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
382
       struct fpreg fpregs;
383
 #ifdef HAVE_PT_GETXMMREGS
384
       char xmmregs[512];
385
+#endif
386
+
387
+#ifdef PT_GETXSTATE_INFO
388
+      if (i386bsd_xsave_len != 0)
389
+	{
390
+	  char *xstateregs;
391
+
392
+	  xstateregs = alloca (i386bsd_xsave_len);
393
+	  if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
394
+		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
395
+	    perror_with_name (_("Couldn't get extended state status"));
396
 
397
+	  i387_supply_xsave (regcache, -1, xstateregs);
398
+	  return;
399
+	}
400
+#endif
401
+      
402
+#ifdef HAVE_PT_GETXMMREGS
403
       if (have_ptrace_xmmregs != 0
404
 	  && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
405
 		    (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
406
@@ -158,18 +179,15 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
407
 	}
408
       else
409
 	{
410
+	  have_ptrace_xmmregs = 0;
411
+#endif
412
           if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
413
 		      (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
414
 	    perror_with_name (_("Couldn't get floating point status"));
415
 
416
 	  i387_supply_fsave (regcache, -1, &fpregs);
417
+#ifdef HAVE_PT_GETXMMREGS
418
 	}
419
-#else
420
-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
421
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
422
-	perror_with_name (_("Couldn't get floating point status"));
423
-
424
-      i387_supply_fsave (regcache, -1, &fpregs);
425
 #endif
426
     }
427
 }
428
@@ -204,7 +222,28 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
429
       struct fpreg fpregs;
430
 #ifdef HAVE_PT_GETXMMREGS
431
       char xmmregs[512];
432
+#endif
433
+
434
+#ifdef PT_GETXSTATE_INFO
435
+      if (i386bsd_xsave_len != 0)
436
+	{
437
+	  char *xstateregs;
438
+
439
+	  xstateregs = alloca (i386bsd_xsave_len);
440
+	  if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
441
+		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
442
+	    perror_with_name (_("Couldn't get extended state status"));
443
 
444
+	  i387_collect_xsave (regcache, -1, xstateregs, 0);
445
+
446
+	  if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid),
447
+		      (PTRACE_TYPE_ARG3) xstateregs, i386bsd_xsave_len) == -1)
448
+	    perror_with_name (_("Couldn't write extended state status"));
449
+	  return;
450
+	}
451
+#endif
452
+
453
+#ifdef HAVE_PT_GETXMMREGS
454
       if (have_ptrace_xmmregs != 0
455
 	  && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
456
 		    (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
457
diff --git gdb/i386bsd-nat.h gdb/i386bsd-nat.h
458
index a11f554..2f50c32 100644
459
--- gdb/i386bsd-nat.h
460
+++ gdb/i386bsd-nat.h
461
@@ -25,6 +25,9 @@
462
 
463
 extern struct target_ops *i386bsd_target (void);
464
 
465
+/* Low level i386 XSAVE info.  */
466
+extern size_t i386bsd_xsave_len;
467
+
468
 /* low level i386 debug register functions used in i386fbsd-nat.c.  */
469
 
470
 extern void i386bsd_dr_set_control (unsigned long control);
471
diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c
472
index ad439e3..6c43f2c 100644
473
--- gdb/i386fbsd-nat.c
474
+++ gdb/i386fbsd-nat.c
475
@@ -116,6 +116,37 @@ i386fbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
476
 }
477
 
478
 
479
+#ifdef PT_GETXSTATE_INFO
480
+/* Implement the to_read_description method.  */
481
+
482
+static const struct target_desc *
483
+i386fbsd_read_description (struct target_ops *ops)
484
+{
485
+  static int xsave_probed;
486
+  static uint64_t xcr0;
487
+
488
+  if (!xsave_probed)
489
+    {
490
+      struct ptrace_xstate_info info;
491
+
492
+      if (ptrace (PT_GETXSTATE_INFO, ptid_get_pid (inferior_ptid),
493
+		  (PTRACE_TYPE_ARG3) &info, sizeof (info)) == 0)
494
+	{
495
+	  i386bsd_xsave_len = info.xsave_len;
496
+	  xcr0 = info.xsave_mask;
497
+	}
498
+      xsave_probed = 1;
499
+    }
500
+
501
+  if (i386bsd_xsave_len != 0)
502
+    {
503
+      return i386_target_description (xcr0);
504
+    }
505
+  else
506
+    return tdesc_i386;
507
+}
508
+#endif
509
+
510
 /* Prevent warning from -Wmissing-prototypes.  */
511
 void _initialize_i386fbsd_nat (void);
512
 
513
@@ -140,6 +171,9 @@ _initialize_i386fbsd_nat (void)
514
 
515
 #endif /* HAVE_PT_GETDBREGS */
516
 
517
+#ifdef PT_GETXSTATE_INFO
518
+  t->to_read_description = i386fbsd_read_description;
519
+#endif
520
 
521
   t->to_resume = i386fbsd_resume;
522
   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
523
diff --git gdb/i386fbsd-tdep.c gdb/i386fbsd-tdep.c
524
index ed41706..99e08cb 100644
525
--- gdb/i386fbsd-tdep.c
526
+++ gdb/i386fbsd-tdep.c
527
@@ -22,6 +22,9 @@
528
 #include "gdbcore.h"
529
 #include "osabi.h"
530
 #include "regcache.h"
531
+#include "regset.h"
532
+#include "i386fbsd-tdep.h"
533
+#include "x86-xstate.h"
534
 
535
 #include "i386-tdep.h"
536
 #include "i387-tdep.h"
537
@@ -235,6 +238,100 @@ static int i386fbsd_jmp_buf_reg_offset[] =
538
   0 * 4				/* %eip */
539
 };
540
 
541
+/* Get XSAVE extended state xcr0 from core dump.  */
542
+
543
+uint64_t
544
+i386fbsd_core_read_xcr0 (bfd *abfd)
545
+{
546
+  asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate");
547
+  uint64_t xcr0;
548
+
549
+  if (xstate)
550
+    {
551
+      size_t size = bfd_section_size (abfd, xstate);
552
+
553
+      /* Check extended state size.  */
554
+      if (size < X86_XSTATE_AVX_SIZE)
555
+	xcr0 = X86_XSTATE_SSE_MASK;
556
+      else
557
+	{
558
+	  char contents[8];
559
+
560
+	  if (! bfd_get_section_contents (abfd, xstate, contents,
561
+					  I386_FBSD_XSAVE_XCR0_OFFSET,
562
+					  8))
563
+	    {
564
+	      warning (_("Couldn't read `xcr0' bytes from "
565
+			 "`.reg-xstate' section in core file."));
566
+	      return 0;
567
+	    }
568
+
569
+	  xcr0 = bfd_get_64 (abfd, contents);
570
+	}
571
+    }
572
+  else
573
+    xcr0 = 0;
574
+
575
+  return xcr0;
576
+}
577
+
578
+/* Implement the core_read_description gdbarch method.  */
579
+
580
+static const struct target_desc *
581
+i386fbsd_core_read_description (struct gdbarch *gdbarch,
582
+				struct target_ops *target,
583
+				bfd *abfd)
584
+{
585
+  return i386_target_description (i386fbsd_core_read_xcr0 (abfd));
586
+}
587
+
588
+/* Similar to i386_supply_fpregset, but use XSAVE extended state.  */
589
+
590
+static void
591
+i386fbsd_supply_xstateregset (const struct regset *regset,
592
+			      struct regcache *regcache, int regnum,
593
+			      const void *xstateregs, size_t len)
594
+{
595
+  i387_supply_xsave (regcache, regnum, xstateregs);
596
+}
597
+
598
+/* Similar to i386_collect_fpregset, but use XSAVE extended state.  */
599
+
600
+static void
601
+i386fbsd_collect_xstateregset (const struct regset *regset,
602
+			       const struct regcache *regcache,
603
+			       int regnum, void *xstateregs, size_t len)
604
+{
605
+  i387_collect_xsave (regcache, regnum, xstateregs, 1);
606
+}
607
+
608
+/* Register set definitions.  */
609
+
610
+static const struct regset i386fbsd_xstateregset =
611
+  {
612
+    NULL,
613
+    i386fbsd_supply_xstateregset,
614
+    i386fbsd_collect_xstateregset
615
+  };
616
+
617
+/* Iterate over core file register note sections.  */
618
+
619
+static void
620
+i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
621
+				       iterate_over_regset_sections_cb *cb,
622
+				       void *cb_data,
623
+				       const struct regcache *regcache)
624
+{
625
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
626
+
627
+  cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data);
628
+  cb (".reg2", tdep->sizeof_fpregset, &i386_fpregset, NULL, cb_data);
629
+
630
+  if (tdep->xcr0 & X86_XSTATE_AVX)
631
+    cb (".reg-xstate", X86_XSTATE_SIZE(tdep->xcr0),
632
+	&i386fbsd_xstateregset, "XSAVE extended state", cb_data);
633
+}
634
+
635
 static void
636
 i386fbsd_supply_uthread (struct regcache *regcache,
637
 			 int regnum, CORE_ADDR addr)
638
@@ -376,6 +473,15 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
639
   /* FreeBSD 4.0 introduced a new `struct sigcontext'.  */
640
   tdep->sc_reg_offset = i386fbsd4_sc_reg_offset;
641
   tdep->sc_num_regs = ARRAY_SIZE (i386fbsd4_sc_reg_offset);
642
+
643
+  tdep->xsave_xcr0_offset = I386_FBSD_XSAVE_XCR0_OFFSET;
644
+
645
+  /* Iterate over core file register note sections.  */
646
+  set_gdbarch_iterate_over_regset_sections
647
+    (gdbarch, i386fbsd_iterate_over_regset_sections);
648
+
649
+  set_gdbarch_core_read_description (gdbarch,
650
+				     i386fbsd_core_read_description);
651
 }
652
 
653
 
654
diff --git gdb/i386fbsd-tdep.h gdb/i386fbsd-tdep.h
655
new file mode 100644
656
index 0000000..8d6f998
657
--- /dev/null
658
+++ gdb/i386fbsd-tdep.h
659
@@ -0,0 +1,31 @@
660
+/* Target-dependent code for FreeBSD x86.
661
+
662
+   Copyright (C) 2015 Free Software Foundation, Inc.
663
+
664
+   This file is part of GDB.
665
+
666
+   This program is free software; you can redistribute it and/or modify
667
+   it under the terms of the GNU General Public License as published by
668
+   the Free Software Foundation; either version 3 of the License, or
669
+   (at your option) any later version.
670
+
671
+   This program is distributed in the hope that it will be useful,
672
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
673
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
674
+   GNU General Public License for more details.
675
+
676
+   You should have received a copy of the GNU General Public License
677
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
678
+
679
+#ifndef I386FBSD_TDEP_H
680
+#define I386FBSD_TDEP_H
681
+
682
+/* Get XSAVE extended state xcr0 from core dump.  */
683
+extern uint64_t i386fbsd_core_read_xcr0 (bfd *abfd);
684
+
685
+/* The format of the XSAVE extended area is determined by hardware.
686
+   Cores store the XSAVE extended area in a NT_X86_XSTATE note that
687
+   matches the layout on Linux.  */
688
+#define I386_FBSD_XSAVE_XCR0_OFFSET 464
689
+
690
+#endif /* i386fbsd-tdep.h */
(-)devel/gdb/files/commit-c5cb74e (-22 lines)
Removed Link Here
1
diff --git gdb/amd64fbsd-tdep.c gdb/amd64fbsd-tdep.c
2
index 2d49cdf..abb0cab 100644
3
--- gdb/amd64fbsd-tdep.c
4
+++ gdb/amd64fbsd-tdep.c
5
@@ -37,12 +37,16 @@
6
 static CORE_ADDR
7
 amd64fbsd_sigcontext_addr (struct frame_info *this_frame)
8
 {
9
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
10
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
11
   CORE_ADDR sp;
12
+  gdb_byte buf[8];
13
 
14
   /* The `struct sigcontext' (which really is an `ucontext_t' on
15
      FreeBSD/amd64) lives at a fixed offset in the signal frame.  See
16
      <machine/sigframe.h>.  */
17
-  sp = frame_unwind_register_unsigned (this_frame, AMD64_RSP_REGNUM);
18
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
19
+  sp = extract_unsigned_integer (buf, 8, byte_order);
20
   return sp + 16;
21
 }
22
 
(-)devel/gdb/files/commit-cf424ae (-348 lines)
Removed Link Here
1
diff --git gdb/amd64fbsd-nat.c gdb/amd64fbsd-nat.c
2
index 1c396e2..b1b261c 100644
3
--- gdb/amd64fbsd-nat.c
4
+++ gdb/amd64fbsd-nat.c
5
@@ -26,6 +26,7 @@
6
 #include <sys/types.h>
7
 #include <sys/ptrace.h>
8
 #include <sys/sysctl.h>
9
+#include <sys/user.h>
10
 #include <machine/reg.h>
11
 
12
 #include "fbsd-nat.h"
13
@@ -244,24 +245,31 @@ Please report this to <bug-gdb@gnu.org>."),
14
 
15
   SC_RBP_OFFSET = offset;
16
 
17
-  /* FreeBSD provides a kern.ps_strings sysctl that we can use to
18
-     locate the sigtramp.  That way we can still recognize a sigtramp
19
-     if its location is changed in a new kernel.  Of course this is
20
-     still based on the assumption that the sigtramp is placed
21
-     directly under the location where the program arguments and
22
-     environment can be found.  */
23
+#ifdef KERN_PROC_SIGTRAMP
24
+  /* Normally signal frames are detected via amd64fbsd_sigtramp_p.
25
+     However, FreeBSD 9.2 through 10.1 do not include the page holding
26
+     the signal code in core dumps.  These releases do provide a
27
+     kern.proc.sigtramp.<pid> sysctl that returns the location of the
28
+     signal trampoline for a running process.  We fetch the location
29
+     of the current (gdb) process and use this to identify signal
30
+     frames in core dumps from these releases.  Note that this only
31
+     works for core dumps of 64-bit (FreeBSD/amd64) processes and does
32
+     not handle core dumps of 32-bit (FreeBSD/i386) processes.  */
33
   {
34
-    int mib[2];
35
-    long ps_strings;
36
+    int mib[4];
37
+    struct kinfo_sigtramp kst;
38
     size_t len;
39
 
40
     mib[0] = CTL_KERN;
41
-    mib[1] = KERN_PS_STRINGS;
42
-    len = sizeof (ps_strings);
43
-    if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0)
44
+    mib[1] = KERN_PROC;
45
+    mib[2] = KERN_PROC_SIGTRAMP;
46
+    mib[3] = getpid ();
47
+    len = sizeof (kst);
48
+    if (sysctl (mib, 4, &kst, &len, NULL, 0) == 0)
49
       {
50
-	amd64fbsd_sigtramp_start_addr = ps_strings - 32;
51
-	amd64fbsd_sigtramp_end_addr = ps_strings;
52
+	amd64fbsd_sigtramp_start_addr = (uintptr_t) kst.ksigtramp_start;
53
+	amd64fbsd_sigtramp_end_addr = (uintptr_t) kst.ksigtramp_end;
54
       }
55
   }
56
+#endif
57
 }
58
diff --git gdb/amd64fbsd-tdep.c gdb/amd64fbsd-tdep.c
59
index abb0cab..e11b0f3 100644
60
--- gdb/amd64fbsd-tdep.c
61
+++ gdb/amd64fbsd-tdep.c
62
@@ -31,6 +31,33 @@
63
 
64
 /* Support for signal handlers.  */
65
 
66
+/* Return whether THIS_FRAME corresponds to a FreeBSD sigtramp
67
+   routine.  */
68
+
69
+static const gdb_byte amd64fbsd_sigtramp_code[] =
70
+{
71
+  0x48, 0x8d, 0x7c, 0x24, 0x10, /* lea     SIGF_UC(%rsp),%rdi */
72
+  0x6a, 0x00,			/* pushq   $0 */
73
+  0x48, 0xc7, 0xc0, 0xa1, 0x01, 0x00, 0x00,
74
+				/* movq    $SYS_sigreturn,%rax */
75
+  0x0f, 0x05                    /* syscall */
76
+};
77
+
78
+static int
79
+amd64fbsd_sigtramp_p (struct frame_info *this_frame)
80
+{
81
+  CORE_ADDR pc = get_frame_pc (this_frame);
82
+  gdb_byte buf[sizeof amd64fbsd_sigtramp_code];
83
+
84
+  if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
85
+    return 0;
86
+  if (memcmp (buf, amd64fbsd_sigtramp_code, sizeof amd64fbsd_sigtramp_code) !=
87
+      0)
88
+    return 0;
89
+
90
+  return 1;
91
+}
92
+
93
 /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
94
    address of the associated sigcontext structure.  */
95
 
96
@@ -88,8 +115,8 @@ static int amd64fbsd_r_reg_offset[] =
97
 };
98
 
99
 /* Location of the signal trampoline.  */
100
-CORE_ADDR amd64fbsd_sigtramp_start_addr = 0x7fffffffffc0ULL;
101
-CORE_ADDR amd64fbsd_sigtramp_end_addr = 0x7fffffffffe0ULL;
102
+CORE_ADDR amd64fbsd_sigtramp_start_addr;
103
+CORE_ADDR amd64fbsd_sigtramp_end_addr;
104
 
105
 /* From <machine/signal.h>.  */
106
 int amd64fbsd_sc_reg_offset[] =
107
@@ -199,6 +226,7 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
108
 
109
   amd64_init_abi (info, gdbarch);
110
 
111
+  tdep->sigtramp_p = amd64fbsd_sigtramp_p;
112
   tdep->sigtramp_start = amd64fbsd_sigtramp_start_addr;
113
   tdep->sigtramp_end = amd64fbsd_sigtramp_end_addr;
114
   tdep->sigcontext_addr = amd64fbsd_sigcontext_addr;
115
diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c
116
index f4951d1..ad439e3 100644
117
--- gdb/i386fbsd-nat.c
118
+++ gdb/i386fbsd-nat.c
119
@@ -25,6 +25,7 @@
120
 #include <sys/types.h>
121
 #include <sys/ptrace.h>
122
 #include <sys/sysctl.h>
123
+#include <sys/user.h>
124
 
125
 #include "fbsd-nat.h"
126
 #include "i386-tdep.h"
127
@@ -148,25 +149,28 @@ _initialize_i386fbsd_nat (void)
128
   /* Support debugging kernel virtual memory images.  */
129
   bsd_kvm_add_target (i386fbsd_supply_pcb);
130
 
131
-  /* FreeBSD provides a kern.ps_strings sysctl that we can use to
132
-     locate the sigtramp.  That way we can still recognize a sigtramp
133
-     if its location is changed in a new kernel.  Of course this is
134
-     still based on the assumption that the sigtramp is placed
135
-     directly under the location where the program arguments and
136
-     environment can be found.  */
137
-#ifdef KERN_PS_STRINGS
138
+#ifdef KERN_PROC_SIGTRAMP
139
+  /* Normally signal frames are detected via i386fbsd_sigtramp_p.
140
+     However, FreeBSD 9.2 through 10.1 do not include the page holding
141
+     the signal code in core dumps.  These releases do provide a
142
+     kern.proc.sigtramp.<pid> sysctl that returns the location of the
143
+     signal trampoline for a running process.  We fetch the location
144
+     of the current (gdb) process and use this to identify signal
145
+     frames in core dumps from these releases.  */
146
   {
147
-    int mib[2];
148
-    u_long ps_strings;
149
+    int mib[4];
150
+    struct kinfo_sigtramp kst;
151
     size_t len;
152
 
153
     mib[0] = CTL_KERN;
154
-    mib[1] = KERN_PS_STRINGS;
155
-    len = sizeof (ps_strings);
156
-    if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0)
157
+    mib[1] = KERN_PROC;
158
+    mib[2] = KERN_PROC_SIGTRAMP;
159
+    mib[3] = getpid ();
160
+    len = sizeof (kst);
161
+    if (sysctl (mib, 4, &kst, &len, NULL, 0) == 0)
162
       {
163
-	i386fbsd_sigtramp_start_addr = ps_strings - 128;
164
-	i386fbsd_sigtramp_end_addr = ps_strings;
165
+	i386fbsd_sigtramp_start_addr = (uintptr_t) kst.ksigtramp_start;
166
+	i386fbsd_sigtramp_end_addr = (uintptr_t) kst.ksigtramp_end;
167
       }
168
   }
169
 #endif
170
diff --git gdb/i386fbsd-tdep.c gdb/i386fbsd-tdep.c
171
index 8d237f0..d4516ee 100644
172
--- gdb/i386fbsd-tdep.c
173
+++ gdb/i386fbsd-tdep.c
174
@@ -29,6 +29,154 @@
175
 #include "fbsd-tdep.h"
176
 #include "solib-svr4.h"
177
 
178
+/* Support for signal handlers.  */
179
+
180
+/* Return whether THIS_FRAME corresponds to a FreeBSD sigtramp
181
+   routine.  */
182
+
183
+/* FreeBSD/i386 supports three different signal trampolines, one for
184
+   versions before 4.0, a second for 4.x, and a third for 5.0 and
185
+   later.  To complicate matters, FreeBSD/i386 binaries running under
186
+   an amd64 kernel use a different set of trampolines.  These
187
+   trampolines differ from the i386 kernel trampolines in that they
188
+   omit a middle section that conditionally restores %gs.  */
189
+
190
+static const gdb_byte i386fbsd_sigtramp_start[] =
191
+{
192
+  0x8d, 0x44, 0x24, 0x20,       /* lea     SIGF_UC(%esp),%eax */
193
+  0x50				/* pushl   %eax */
194
+};
195
+
196
+static const gdb_byte i386fbsd_sigtramp_middle[] =
197
+{
198
+  0xf7, 0x40, 0x54, 0x00, 0x00, 0x02, 0x00,
199
+				/* testl   $PSL_VM,UC_EFLAGS(%eax) */
200
+  0x75, 0x03,			/* jne	   +3 */
201
+  0x8e, 0x68, 0x14		/* mov	   UC_GS(%eax),%gs */
202
+};
203
+
204
+static const gdb_byte i386fbsd_sigtramp_end[] =
205
+{
206
+  0xb8, 0xa1, 0x01, 0x00, 0x00, /* movl   $SYS_sigreturn,%eax */
207
+  0x50,			/* pushl   %eax */
208
+  0xcd, 0x80			/* int	   $0x80 */
209
+};
210
+
211
+static const gdb_byte i386fbsd_freebsd4_sigtramp_start[] =
212
+{
213
+  0x8d, 0x44, 0x24, 0x14,	/* lea	   SIGF_UC4(%esp),%eax */
214
+  0x50				/* pushl   %eax */
215
+};
216
+
217
+static const gdb_byte i386fbsd_freebsd4_sigtramp_middle[] =
218
+{
219
+  0xf7, 0x40, 0x54, 0x00, 0x00, 0x02, 0x00,
220
+				/* testl   $PSL_VM,UC4_EFLAGS(%eax) */
221
+  0x75, 0x03,			/* jne	   +3 */
222
+  0x8e, 0x68, 0x14		/* mov	   UC4_GS(%eax),%gs */
223
+};
224
+
225
+static const gdb_byte i386fbsd_freebsd4_sigtramp_end[] =
226
+{
227
+  0xb8, 0x58, 0x01, 0x00, 0x00, /* movl    $344,%eax */
228
+  0x50,			/* pushl   %eax */
229
+  0xcd, 0x80			/* int	   $0x80 */
230
+};
231
+
232
+static const gdb_byte i386fbsd_osigtramp_start[] =
233
+{
234
+  0x8d, 0x44, 0x24, 0x14,	/* lea	   SIGF_SC(%esp),%eax */
235
+  0x50				/* pushl   %eax */
236
+};
237
+
238
+static const gdb_byte i386fbsd_osigtramp_middle[] =
239
+{
240
+  0xf7, 0x40, 0x18, 0x00, 0x00, 0x02, 0x00,
241
+				/* testl   $PSL_VM,SC_PS(%eax) */
242
+  0x75, 0x03,			/* jne	   +3 */
243
+  0x8e, 0x68, 0x44		/* mov	   SC_GS(%eax),%gs */
244
+};
245
+
246
+static const gdb_byte i386fbsd_osigtramp_end[] =
247
+{
248
+  0xb8, 0x67, 0x00, 0x00, 0x00, /* movl    $103,%eax */
249
+  0x50,			/* pushl   %eax */
250
+  0xcd, 0x80			/* int	   $0x80 */
251
+};
252
+
253
+/* The three different trampolines are all the same size.  */
254
+gdb_static_assert (sizeof i386fbsd_sigtramp_start ==
255
+		   sizeof i386fbsd_freebsd4_sigtramp_start);
256
+gdb_static_assert (sizeof i386fbsd_sigtramp_start ==
257
+		   sizeof i386fbsd_osigtramp_start);
258
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle ==
259
+		   sizeof i386fbsd_freebsd4_sigtramp_middle);
260
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle ==
261
+		   sizeof i386fbsd_osigtramp_middle);
262
+gdb_static_assert (sizeof i386fbsd_sigtramp_end ==
263
+		   sizeof i386fbsd_freebsd4_sigtramp_end);
264
+gdb_static_assert (sizeof i386fbsd_sigtramp_end ==
265
+		   sizeof i386fbsd_osigtramp_end);
266
+
267
+/* We assume that the middle is the largest chunk below.  */
268
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle >
269
+		   sizeof i386fbsd_sigtramp_start);
270
+gdb_static_assert (sizeof i386fbsd_sigtramp_middle >
271
+		   sizeof i386fbsd_sigtramp_end);
272
+
273
+static int
274
+i386fbsd_sigtramp_p (struct frame_info *this_frame)
275
+{
276
+  CORE_ADDR pc = get_frame_pc (this_frame);
277
+  gdb_byte buf[sizeof i386fbsd_sigtramp_middle];
278
+  const gdb_byte *middle, *end;
279
+
280
+  /* Look for a matching start.  */
281
+  if (!safe_frame_unwind_memory (this_frame, pc, buf,
282
+				 sizeof i386fbsd_sigtramp_start))
283
+    return 0;
284
+  if (memcmp (buf, i386fbsd_sigtramp_start, sizeof i386fbsd_sigtramp_start) ==
285
+      0) {
286
+    middle = i386fbsd_sigtramp_middle;
287
+    end = i386fbsd_sigtramp_end;
288
+  } else if (memcmp (buf, i386fbsd_freebsd4_sigtramp_start,
289
+		     sizeof i386fbsd_freebsd4_sigtramp_start) == 0) {
290
+    middle = i386fbsd_freebsd4_sigtramp_middle;
291
+    end = i386fbsd_freebsd4_sigtramp_end;
292
+  } else if (memcmp (buf, i386fbsd_osigtramp_start,
293
+		     sizeof i386fbsd_osigtramp_start) == 0) {
294
+    middle = i386fbsd_osigtramp_middle;
295
+    end = i386fbsd_osigtramp_end;
296
+  } else
297
+    return 0;
298
+
299
+  /* Since the end is shorter than the middle, check for a matching end
300
+     next.  */
301
+  pc += sizeof i386fbsd_sigtramp_start;
302
+  if (!safe_frame_unwind_memory (this_frame, pc, buf,
303
+				 sizeof i386fbsd_sigtramp_end))
304
+    return 0;
305
+  if (memcmp (buf, end, sizeof i386fbsd_sigtramp_end) == 0)
306
+    return 1;
307
+
308
+  /* If the end didn't match, check for a matching middle.  */
309
+  if (!safe_frame_unwind_memory (this_frame, pc, buf,
310
+				 sizeof i386fbsd_sigtramp_middle))
311
+    return 0;
312
+  if (memcmp (buf, middle, sizeof i386fbsd_sigtramp_middle) != 0)
313
+    return 0;
314
+
315
+  /* The middle matched, check for a matching end.  */
316
+  pc += sizeof i386fbsd_sigtramp_middle;
317
+  if (!safe_frame_unwind_memory (this_frame, pc, buf,
318
+				 sizeof i386fbsd_sigtramp_end))
319
+    return 0;
320
+  if (memcmp (buf, end, sizeof i386fbsd_sigtramp_end) != 0)
321
+    return 0;
322
+
323
+  return 1;
324
+}
325
+
326
 /* FreeBSD 3.0-RELEASE or later.  */
327
 
328
 /* From <machine/reg.h>.  */
329
@@ -43,8 +191,8 @@ static int i386fbsd_r_reg_offset[] =
330
 };
331
 
332
 /* Sigtramp routine location.  */
333
-CORE_ADDR i386fbsd_sigtramp_start_addr = 0xbfbfdf20;
334
-CORE_ADDR i386fbsd_sigtramp_end_addr = 0xbfbfdff0;
335
+CORE_ADDR i386fbsd_sigtramp_start_addr;
336
+CORE_ADDR i386fbsd_sigtramp_end_addr;
337
 
338
 /* From <machine/signal.h>.  */
339
 int i386fbsd_sc_reg_offset[] =
340
@@ -139,6 +287,8 @@ i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
341
   /* FreeBSD uses -freg-struct-return by default.  */
342
   tdep->struct_return = reg_struct_return;
343
 
344
+  tdep->sigtramp_p = i386fbsd_sigtramp_p;
345
+
346
   /* FreeBSD uses a different memory layout.  */
347
   tdep->sigtramp_start = i386fbsd_sigtramp_start_addr;
348
   tdep->sigtramp_end = i386fbsd_sigtramp_end_addr;
(-)devel/gdb/files/fbsd-threads.c (-4 / +4 lines)
Lines 675-681 attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, Link Here
675
    memset(private, 0, sizeof(struct private_thread_info));
675
    memset(private, 0, sizeof(struct private_thread_info));
676
676
677
    tp = add_thread_with_info(ptid, private);
677
    tp = add_thread_with_info(ptid, private);
678
    tp->private = private;
678
    tp->priv = private;
679
    tp->private_dtor = free_private_thread_info;
679
    tp->private_dtor = free_private_thread_info;
680
  }
680
  }
681
681
Lines 1176-1184 fbsd_thread_pid_to_str (struct target_ops *ops, ptid_t ptid) Link Here
1176
      if (ti.ti_lid != 0)
1176
      if (ti.ti_lid != 0)
1177
        {
1177
        {
1178
          // Need to find the name of this LWP, even though it shouldn't change
1178
          // Need to find the name of this LWP, even though it shouldn't change
1179
          fbsd_find_lwp_name(ti.ti_lid, tinfo->private);
1179
          fbsd_find_lwp_name(ti.ti_lid, tinfo->priv);
1180
1180
1181
          if (tinfo->private->lwp_name == NULL)
1181
          if (tinfo->priv->lwp_name == NULL)
1182
            {
1182
            {
1183
              snprintf(buf, sizeof (buf), "Thread %llx (LWP %d)",
1183
              snprintf(buf, sizeof (buf), "Thread %llx (LWP %d)",
1184
                  (unsigned long long)th.th_thread, ti.ti_lid);
1184
                  (unsigned long long)th.th_thread, ti.ti_lid);
Lines 1187-1193 fbsd_thread_pid_to_str (struct target_ops *ops, ptid_t ptid) Link Here
1187
            {
1187
            {
1188
              snprintf(buf, sizeof (buf), "Thread %llx (LWP %d %s)",
1188
              snprintf(buf, sizeof (buf), "Thread %llx (LWP %d %s)",
1189
                  (unsigned long long)th.th_thread, ti.ti_lid,
1189
                  (unsigned long long)th.th_thread, ti.ti_lid,
1190
                  tinfo->private->lwp_name);
1190
                  tinfo->priv->lwp_name);
1191
            }
1191
            }
1192
        }
1192
        }
1193
      else
1193
      else
(-)devel/gdb/files/patch-gdb-configure (-13 lines)
Lines 22-37 index 355f190..9c60e01 100755 Link Here
22
 "
22
 "
23
 if test "x$ac_cv_member_struct_reg_r_gs" = x""yes; then :
23
 if test "x$ac_cv_member_struct_reg_r_gs" = x""yes; then :
24
 
24
 
25
@@ -12945,10 +12947,9 @@ fi
26
 
27
 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
28
 -Wpointer-sign \
29
--Wno-unused -Wunused-value -Wunused-function \
30
+-Wno-unused -Wunused-value \
31
 -Wno-switch -Wno-char-subscripts -Wmissing-prototypes \
32
--Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
33
--Wold-style-declaration -Wold-style-definition"
34
+-Wdeclaration-after-statement -Wempty-body -Wold-style-definition"
35
 
36
 # Enable -Wno-format by default when using gcc on mingw since many
37
 # GCC versions complain about %I64.
(-)devel/gdb/files/patch-gdb-i386fbsd-nat.c (-3 / +2 lines)
Lines 7-12 index 6c43f2c..a205a26 100644 Link Here
7
 #endif
7
 #endif
8
 
8
 
9
-  t->to_resume = i386fbsd_resume;
9
-  t->to_resume = i386fbsd_resume;
10
   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
10
   fbsd_nat_add_target (t);
11
   t->to_find_memory_regions = fbsd_find_memory_regions;
11
   /* Support debugging kernel virtual memory images.  */
12
   add_target (t);
(-)devel/gdb/pkg-plist (+2 lines)
Lines 9-14 man/man1/gdb%%VER%%.1.gz Link Here
9
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/printing.py
9
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/printing.py
10
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/prompt.py
10
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/prompt.py
11
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/types.py
11
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/types.py
12
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/unwinder.py
12
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/xmethod.py
13
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/xmethod.py
13
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/__init__.py
14
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/__init__.py
14
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/explore.py
15
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/explore.py
Lines 16-21 man/man1/gdb%%VER%%.1.gz Link Here
16
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/pretty_printers.py
17
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/pretty_printers.py
17
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/prompt.py
18
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/prompt.py
18
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/type_printers.py
19
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/type_printers.py
20
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/unwinders.py
19
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/xmethods.py
21
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/command/xmethods.py
20
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/__init__.py
22
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/__init__.py
21
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/caller_is.py
23
%%PYTHON%%%%DATADIR%%%%VER%%/python/gdb/function/caller_is.py

Return to bug 203170