mbox series

[v3,0/5] Add stub to handle Xfer:siginfo:read query

Message ID 20240309030901.1726211-1-gustavo.romero@linaro.org
Headers show
Series Add stub to handle Xfer:siginfo:read query | expand

Message

Gustavo Romero March 9, 2024, 3:08 a.m. UTC
Xfer:siginfo:read query is received, usually, when GDB catches a signal
and needs additional info about it, like the si_code and the si_addr, so
GDB can show the user interesting info about the signal. This query can
also be received when an user explicitly asks for more information via
printing GBD's special purpose variable '$_siginfo'.

This series adds the stub to handle Xfer:siginfo:read queries.

To achieve this, it is first necessary to stash the target-specific
siginfo in the gdbstub server state struct when handling a signal, so it
requires modifying the gdb_handlesig function to accept the target's
siginfo struct and its length.

Later, when replying to a Xfer:siginfo:read query (i.e., after a
signal is caught), the query handler utilizes the stashed siginfo to
form the packet for replying to the query.

Finally, a test is added to check if the stub correctly responds to the
query when a simple binary causes a SIGSEGV. Since the si_addr must be
available in the case of a SIGSEGV, the value of si_addr is checked
against the expected faulting address, corresponding to the dereferenced
pointer value in the binary.

v1:
https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg00423.html

v2:
https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg01858.html


Cheers,
Gustavo

Gustavo Romero (5):
  gdbstub: Rename back gdb_handlesig
  linux-user: Move tswap_siginfo out of target code
  gdbstub: Save target's siginfo
  gdbstub: Add Xfer:siginfo:read stub
  tests/tcg: Add multiarch test for Xfer:siginfo:read stub

 bsd-user/main.c                               |  2 +-
 bsd-user/signal.c                             |  5 +-
 gdbstub/gdbstub.c                             |  8 ++++
 gdbstub/internals.h                           |  1 +
 gdbstub/user.c                                | 46 +++++++++++++++++--
 include/gdbstub/user.h                        | 19 +++-----
 linux-user/aarch64/signal.c                   |  2 +-
 linux-user/alpha/signal.c                     |  2 +-
 linux-user/arm/signal.c                       |  2 +-
 linux-user/hexagon/signal.c                   |  2 +-
 linux-user/hppa/signal.c                      |  2 +-
 linux-user/i386/signal.c                      |  6 +--
 linux-user/loongarch64/signal.c               |  2 +-
 linux-user/m68k/signal.c                      |  4 +-
 linux-user/main.c                             |  2 +-
 linux-user/microblaze/signal.c                |  2 +-
 linux-user/mips/signal.c                      |  4 +-
 linux-user/nios2/signal.c                     |  2 +-
 linux-user/openrisc/signal.c                  |  2 +-
 linux-user/ppc/signal.c                       |  4 +-
 linux-user/riscv/signal.c                     |  2 +-
 linux-user/s390x/signal.c                     |  2 +-
 linux-user/sh4/signal.c                       |  2 +-
 linux-user/signal-common.h                    |  2 -
 linux-user/signal.c                           | 15 ++++--
 linux-user/sparc/signal.c                     |  2 +-
 linux-user/xtensa/signal.c                    |  2 +-
 tests/tcg/multiarch/Makefile.target           | 10 +++-
 .../gdbstub/test-qxfer-siginfo-read.py        | 26 +++++++++++
 tests/tcg/multiarch/segfault.c                | 14 ++++++
 30 files changed, 147 insertions(+), 49 deletions(-)
 create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py
 create mode 100644 tests/tcg/multiarch/segfault.c

Comments

Alex Bennée March 11, 2024, 3:45 p.m. UTC | #1
Gustavo Romero <gustavo.romero@linaro.org> writes:

> Xfer:siginfo:read query is received, usually, when GDB catches a signal
> and needs additional info about it, like the si_code and the si_addr, so
> GDB can show the user interesting info about the signal. This query can
> also be received when an user explicitly asks for more information via
> printing GBD's special purpose variable '$_siginfo'.

Queued to gdbstub/next, thanks.