public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] gdbserver improvements for AArch64 SVE support
@ 2022-11-26  2:04 Thiago Jung Bauermann
  2022-11-26  2:04 ` [PATCH v2 1/6] gdbserver: Add asserts in register_size and register_data functions Thiago Jung Bauermann
                   ` (5 more replies)
  0 siblings, 6 replies; 45+ messages in thread
From: Thiago Jung Bauermann @ 2022-11-26  2:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Luis Machado, Thiago Jung Bauermann

Hello,

This is version 2 of the patch series adding support to gdbserver for
inferiors that change the SVE vector length at runtime. This is already
supported by GDB, but not by gdbserver. Version 1 was posted here:

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

The main difference in this version is that it implements Luis' suggestion
of keeping the per-process target description and using per-thread ones
only when necessary (i.e., when the inferior supports SVE).

This simplified the patches significantly (thank you for the suggestion,
Luis!), and they now cause minimal change on non-SVE targets.

To recap, GDB supports different vector lengths by calling
target_ops::thread_architecture, and aarch64_linux_nat_target provides an
implementation of that method.

This patch series' idea is to provide a remote_target::thread_architecture
method so that the same mechanism can be used in the case of remote
debugging. It returns a gdbarch based on the expedited registers seen in
the most recent stop reply.

To arrive at that solution some preparation is necessary. Most patches are
small cleanups or code reorganisation to make review easier. The biggest
change is in patch 4, which adds a per-thread target description to
gdbserver. As mentioned earlier though, only SVE-supporting aarch64-linux
targets will actually use different per-thread tdescs. All other targets
continue using the per-process target description.

Also, contrary to what I mentioned to some people at the GNU Tools
Cauldron, XML target descriptions are not transmitted over the wire. What
happens is:

1. When the inferior thread stops, gdbserver fetches its vector length. If
   it's different from the last time it stopped, gdbserver sets a
   thread-specific tdesc (in aarch64_target::arch_update_tdesc).
2. gdbserver sends the new vector length as “VG” an expedited
   pseudo-register (it was already doing that, this patch series doesn't
   change this part).
3. When GDB receives a stop reply, it gets the vector length from the
   expedited registers and uses it to get a new target description and
   gdbarch, then stores the latter in remote_thread_info->expedited_arch
   (in remote_target::process_stop_reply).
4. When GDB needs to know the thread's gdbarch, it calls the process
   stratum's thread_architecture method. With these patches remote_target
   now provides said method, which returns the gdbarch obtained from the
   last stop reply.

So GDB and gdbserver independently update their own target descriptions
when they notice that the vector length changed.

With this series applied, gdb.arch/aarch64-sve.exp passes all tests on
extended-remote aarch64-linux. Without them, it fails tests after the
testcase changes the vector length.

Tested on native and extended-remote aarch64-linux, x86_64-linux and
armv7l-linux-gnueabihf (the last one on QEMU TCG).

Changes since v1:

- Patch 1: gdbserver: Add asserts in register_size and register_data functions
  - No change.
- Patch 2: gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap
  - Changed to add an “int pid” parameter rather than a “struct thread_info”
    one. Suggested by Luis.
- Patch 3: gdb,gdbserver/aarch64-linux: Allow aarch64_sve_get_vq to return error
  - Dropped, since as Luis mentioned “we will always be able to validate
    supported features when we start/attach to a process”, and also the
    situation it helped with doesn't happen anymore in the new version of
    the code.
- Patch 4: gdbserver/linux-aarch64: Factor out function to get aarch64_features
  - Changed aarch64_get_arch_features to return “struct aarch64_features”
    rather than “gdb::optional<struct aarch64_features>” since we can
    assume that aarch64_sve_get_vq always works.
- Patch 5: gdbserver: Move target description from being per-process to
  being per-thread
  - Squashed into the next patch, since it became much simpler after
    implementing Luis' suggestion of keeping per-process target
    descriptions.
- Patch 6: gdbserver/linux-aarch64: When thread stops, update its target
  description
  - Added “has_sve” bool to linux-aarch64-low's “struct arch_process_info”.
  - Changed aarch64_target::arch_update_tdesc to return early if the given
    thread's has_sve property is false.
  - Changed get_thread_regcache to look for a target description in the
    thread before looking for one in the process.
  - Changed current_target_desc to look for a target description in the
    current_thread before looking for one in the current_process.
- Patch 7: gdb/aarch64: Factor out most of the thread_architecture method
  - Fixed memory leak where aarch64_update_gdbarch was calling
    aarch64_create_target_description instead of aarch64_read_description.
- Patch 8: gdb/aarch64: Detect vector length changes when debugging remotely
  - Changed the title and description to try making them a bit clearer.

