Date: Wed, 27 Apr 2016 16:11:53 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r414115 - in head/devel/gdb: . files/kgdb Message-ID: <201604271611.u3RGBr3b097517@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb (src,doc committer) Date: Wed Apr 27 16:11:53 2016 New Revision: 414115 URL: https://svnweb.freebsd.org/changeset/ports/414115 Log: 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 Modified: head/devel/gdb/Makefile head/devel/gdb/files/kgdb/i386fbsd-kern.c Modified: head/devel/gdb/Makefile ============================================================================== --- head/devel/gdb/Makefile Wed Apr 27 16:08:47 2016 (r414114) +++ head/devel/gdb/Makefile Wed Apr 27 16:11:53 2016 (r414115) @@ -3,7 +3,7 @@ PORTNAME= gdb PORTVERSION= 7.11 -#PORTREVISION= +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= GNU Modified: head/devel/gdb/files/kgdb/i386fbsd-kern.c ============================================================================== --- head/devel/gdb/files/kgdb/i386fbsd-kern.c Wed Apr 27 16:08:47 2016 (r414114) +++ head/devel/gdb/files/kgdb/i386fbsd-kern.c Wed Apr 27 16:11:53 2016 (r414115) @@ -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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604271611.u3RGBr3b097517>