mbox series

[RFC,v4,00/15] gdbserver improvements for AArch64 SVE support

Message ID 20241102025635.586759-1-thiago.bauermann@linaro.org
Headers show
Series gdbserver improvements for AArch64 SVE support | expand

Message

Thiago Jung Bauermann Nov. 2, 2024, 2:56 a.m. UTC
Hello,

This is the fourth try at implementing variable-length register support in
gdbserver and the remote protocol. It corresponds to the talk I gave at
GNU Tools Cauldron 2024:

https://www.youtube.com/watch?v=sghWiqTKBN0&list=PL_GiHdX17Wtye5q4zPVnJc6ec7PdnUNil&index=7

The v3 submission is here:

https://inbox.sourceware.org/gdb-patches/20230130044518.3322695-1-thiago.bauermann@linaro.org/

Thank you all for attending the talk and for the great discussion and
suggestions that followed it. I really appreciate it. This code doesn't
reflect that discussion nor the suggestions though, because I wanted to
post a version of the patches that corresponded to what I presented.

I will address the presentation comments in the next version. Namely:

- Pedro's suggestion of changing the VG register (which gives the size of
  the vector registers) to appear before the variable-length vector
  registers in the internal GDB register numbering, without affecting the
  remote protocol register numbering.

- Simon's suggestion of keeping the fixed-size registers and the
  variable-size registers in the same regcache buffer, making sure that
  the latter are always placed at the end.

- Baris' suggestion of implementing an 'e' packet to request the expedited
  registers from the remote target.

- Luis' suggestion of extending the 'p' packet to fetch a specific list or
  registers.

There are some FIXMEs in this code, which is why one of the reasons this
version is marked as RFC. The other reason is the lack of implementing the
suggestions above.

v4 is a different approach from the previous versions, because the main
point of this series is to allow expressing a vector register's size using
a math expression. Previous versions relied on a different target
description for each register size.

The first 5 patches are cleanups and can be pushed independently, if
approved.  Some of them are about using gdb::array_view<gdb_byte> in more
functions related to unwinding and manipulating registers, so that GDB can
make sure that the buffers being passed around have the correct size.
This helped me gain confidence that variable-sized registers were being
correctly read and stored, but I also think it's a useful cleanup in
general.

Thiago Jung Bauermann (15):
  GDB, gdbserver: Convert regcache_register_size function to method
  GDB: Use gdb::array_view for buffers used in register reading and
    unwinding
  GDB: remote: Print total bytes received in debug message
  GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg
  gdbserver: nat/aarch64: Only check Z registers for extra contents if
    they can have it
  gdbserver: Implement p and P packets
  GDB, gdbserver: Create concept of load-early registers
  GDB: Allow DWARF expression evaluation to use regcache
  GDB tdesc: Add vector type with number of elements given by math
    expression.
  GDB: Add concept of variable-size registers to the regcache
  gdbserver: Add concept of variable-size registers to the regcache
  GDB: aarch64-linux: Load and store VG separately from other SVE
    registers
  GDB, gdbserver: aarch64: Convert SVE feature to use variable-size
    registers
  GDB, gdbserver: aarch64: Use VG instead of VQ
  gdb/testsuite: Add test to exercise multi-threaded AArch64 SVE
    inferiors

 gdb/aarch64-linux-nat.c                       |  53 ++-
 gdb/aarch64-linux-tdep.c                      |  55 ++-
 gdb/aarch64-tdep.c                            | 124 +++---
 gdb/aarch64-tdep.h                            |  21 +-
 gdb/arch/aarch64.c                            |  36 +-
 gdb/arch/aarch64.h                            |  25 +-
 gdb/dwarf2/expr.c                             |  63 ++-
 gdb/dwarf2/expr.h                             |  17 +-
 gdb/dwarf2/frame.c                            |   2 +-
 gdb/dwarf2/loc.c                              |  41 +-
 gdb/dwarf2/loc.h                              |   2 +
 gdb/eval.c                                    |  13 +-
 gdb/features/Makefile                         |   1 +
 gdb/features/aarch64-sve.c                    | 199 +++++----
 gdb/features/aarch64-sve.xml                  | 217 +++++++++
 gdb/features/gdb-target.dtd                   |  17 +-
 gdb/findvar.c                                 |  22 +-
 gdb/frame-unwind.c                            |  18 +-
 gdb/frame-unwind.h                            |   2 +-
 gdb/frame.c                                   |  72 +--
 gdb/frame.h                                   |   8 +-
 gdb/gdbarch-gen.c                             |  32 ++
 gdb/gdbarch-gen.h                             |   9 +
 gdb/gdbarch_components.py                     |  11 +
 gdb/gdbtypes.c                                | 138 ++++--
 gdb/gdbtypes.h                                |   7 +-
 gdb/gnu-v3-abi.c                              |   2 +-
 gdb/i387-tdep.c                               |   4 +-
 gdb/jit.c                                     |   2 +-
 gdb/mips-tdep.c                               |  19 +-
 gdb/nat/aarch64-hw-point.c                    |   2 +-
 gdb/nat/aarch64-scalable-linux-ptrace.c       |  52 +--
 gdb/nat/aarch64-scalable-linux-ptrace.h       |  12 +-
 gdb/process-stratum-target.h                  |   3 +
 gdb/python/py-unwind.c                        |   7 +-
 gdb/record-full.c                             |  21 +-
 gdb/regcache-dump.c                           |   2 +-
 gdb/regcache.c                                | 376 +++++++++++++---
 gdb/regcache.h                                |  61 ++-
 gdb/regformats/regdef.h                       |  35 +-
 gdb/remote.c                                  | 163 +++++--
 gdb/stack.c                                   |   2 +-
 gdb/target-descriptions.c                     | 114 ++++-
 gdb/target-descriptions.h                     |  11 +
 gdb/testsuite/gdb.arch/aarch64-sve-threads.c  | 125 ++++++
 .../gdb.arch/aarch64-sve-threads.exp          |  80 ++++
 gdb/trad-frame.h                              |  10 +-
 gdb/value.c                                   |  16 +-
 gdb/value.h                                   |   3 +
 gdb/xml-tdesc.c                               | 416 +++++++++++++++++-
 gdbserver/Makefile.in                         |   2 +
 gdbserver/ax.cc                               |   2 +-
 gdbserver/config.in                           |   3 +
 gdbserver/configure                           |   6 +
 gdbserver/configure.ac                        |   5 +
 gdbserver/configure.srv                       |   1 +
 gdbserver/linux-aarch64-low.cc                |   6 +-
 gdbserver/linux-aarch64-tdesc.cc              |  17 +-
 gdbserver/locexpr.cc                          | 107 +++++
 gdbserver/locexpr.h                           |  31 ++
 gdbserver/regcache.cc                         | 217 +++++++--
 gdbserver/regcache.h                          |  32 +-
 gdbserver/remote-utils.cc                     |   2 +-
 gdbserver/server.cc                           |  75 ++++
 gdbserver/tdesc.cc                            | 110 ++++-
 gdbserver/tdesc.h                             |   4 +-
 gdbserver/tracepoint.cc                       |   4 +-
 gdbsupport/common-regcache.h                  |  19 +-
 gdbsupport/tdesc.cc                           | 143 +++++-
 gdbsupport/tdesc.h                            |  60 ++-
 70 files changed, 3022 insertions(+), 567 deletions(-)
 create mode 100644 gdb/features/aarch64-sve.xml
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-sve-threads.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-sve-threads.exp
 create mode 100644 gdbserver/locexpr.cc
 create mode 100644 gdbserver/locexpr.h