Bug 197501 - devel/gdb: Add XSAVE support, plus i386 sigtramp fix and i386 on amd64 fix
Summary: devel/gdb: Add XSAVE support, plus i386 sigtramp fix and i386 on amd64 fix
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: John Baldwin
URL:
Keywords: needs-qa, patch
Depends on:
Blocks:
 
Reported: 2015-02-09 23:00 UTC by John Baldwin
Modified: 2015-02-18 20:06 UTC (History)
1 user (show)

See Also:
luca.pizzamiglio: maintainer-feedback+


Attachments
gdb_port_xsave.patch (59.79 KB, patch)
2015-02-09 23:00 UTC, John Baldwin
koobs: maintainer-approval? (luca.pizzamiglio)
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 2015-02-09 23:00:27 UTC
Created attachment 152824 [details]
gdb_port_xsave.patch

This patch to the port adds support for XSAVE on amd64 and i386 using the recently added PTRACE_GET/SETXSTATE in HEAD.  (I will soon merge those changes to stable/10 as well.)

It also adds kern.proc.sigtramp usage on i386 fixing unwinding across signal frames for i386 binaries after the shared page signal code changes.

As part of the XSAVE changes it also fixes the amd64 FreeBSD ABI to return an i386 target description when debugging a 32-bit process.  This allows XSAVE debugging to work for an i386 binary on amd64 (though threads cannot be debugged still).

The threads patches have been reworked to pull threads-related patches out of the main port patches and into a single patch that is applied when the THREAD option is enabled.  In part this is to make it easier to update the port in the hopeful case that other patches (like the signal trampoline fixes and XSAVE) can be upstreamed.

One additional change to the threads patches to allow them to work with XSAVE is that the fbsd-threads target no longer uses ptrace to fetch registers for LWPs directly.  Instead, the x86 nat.c files are updated to pass the lwp id to ptrace if the inferior has an lwp id instead of always passing the PIDs.  This means that for LWP-backed threads, the fbsd-threads target now passes all register requests down to the native method.  The supply/collect regset stubs are now only needed to support userland threads for libkse.
Comment 1 John Baldwin freebsd_committer freebsd_triage 2015-02-09 23:51:00 UTC
(Not sure why the auto-assign didn't kick in here)
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-02-11 13:38:38 UTC
Submitter is committer, re-assign.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2015-02-11 13:38:55 UTC
Comment on attachment 152824 [details]
gdb_port_xsave.patch

Patch pending approval
Comment 4 John Baldwin freebsd_committer freebsd_triage 2015-02-11 13:42:44 UTC
I will also bump PORTREVISION before committing, just didn't include that in case there was a race with another patch.
Comment 5 luca.pizzamiglio 2015-02-18 09:23:17 UTC
I tested the patch and it works correctly in several scenario.
please, commit it bumping PORTREVISION.

thanks
Comment 6 commit-hook freebsd_committer freebsd_triage 2015-02-18 19:24:58 UTC
A commit references this bug:

Author: jhb
Date: Wed Feb 18 19:24:17 UTC 2015
New revision: 379311
URL: https://svnweb.freebsd.org/changeset/ports/379311

Log:
  - Add support for XSAVE on amd64 and i386 using the recently added
    PT_GETXSTATE_INFO and XSTATE core dump sections.
  - Use kern.proc.sigtramp on i386 to fix unwinding across signal
    frames.
  - Change the amd64 FreeBSD ABI to return an i386 target description
    when debugging a 32-bit process.  This allows XSAVE debugging to
    work for an i386 binary on amd64.
  - Rework thread patches to pull all threads-related patches out of
    the main port patches and into a single optional patch.
  - Adjust the thread patches so that fbsd-threads.c passes register
    requests for LWPs down to the native target instead of calling
    ptrace directly.  This allows XSAVE to work with threads without
    any other changes.  The x86 nat.c files now pass LWP IDs to
    ptrace register operations (other platforms already did this).
    The supply/collect regset stubs are now only needed to support
    userland threads for libkse.

  PR:		197501
  Approved by:	maintainer, bdrewery

Changes:
  head/devel/gdb/Makefile
  head/devel/gdb/files/extrapatch-gdb-Makefile.in
  head/devel/gdb/files/extrapatch-gdb-configure.tgt
  head/devel/gdb/files/extrapatch-threads
  head/devel/gdb/files/fbsd-threads.c
  head/devel/gdb/files/patch-gdb-amd64fbsd-nat.c
  head/devel/gdb/files/patch-gdb-amd64fbsd-tdep.c
  head/devel/gdb/files/patch-gdb-i386bsd-nat.c
  head/devel/gdb/files/patch-gdb-i386bsd-nat.h
  head/devel/gdb/files/patch-gdb-i386fbsd-nat.c
  head/devel/gdb/files/patch-gdb-i386fbsd-tdep.c
  head/devel/gdb/files/patch-xsave