[00/12] Initial support for ROCm platform (AMDGPU) debugging

Message ID 20221206135729.3937767-1-simon.marchi@efficios.com
Headers
Series Initial support for ROCm platform (AMDGPU) debugging |

Message

Simon Marchi Dec. 6, 2022, 1:57 p.m. UTC
  This patch series adds initial support for debugging programs offloaded
to AMD GPUs using the ROCm platform.

Patches 1 to 11 are preparatory patches, and patch 12 is the big one.
We included in that patch only what we consider to be the bare minimum
for a cohesive first step, something that can be run and tested.  See
the commit message of patch 12 for more details.

At the end of this series, it is possible to hit breakpoints in GPU code
and resume execution until the end of the program.  Notably, GDB is not
able to compute the backtrace, which is of course an important piece to
do any real debugging.  Supporting this will require GDB to support some
extensions to DWARF, which is a big piece in itself.  This part, as well
as other features, will come as future patches.

Patch 12 also contains documentation changes.  This series was tested on
Ubuntu 22.04, and no regressions appear for x86-64 / Linux debugging
when and the AMDGPU / ROCm platform support is compiled in.
Built-tested with --enable-targets=all.

Porting GDB to the ROCm platform brought up many challenges and has a
few interesting differences, compared to a "standard" CPU port.  We did
a presentation at the 2022 Cauldron, in Prague, that explains some of
them:

  https://www.youtube.com/watch?v=X1iZ_Ta7jOo

Lancelot SIX (1):
  gdb: add supports_arch_info callback to gdbarch_register

Pedro Alves (1):
  gdb: make install_breakpoint return a non-owning reference

