Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Apr 2016 18:48:31 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-branches@freebsd.org
Subject:   svn commit: r414287 - in branches/2016Q2/devel/gdb: . files/kgdb
Message-ID:  <201604291848.u3TImVaE079225@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb (src,doc committer)
Date: Fri Apr 29 18:48:31 2016
New Revision: 414287
URL: https://svnweb.freebsd.org/changeset/ports/414287

Log:
  MFH: r414115
  
  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:	ports-secteam (junovitch)

Modified:
  branches/2016Q2/devel/gdb/Makefile
  branches/2016Q2/devel/gdb/files/kgdb/i386fbsd-kern.c
Directory Properties:
  branches/2016Q2/   (props changed)

Modified: branches/2016Q2/devel/gdb/Makefile
==============================================================================
--- branches/2016Q2/devel/gdb/Makefile	Fri Apr 29 18:24:11 2016	(r414286)
+++ branches/2016Q2/devel/gdb/Makefile	Fri Apr 29 18:48:31 2016	(r414287)
@@ -3,7 +3,7 @@
 
 PORTNAME=	gdb
 PORTVERSION=	7.11
-#PORTREVISION=
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	GNU
 

Modified: branches/2016Q2/devel/gdb/files/kgdb/i386fbsd-kern.c
==============================================================================
--- branches/2016Q2/devel/gdb/files/kgdb/i386fbsd-kern.c	Fri Apr 29 18:24:11 2016	(r414286)
+++ branches/2016Q2/devel/gdb/files/kgdb/i386fbsd-kern.c	Fri Apr 29 18:48:31 2016	(r414287)
@@ -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?201604291848.u3TImVaE079225>