Bug 215783

Summary: devel/gdb: Add MIPS support
Product: Ports & Packages Reporter: John Baldwin <jhb>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: luca.pizzamiglio, olivier, sbruno
Priority: --- Flags: luca.pizzamiglio: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
gdb_mips.patch none

Description John Baldwin freebsd_committer freebsd_triage 2017-01-04 23:28:50 UTC
Created attachment 178528 [details]
gdb_mips.patch

This patch includes two upstream commits to add support for FreeBSD/mips user binaries as well as a new backend from my freebsd-7.12-kgdb branch that adds support for debugging FreeBSD/mips kernels to kgdb.

I've tested cross-debugging of process cores and kernel cores on amd64 as well as running a native gdb in qemu for user binaries.

There is still an open issue with gdb not recognizing mips64 core dumps.  I have a pending patch in review to add a workaround to binutils, though the real bug is in the kernel.

I have done my testing from my git branch, and I have only build-tested the port update on amd64. I've cc'd Sean hoping he can use the qemu-user magic to build a gdb package for mips for testing?
Comment 1 luca.pizzamiglio 2017-01-09 14:29:23 UTC
Hi John,

I'm integrating your patch with other modifications that I was preparing to fix other stuff.

I'll prepare a new PR ASAP ready to be committed.

I'm preparing also the qemu magic to build for mips (atm I've only arm)

Is this patch for both mips32 and mips64?
Comment 2 John Baldwin freebsd_committer freebsd_triage 2017-01-09 16:21:46 UTC
(In reply to luca.pizzamiglio from comment #1)
It has been tested for both mips (o32) and mips64 (n64).  It should build fine for n32 as well, but I can't get mipsn32 to work at all in qemu (/sbin/init fails).  The ONLY_FOR_ARCH match in bsd.port.mk uses a very simple substring match, so just "mips" will match all of the mips architectures by my reading (and having "powerpc64" and "powerpc" is redundant as the check for "powerpc" will already match "powerpc64").  It might also be worth inverting the check to just be !aarch64 at this point (I think that's the only architecture not supported now?)

Please include a 'Sponsored by: DARPA / AFRL' line in the commit log for the MIPS bits of the actual commit to the port.
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-01-12 21:40:24 UTC
A commit references this bug:

Author: olivier
Date: Thu Jan 12 21:40:06 UTC 2017
New revision: 431323
URL: https://svnweb.freebsd.org/changeset/ports/431323

Log:
  Add MIPS support and other fixes

  PR:		215938
  - Main PR that merge all
  Submitted by:   luca.pizzamiglio@gmail.com (maintainer)

  PR:		215783
  - Add MIPS support
  Submitted by:   jhb
  Sponsored by:   DARPA / AFRL

  PR:		215868
  - Fix build on powerpc architecture
  Reported by:    Mark Millard

  PR:		212607
  - Add a workaround to mitigate gdb hangs under some circumstances
  with multi-threaded applications
  (thanks to misc-freebsd-bugzilla@talk2dom.com)
  Reported by:    tijl

  PR:		215578
  - Fix build by removing option to use system readline
  Reported by:    rozhuk.im@gmail.com

Changes:
  head/devel/gdb/Makefile
  head/devel/gdb/distinfo
  head/devel/gdb/files/commit-387360daf9
  head/devel/gdb/files/commit-b268007c68
  head/devel/gdb/files/extrapatch-base-readline
  head/devel/gdb/files/extrapatch-kgdb
  head/devel/gdb/files/kgdb/mipsfbsd-kern.c
  head/devel/gdb/files/kgdb/ppcfbsd-kern.c
  head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
  head/devel/gdb/files/patch-gdb-fbsd-nat.c
Comment 4 Olivier Cochard freebsd_committer freebsd_triage 2017-01-12 21:48:03 UTC
Thanks for your improvement: I hope the Sponsored mention in the commit log suit you.
Comment 5 John Baldwin freebsd_committer freebsd_triage 2017-01-12 23:23:21 UTC
Perfect, thanks.