Bug 206044

Summary: devel/gdb: Misc KGDB fixes
Product: Ports & Packages Reporter: John Baldwin <jhb>
Component: Individual Port(s)Assignee: John Baldwin <jhb>
Status: Closed FIXED    
Severity: Affects Only Me CC: feld, koobs, luca.pizzamiglio, ports-secteam
Priority: --- Keywords: feature, patch
Version: LatestFlags: koobs: maintainer-feedback+
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
gdb_port_kgdb2.patch luca.pizzamiglio: maintainer-approval+

Description John Baldwin freebsd_committer freebsd_triage 2016-01-08 19:49:09 UTC
Created attachment 165277 [details]
gdb_port_kgdb2.patch

The enclosed patches fix three separate issues in kgdb and bump the portrevision (since KGDB is enabled by default):

- kgdb -n now permits any valid string to be used instead of only permitting
  numbers.  In particular, this allows 'kgdb -n last' to be used to open the
  most recent vmcore.
- kgdb will now try to determine the list of kernel modules even if the kernel
  binary does not include debug symbols.  This works fine in kernels that have
  the changes in r290728.
- Mark trapframes as "signal trampoline frames".  GDB assumes that "normal"
  frames will never call into a NULL PC.  Instead, it assumes that calling a
  NULL PC will result in an exception (and thus a signal being posted resulting
  in a signal frame).  A trap for a NULL function pointer would thus stop
  unwinding once it hit the frame with a NULL PC.  Marking the trapframes as
  a signal frame tells GDB it is ok to unwind past a NULL PC.  One side
  effect is that frames in the asm handler now display as "signal handler called"
  instead of the raw line in assembly.  Perhaps at some point it would be
  nice to mark these up the way ddb does with the trap number, etc. but GDB's
  stack code doesn't support custom frame printers.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-09 18:38:50 UTC
@John, would you like to assign yourself this issue for commit? I'd be happy to approve given relevant QA (poudriere, test suite if gdb has it, etc)
Comment 2 John Baldwin freebsd_committer freebsd_triage 2016-01-09 23:40:20 UTC
Happy to commit it once Luca has reviewed it.  There is no test suite for the kgdb bits of gdb, though I did test these changes by debugging a crashdump from a NULL function pointer panic (and had to fix kgdb to debug it).  The other two patches I had tested previously as well (running kgdb against a kernel without debug symbols and checking 'info sharedlibrary' and using 'kgdb -n last').
Comment 3 luca.pizzamiglio 2016-01-11 14:02:03 UTC
Comment on attachment 165277 [details]
gdb_port_kgdb2.patch

Patch approved!
Thanks for the continuing support!
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-11 16:36:43 UTC
@John, this is good to proceed pending QA (portlint, poudriere) confirmation
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-01-11 17:36:35 UTC
A commit references this bug:

Author: jhb
Date: Mon Jan 11 17:36:14 UTC 2016
New revision: 405792
URL: https://svnweb.freebsd.org/changeset/ports/405792

Log:
  Various fixes to kgdb.  Port revision bumped since kgdb is enabled by
  default.
  - kgdb -n now permits any valid string to be used instead of only
    permitting numbers.  In particular, this allows 'kgdb -n last' to be
    used to open the most recent vmcore.
  - kgdb will now try to determine the list of kernel modules even if the
    kernel binary does not include debug symbols.  This works fine in kernels
    that have the changes in r290728.
  - Mark trapframes as "signal trampoline frames".  GDB assumes that "normal"
    frames will never call into a NULL PC.  Instead, it assumes that calling a
    NULL PC will result in an exception (and thus a signal being posted
    resulting in a signal frame).  A trap for a NULL function pointer would
    thus stop unwinding once it hit the frame with a NULL PC.  Marking the
    trapframes as a signal frame tells GDB it is ok to unwind past a NULL PC.
    One side effect is that frames in the asm handler now display as "signal
    handler called" instead of the raw line in assembly.  Perhaps at some
    point it would be nice to mark these up the way ddb does with the trap
    number, etc. but GDB's stack code doesn't support custom frame printers.

  PR:		206044
  Reviewed by:	luca.pizzamiglio@gmail.com (maintainer)
  Approved by:	koobs

Changes:
  head/devel/gdb/Makefile
  head/devel/gdb/files/kgdb/amd64fbsd-kern.c
  head/devel/gdb/files/kgdb/fbsd-kld.c
  head/devel/gdb/files/kgdb/i386fbsd-kern.c
  head/devel/gdb/files/kgdb/kgdb-main.c
  head/devel/gdb/files/kgdb/ppcfbsd-kern.c
  head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
Comment 6 Andriy Gapon freebsd_committer freebsd_triage 2016-01-21 12:22:56 UTC
This bug can be closed now?
Comment 7 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-21 12:44:36 UTC
Pending MFH
Comment 8 John Baldwin freebsd_committer freebsd_triage 2016-04-25 17:39:08 UTC
7.11 is already in the most recent quarterly and contains these changes.