Bug 209061 - devel/gdb: Fix gdb/i386 built on older kernels
Summary: devel/gdb: Fix gdb/i386 built on older kernels
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-26 02:48 UTC by John Baldwin
Modified: 2016-04-29 18:50 UTC (History)
2 users (show)

See Also:
luca.pizzamiglio: maintainer-feedback+


Attachments
kgdb_i386.patch (1.64 KB, patch)
2016-04-26 02:48 UTC, John Baldwin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Baldwin freebsd_committer freebsd_triage 2016-04-26 02:48:43 UTC
Created attachment 169704 [details]
kgdb_i386.patch

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 against an AVX kernel should work fine.
Comment 1 luca.pizzamiglio 2016-04-27 09:20:25 UTC
Comment on attachment 169704 [details]
kgdb_i386.patch

The patch provided works perfectly and all my tests passed.
Patch approved.
Comment 2 commit-hook freebsd_committer 2016-04-27 16:12:26 UTC
A commit references this bug:

Author: jhb
Date: Wed Apr 27 16:11:53 UTC 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

Changes:
  head/devel/gdb/Makefile
  head/devel/gdb/files/kgdb/i386fbsd-kern.c
Comment 3 commit-hook freebsd_committer 2016-04-29 18:49:32 UTC
A commit references this bug:

Author: jhb
Date: Fri Apr 29 18:48:32 UTC 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)

Changes:
_U  branches/2016Q2/
  branches/2016Q2/devel/gdb/Makefile
  branches/2016Q2/devel/gdb/files/kgdb/i386fbsd-kern.c