From owner-svn-ports-head@freebsd.org Wed Apr 27 16:11:54 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC898B1E970; Wed, 27 Apr 2016 16:11:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6DE0D1B96; Wed, 27 Apr 2016 16:11:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3RGBrBj097519; Wed, 27 Apr 2016 16:11:53 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3RGBr3b097517; Wed, 27 Apr 2016 16:11:53 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201604271611.u3RGBr3b097517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 27 Apr 2016 16:11:53 +0000 (UTC) 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 X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2016 16:11:54 -0000 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));