[PATCHv5,00/11] x86/Linux Target Description Changes

Message ID cover.1714143669.git.aburgess@redhat.com
Headers
Series x86/Linux Target Description Changes |

Message

Andrew Burgess April 26, 2024, 3:01 p.m. UTC
  In v5:

  - Felix pointed out that building gdbserver with the '-m32' flag on
    an x86-64 host would fail.  This is fixed in V5 with the addition
    of patch #4.  This patch moves the have_ptrace_getfpxregs global
    into the gdb/nat/ directory and fixes the includes so that the
    the declaration is seen where needed,

  - I've rebased onto a slightly later commit.

In v4:

  - I tried merging V3, but it turned out I broke pretty much
    everything that wasn't x86 based when configured with
    --enable-targets=all,

  - The problem was a failure to correctly split the shared code
    between the gdb/arch/ and gdb/nat/ directories, as a consequence,
    code which is needed on a non x86 based host to support x86 based
    targets wasn't available to the compilation, and the build failed,

  - In V4 I've gone through every patch and resplit the code in a way
    which I now believe is correct, I've done the following tests:

    + On a non x86 host I've built GDB to support only the current
    host as a target, to support all targets, and to support x86-64
    and i386 linux targets,

    + On an i386 virtual machine I built GDB only for the host as a
    target, and for all targets.  I regression tested the all targets
    build for unix, native-gdbserver, and native-extended-gdbserver,

    + On an x86-64 machine I've built GDB for only the current host as
    a target, and for all targets.  I regression tested the all targets
    build for unix, native-gdbserver, and native-extended-gdbserver.

  - Only patches 6, 8, and 10 require significant review.  All of the
    other patches are pretty trivial (though reviews always welcome).

  - I think there's more improvements that can be made to the x86
    target description creation/lookup/caching.  This series only
    changes the Linux lookup, and we still cache i386/amd64/x32
    separately.

    In the future I think we can merge all x86 target description
    caching into a single data structure, this would be for all OS
    variants and all ABI variants.

    Though making that "grand unification" will certainly require some
    of the code in this series to change, I think the bulk of it will
    remain, and trying to do everything in one series is just going to
    result in an even larger series.  I'd prefer to get these first
    patches merged, then come back to build on this work once this is
    merged and we know there's no problems with it.

In v3:

  - Rebased.  Nasty merge conflict with 4bb20a6244b7091 which I think
    I've resolved, but am unable to test.  Reposting so the author of
    that other commit can validate.

  - Initial testing looks good.  Full tests are still running.

In v2:

  - Rebase to current upstream/master, no merge conflicts,

  - Retested.

---

Andrew Burgess (11):
  gdbserver/ipa/x86: remove unneeded declarations
  gdbserver: convert have_ptrace_getregset to a tribool
  gdb/x86: move reading of cs and ds state into gdb/nat directory
  gdb/x86: move have_ptrace_getfpxregs global into gdb/nat directory
  gdbserver/x86: move no-xml code earlier in x86_linux_read_description
  gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition
  gdb/gdbserver: share some code relating to target description creation
  gdb/arch: assert that X86_XSTATE_MPX is not set for x32
  gdbserver: update target description creation for x86/linux
  gdb: move xcr0 == 0 check into i386_linux_core_read_description
  gdb/gdbserver: share x86/linux tdesc caching

 gdb/Makefile.in                               |   9 +-
 gdb/amd64-linux-tdep.c                        |  32 +--
 gdb/amd64-linux-tdep.h                        |   6 -
 gdb/arch/amd64-linux-tdesc.c                  |  61 +++++
 gdb/arch/amd64-linux-tdesc.h                  |  30 +++
 gdb/arch/amd64.c                              |   8 +-
 gdb/arch/i386-linux-tdesc.c                   |  51 ++++
 .../i386-linux-tdesc.h}                       |  17 +-
 gdb/arch/x86-linux-tdesc-features.c           | 247 ++++++++++++++++++
 gdb/arch/x86-linux-tdesc-features.h           |  62 +++++
 gdb/arch/x86-linux-tdesc.h                    |  37 +++
 gdb/configure.nat                             |   8 +-
 gdb/configure.tgt                             |  11 +-
 gdb/i386-linux-nat.c                          |  18 +-
 gdb/i386-linux-tdep.c                         |  42 +--
 gdb/i386-linux-tdep.h                         |  23 --
 gdb/nat/x86-linux-tdesc.c                     | 124 +++++++++
 gdb/nat/x86-linux-tdesc.h                     |  60 +++++
 gdb/nat/x86-linux.c                           |  56 ++++
 gdb/nat/x86-linux.h                           |  44 ++++
 gdb/x86-linux-nat.c                           | 126 +--------
 gdbserver/configure.srv                       |  11 +
 gdbserver/linux-amd64-ipa.cc                  |  50 +---
 gdbserver/linux-arm-low.cc                    |   6 +-
 gdbserver/linux-i386-ipa.cc                   |  26 +-
 gdbserver/linux-low.cc                        |   2 +-
 gdbserver/linux-low.h                         |   2 +-
 gdbserver/linux-x86-low.cc                    | 201 +++++---------
 gdbserver/linux-x86-tdesc.cc                  | 142 +---------
 gdbserver/linux-x86-tdesc.h                   |  56 ----
 gdbsupport/x86-xstate.h                       |  20 ++
 31 files changed, 959 insertions(+), 629 deletions(-)
 create mode 100644 gdb/arch/amd64-linux-tdesc.c
 create mode 100644 gdb/arch/amd64-linux-tdesc.h
 create mode 100644 gdb/arch/i386-linux-tdesc.c
 rename gdb/{i386-linux-nat.h => arch/i386-linux-tdesc.h} (64%)
 create mode 100644 gdb/arch/x86-linux-tdesc-features.c
 create mode 100644 gdb/arch/x86-linux-tdesc-features.h
 create mode 100644 gdb/arch/x86-linux-tdesc.h
 create mode 100644 gdb/nat/x86-linux-tdesc.c
 create mode 100644 gdb/nat/x86-linux-tdesc.h
 delete mode 100644 gdbserver/linux-x86-tdesc.h


base-commit: 39f0ac383169d7ef8b3169e483ae95dd185e41bd