Simon Marchi (10):
  gdbsupport: add type definitions for pid, lwp and tid
  gdb: add inferior_pre_detach observable
  gdb: make gdbarch_alloc take ownership of the tdep
  gdb: add gdbarch_up
  gdbsupport: move libxxhash configure check to gdbsupport
  gdbsupport: move fast_hash to gdbsupport/common-utils.h
  gdbsupport: add gdb::string_view_hash
  gdb/solib-svr4: don't disable probes interface if probe not found
  gdb: make gdb_printing_disassembler::stream public
  gdb: initial support for ROCm platform (AMDGPU) debugging

 gdb/Makefile.in                   |   17 +-
 gdb/NEWS                          |    7 +
 gdb/README                        |   15 +
 gdb/aarch64-tdep.c                |    5 +-
 gdb/alpha-tdep.c                  |    7 +-
 gdb/amd-dbgapi-target.c           | 1966 +++++++++++++++
 gdb/amd-dbgapi-target.h           |  116 +
 gdb/amdgpu-tdep.c                 | 1367 ++++++++++
 gdb/amdgpu-tdep.h                 |   93 +
 gdb/arc-tdep.c                    |    6 +-
 gdb/arch-utils.c                  |   11 +-
 gdb/arm-tdep.c                    |    6 +-
 gdb/avr-tdep.c                    |    6 +-
 gdb/bfin-tdep.c                   |    6 +-
 gdb/bpf-tdep.c                    |    4 +-
 gdb/breakpoint.c                  |    4 +-
 gdb/breakpoint.h                  |    8 +-
 gdb/configure                     | 3863 +++++++++++++++--------------
 gdb/configure.ac                  |   75 +-
 gdb/configure.tgt                 |   23 +-
 gdb/cris-tdep.c                   |    6 +-
 gdb/csky-tdep.c                   |    7 +-
 gdb/disasm.h                      |    4 +-
 gdb/doc/gdb.texinfo               |  758 ++++++
 gdb/frv-tdep.c                    |   15 +-
 gdb/ft32-tdep.c                   |    6 +-
 gdb/gdbarch.c                     |    6 +-
 gdb/gdbarch.h                     |   17 +-
 gdb/hppa-tdep.c                   |    7 +-
 gdb/i386-tdep.c                   |    7 +-
 gdb/ia64-tdep.c                   |    7 +-
 gdb/lm32-tdep.c                   |    6 +-
 gdb/loongarch-tdep.c              |    6 +-
 gdb/m32c-tdep.c                   |    5 +-
 gdb/m32r-tdep.c                   |    6 +-
 gdb/m68hc11-tdep.c                |    7 +-
 gdb/m68k-tdep.c                   |    7 +-
 gdb/mep-tdep.c                    |    7 +-
 gdb/microblaze-tdep.c             |    5 +-
 gdb/mips-tdep.c                   |    7 +-
 gdb/mn10300-tdep.c                |    6 +-
 gdb/moxie-tdep.c                  |    6 +-
 gdb/msp430-tdep.c                 |    7 +-
 gdb/nds32-tdep.c                  |    8 +-
 gdb/nios2-tdep.c                  |    6 +-
 gdb/observable.c                  |    1 +
 gdb/observable.h                  |    3 +
 gdb/or1k-tdep.c                   |    7 +-
 gdb/regcache.c                    |    3 +-
 gdb/riscv-tdep.c                  |    7 +-
 gdb/rl78-tdep.c                   |    7 +-
 gdb/rs6000-tdep.c                 |    8 +-
 gdb/rx-tdep.c                     |    7 +-
 gdb/s12z-tdep.c                   |    4 +-
 gdb/s390-tdep.c                   |   13 +-
 gdb/s390-tdep.h                   |    2 +
 gdb/sh-tdep.c                     |    6 +-
 gdb/solib-rocm.c                  |  679 +++++
 gdb/solib-svr4.c                  |   15 +-
 gdb/sparc-tdep.c                  |    6 +-
 gdb/symtab.c                      |    2 +-
 gdb/target.c                      |    2 +
 gdb/testsuite/gdb.rocm/simple.cpp |   48 +
 gdb/testsuite/gdb.rocm/simple.exp |   52 +
 gdb/testsuite/lib/future.exp      |   38 +
 gdb/testsuite/lib/gdb.exp         |    7 +
 gdb/testsuite/lib/rocm.exp        |   94 +
 gdb/tic6x-tdep.c                  |    6 +-
 gdb/utils.h                       |   19 -
 gdb/v850-tdep.c                   |    7 +-
 gdb/xtensa-config.c               |    4 +-
 gdb/xtensa-tdep.c                 |   10 +-
 gdb/z80-tdep.c                    |    6 +-
 gdbserver/config.in               |    3 +
 gdbserver/configure               |  514 ++++
 gdbsupport/Makefile.in            |    3 +
 gdbsupport/common-utils.h         |   38 +
 gdbsupport/common.m4              |   24 +
 gdbsupport/config.in              |    3 +
 gdbsupport/configure              |  514 ++++
 gdbsupport/ptid.h                 |   18 +-
 81 files changed, 8644 insertions(+), 2070 deletions(-)
 create mode 100644 gdb/amd-dbgapi-target.c
 create mode 100644 gdb/amd-dbgapi-target.h
 create mode 100644 gdb/amdgpu-tdep.c
 create mode 100644 gdb/amdgpu-tdep.h
 create mode 100644 gdb/solib-rocm.c
 create mode 100644 gdb/testsuite/gdb.rocm/simple.cpp
 create mode 100644 gdb/testsuite/gdb.rocm/simple.exp
 create mode 100644 gdb/testsuite/lib/rocm.exp
  

Comments

Simon Marchi Jan. 5, 2023, 7:41 p.m. UTC | #1
On 12/6/22 08:57, Simon Marchi via Gdb-patches wrote:
> This patch series adds initial support for debugging programs offloaded
> to AMD GPUs using the ROCm platform.
> 
> Patches 1 to 11 are preparatory patches, and patch 12 is the big one.
> We included in that patch only what we consider to be the bare minimum
> for a cohesive first step, something that can be run and tested.  See
> the commit message of patch 12 for more details.
> 
> At the end of this series, it is possible to hit breakpoints in GPU code
> and resume execution until the end of the program.  Notably, GDB is not
> able to compute the backtrace, which is of course an important piece to
> do any real debugging.  Supporting this will require GDB to support some
> extensions to DWARF, which is a big piece in itself.  This part, as well
> as other features, will come as future patches.
> 
> Patch 12 also contains documentation changes.  This series was tested on
> Ubuntu 22.04, and no regressions appear for x86-64 / Linux debugging
> when and the AMDGPU / ROCm platform support is compiled in.
> Built-tested with --enable-targets=all.
> 
> Porting GDB to the ROCm platform brought up many challenges and has a
> few interesting differences, compared to a "standard" CPU port.  We did
> a presentation at the 2022 Cauldron, in Prague, that explains some of
> them:
> 
>   https://www.youtube.com/watch?v=X1iZ_Ta7jOo

FYI, I pushed patches 5, 7, 8 and 9, since they seemed like good
changes, independently from this series (and they were LGTM'ed by
Andrew).

Simon