Bug 215783 - devel/gdb: Add MIPS support
Summary: devel/gdb: Add MIPS support
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)
Depends on:
Reported: 2017-01-04 23:28 UTC by John Baldwin
Modified: 2017-01-12 23:23 UTC (History)
3 users (show)

See Also:
luca.pizzamiglio: maintainer-feedback+

gdb_mips.patch (51.01 KB, patch)
2017-01-04 23:28 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 2017-01-04 23:28:50 UTC
Created attachment 178528 [details]

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 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

  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

Comment 4 Olivier Cochard freebsd_committer 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.