Page MenuHomeFreeBSD

devel/gdb: Fixes for kgdb including initial FreeBSD/arm support.
ClosedPublic

Authored by jhb on Jun 25 2018, 11:32 PM.

Details

Summary
  • Improve fallback handling for the read of pcb_size.

    If for some reason kgdb has only the kernel's debug info, a read of pcb_size will simply return 0, resulting in an exception when unwinding the stack of a thread that was on a CPU at the time the dump was created. In this case, fall back to using sizeof(struct pcb).
  • Always supply a value for the PC register on x86.

    A thread's PCB may have been swapped out, and a dummy value ensures that we don't get an exception while enumerating threads in a dump.
  • Mark all 64-bit address bits as valid for aarch64 kernels.

    ARMv8 supports pointer tagging in which case the upper 8 bits of VAs are ignored, but FreeBSD kernels are linked such that they depend on those upper 8 bits being set to 1. GDB was stripping those bits by default causing KVAs to be mapped to invalid addresses.
  • Rework kgdb -w support to only open /dev/mem writable.

    Don't depend on the gdb global 'write_files' option which tries to rewrite the kernel binary on close which can crash. Instead, add an optional '-w' flag to 'target vmcore' which opens the vmcore with O_RDWR instead of O_RDONLY. Change the kgdb '-w' option to set this flag in the nested 'target vmcore' command rather than passing the global '-w' option to gdb.
  • Garbage collect old code for reading dumptid.
  • First cut at FreeBSD/arm kernel support.

    Tested on live kernel on my RPi, but not against a crashdump, and only trapframes from userland, not a nested trap.

Submitted by: markj (1, 2)

Test Plan
  • markj tested (1,2) for a coredump he had where kgdb crashed
  • I tested the aarch64 fix on an aarch64 crashdump supplied by tuexen@.
  • I tested the arm bits via live kgdb on my raspberry pi.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb created this revision.Jun 25 2018, 11:32 PM

I'd like to see this go in too. :)

I would like to see this going in, too.

jhb added a comment.Jul 11 2018, 4:00 PM

Normally @pizzamig is quite responsive on reviews for devel/gdb, so I wonder if he might be on vacation or some such?

linimon retitled this revision from Fixes for kgdb including initial FreeBSD/arm support. to devel/gdb: Fixes for kgdb including initial FreeBSD/arm support..Jul 18 2018, 1:03 PM
kan accepted this revision.Jul 25 2018, 5:12 PM
kan added a subscriber: kan.

.. kgdb parts make sense. Non-kgdb bits are not really affected, so change should not invoke the wrath of real maintainer.

This revision is now accepted and ready to land.Jul 25 2018, 5:12 PM
This revision was automatically updated to reflect the committed changes.