aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-04-28 00:11:53 +0800
committerjhb <jhb@FreeBSD.org>2016-04-28 00:11:53 +0800
commite18decff7b697acaf1d1ff3e2d25e7e4798e851a (patch)
treeff2a5fc4025de6c09ee2e25281b1677be18418e4
parent804328beceae445c15411291eb66315374c78168 (diff)
downloadfreebsd-ports-gnome-e18decff7b697acaf1d1ff3e2d25e7e4798e851a.tar.gz
freebsd-ports-gnome-e18decff7b697acaf1d1ff3e2d25e7e4798e851a.tar.zst
freebsd-ports-gnome-e18decff7b697acaf1d1ff3e2d25e7e4798e851a.zip
Fix an issue with gdb triggering assertions in kgdb on i386.
The kgdb targets use runtime assertions on native targets to verify that the helper arrays documenting the layout of things like the PCB and trapframe structures match. Ideally these asserts would be compile time assertions, but they cannot be checked at compile time. Instead, they are checked at runtime during gdb startup. However, the layout of the i386 PCB changed when the AVX changes were merged to i386. The constants in the i386 target assume the post-AVX layout, but gdb packages on stable branches might be built against pre-AVX worlds. In that case, those gdb binaries will trigger these assertions on every invocation. As a workaround, disable the PCB-related assertions on pre-AVX worlds. If kgdb is run against a pre-AVX kernel it will not be able to parse the PCB correctly, but userland debugging should work fine. kgdb built against a pre-AVX world but run against an AVX kernel should work fine. PR: 209061 Reported by: trasz Approved by: luca.pizzamiglio@gmail.com (maintainer), swills
-rw-r--r--devel/gdb/Makefile2
-rw-r--r--devel/gdb/files/kgdb/i386fbsd-kern.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/devel/gdb/Makefile b/devel/gdb/Makefile
index 36b90c542250..2243970a6c45 100644
--- a/devel/gdb/Makefile
+++ b/devel/gdb/Makefile
@@ -3,7 +3,7 @@
PORTNAME= gdb
PORTVERSION= 7.11
-#PORTREVISION=
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= GNU
diff --git a/devel/gdb/files/kgdb/i386fbsd-kern.c b/devel/gdb/files/kgdb/i386fbsd-kern.c
index 37e658fcf7f8..6937efea237c 100644
--- a/devel/gdb/files/kgdb/i386fbsd-kern.c
+++ b/devel/gdb/files/kgdb/i386fbsd-kern.c
@@ -478,6 +478,20 @@ _initialize_i386_kgdb_tdep(void)
i386fbsd_pspace_data_cleanup);
#ifdef __i386__
+ /*
+ * FreeBSD/i386 kernels prior to the introduction of AVX
+ * support used a different layout for the PCB. If gdb is
+ * compiled on these systems, these asserts will fail. The
+ * package builders build packages on older systems which are
+ * then run on newer systems. These binaries trip over these
+ * assertions even when debugging user programs and even
+ * though the running kernel is new enough. To cope, disable
+ * the assertion checks unless gdb is built against a new
+ * enough world. Note that this means kgdb is not going to
+ * parse PCBs correctly on FreeBSD/i386 kernels before AVX was
+ * merged.
+ */
+#if __FreeBSD_version >= 1001505
gdb_assert(offsetof(struct pcb, pcb_ebx)
== i386fbsd_pcb_offset[I386_EBX_REGNUM]);
gdb_assert(offsetof(struct pcb, pcb_esp)
@@ -490,6 +504,7 @@ _initialize_i386_kgdb_tdep(void)
== i386fbsd_pcb_offset[I386_EDI_REGNUM]);
gdb_assert(offsetof(struct pcb, pcb_eip)
== i386fbsd_pcb_offset[I386_EIP_REGNUM]);
+#endif
gdb_assert(CODE_SEL == GSEL(GCODE_SEL, SEL_KPL));
gdb_assert(DATA_SEL == GSEL(GDATA_SEL, SEL_KPL));
gdb_assert(PRIV_SEL == GSEL(GPRIV_SEL, SEL_KPL));