Thiago Jung Bauermann (6):
  gdbserver: Add asserts in register_size and register_data functions
  gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap
  gdbserver/linux-aarch64: Factor out function to get aarch64_features
  gdbserver/linux-aarch64: When thread stops, update its target
    description
  gdb/aarch64: Factor out most of the thread_architecture method
  gdb/aarch64: Detect vector length changes when debugging remotely

 gdb/aarch64-linux-nat.c        | 28 +-------------
 gdb/aarch64-tdep.c             | 59 +++++++++++++++++++++++++++++
 gdb/aarch64-tdep.h             |  2 +
 gdb/arch-utils.c               |  9 +++++
 gdb/arch-utils.h               |  5 +++
 gdb/gdbarch-components.py      | 16 ++++++++
 gdb/gdbarch-gen.h              | 11 ++++++
 gdb/gdbarch.c                  | 22 +++++++++++
 gdb/remote.c                   | 42 +++++++++++++++++++++
 gdbserver/gdbthread.h          |  2 +
 gdbserver/linux-aarch64-low.cc | 69 ++++++++++++++++++++++++++++------
 gdbserver/linux-arm-low.cc     |  2 +-
 gdbserver/linux-low.cc         | 36 +++++++++++++-----
 gdbserver/linux-low.h          | 14 ++++---
 gdbserver/linux-ppc-low.cc     |  6 +--
 gdbserver/linux-s390-low.cc    |  2 +-
 gdbserver/netbsd-low.cc        |  4 +-
 gdbserver/netbsd-low.h         |  2 +-
 gdbserver/regcache.cc          | 15 ++++++--
 gdbserver/server.cc            |  2 +-
 gdbserver/target.cc            |  4 +-
 gdbserver/target.h             |  2 +-
 gdbserver/tdesc.cc             |  3 ++
 23 files changed, 289 insertions(+), 68 deletions(-)


base-commit: 31c1130f35e0ef800ea4d92224a72872ffe4a5db

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2022-12-09  2:20 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-26  2:04 [PATCH v2 0/6] gdbserver improvements for AArch64 SVE support Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 1/6] gdbserver: Add asserts in register_size and register_data functions Thiago Jung Bauermann
2022-11-28 11:51   ` Luis Machado
2022-11-29  2:53     ` Thiago Jung Bauermann
2022-11-28 14:48   ` Simon Marchi
2022-11-28 14:53     ` Simon Marchi
2022-11-29  2:52       ` Thiago Jung Bauermann
2022-11-29  2:43     ` Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 2/6] gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap Thiago Jung Bauermann
2022-11-28 11:50   ` Luis Machado
2022-11-28 15:01     ` Simon Marchi
2022-11-29  3:10       ` Thiago Jung Bauermann
2022-11-28 15:07   ` Simon Marchi
2022-11-28 15:20     ` Luis Machado
2022-11-29  3:17     ` Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 3/6] gdbserver/linux-aarch64: Factor out function to get aarch64_features Thiago Jung Bauermann
2022-11-28 11:54   ` Luis Machado
2022-11-29  3:19     ` Thiago Jung Bauermann
2022-11-28 15:12   ` Simon Marchi
2022-11-29  3:26     ` Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 4/6] gdbserver/linux-aarch64: When thread stops, update its target description Thiago Jung Bauermann
2022-11-28 12:06   ` Luis Machado
2022-11-29  3:59     ` Thiago Jung Bauermann
2022-11-28 15:47   ` Simon Marchi
2022-11-28 16:01     ` Luis Machado
2022-11-28 16:07       ` Simon Marchi
2022-11-29  4:30     ` Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 5/6] gdb/aarch64: Factor out most of the thread_architecture method Thiago Jung Bauermann
2022-11-28 12:09   ` Luis Machado
2022-11-29  4:32     ` Thiago Jung Bauermann
2022-11-28 16:09   ` Simon Marchi
2022-11-29  4:33     ` Thiago Jung Bauermann
2022-11-26  2:04 ` [PATCH v2 6/6] gdb/aarch64: Detect vector length changes when debugging remotely Thiago Jung Bauermann
2022-11-28 13:27   ` Luis Machado
2022-12-01  1:15     ` Thiago Jung Bauermann
2022-11-28 16:36   ` Simon Marchi
2022-12-01  3:16     ` Thiago Jung Bauermann
2022-12-01  8:32       ` Luis Machado
2022-12-01 16:16       ` Simon Marchi
2022-11-30  8:43   ` Luis Machado
2022-12-05 22:37     ` Thiago Jung Bauermann
2022-12-07 17:05       ` Luis Machado
2022-12-07 19:25         ` Simon Marchi
2022-12-07 23:01           ` Luis Machado
2022-12-09  2:20             ` Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).