From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id BF4393858D28 for ; Thu, 5 Jan 2023 20:02:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF4393858D28 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 305K2ds2009494 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 15:02:43 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 305K2ds2009494 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1672948963; bh=TTycF6Z/OSYCVk3+12KK6tjRA7TFU1DlSyKoxn8fMGU=; h=From:To:Cc:Subject:Date:From; b=of3BRUsLbwlyuVBwNMdUpvcUjgyOAi5SYI4StXgPISvGzAUxyiRlcAu4OeX4qUBJ9 SwPcxgHb1Eo7v6x0Osv/r5Jcyxkc1zX9+dYyIucFjZs3V3QEuC8DN/GGJ1CRQT2Vsl ux8a2A66blZapcxe8uI9js8CBSWaH/OQ9S0CcxcE= Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AADB01E112; Thu, 5 Jan 2023 15:02:38 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 0/8] Initial support for ROCm platform (AMD GPU) debugging Date: Thu, 5 Jan 2023 15:02:29 -0500 Message-Id: <20230105200237.987771-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Jan 2023 20:02:39 +0000 X-Spam-Status: No, score=-3183.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is the v2 of: https://inbox.sourceware.org/gdb-patches/20221206135729.3937767-1-simon.marchi@efficios.com/ I pushed patches 5, 7, 8 and 9, since I considered them good chances even outside of this series. Most other preparatory patches have been reviewed and LGTM'ed by Andrew Burgess, but they are not really useful on their own, so they are still in this series. There are no changes in them, except a typo fix in patch 3. The only preparatory patch which was not reviewed is "gdb/solib-svr4: don't disable probes interface if probe not found". The only changes in the last patch are in the doc. I reduced the size and scope of the documentation drastically. There was a lot of information that was only tangentially relevant to GDB, about the behavior of the rest of the ROCm platform. We agreed that this kind of information is not relevant for the upstream GDB project (it can still continue to exist in the downstream ROCm GDB documentation). So I removed anything that was not documenting concrete use cases of GDB itself. Other than that, the last patch didn't change since v1. Here is the original cover letter (with patch numbers updated): This patch series adds initial support for debugging programs offloaded to AMD GPUs using the ROCm platform. Patches 1 to 7 are preparatory patches, and patch 8 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 8 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 8 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 (6): gdbsupport: add type definitions for pid, lwp and tid gdb: add inferior_pre_detach observable gdb: add gdbarch_up 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/amd-dbgapi-target.c | 1966 +++++++++++++++++++++++++++++ gdb/amd-dbgapi-target.h | 116 ++ gdb/amdgpu-tdep.c | 1367 ++++++++++++++++++++ gdb/amdgpu-tdep.h | 93 ++ gdb/arch-utils.c | 9 +- gdb/breakpoint.c | 4 +- gdb/breakpoint.h | 8 +- gdb/configure | 425 +++++-- gdb/configure.ac | 52 + gdb/configure.tgt | 23 +- gdb/disasm.h | 4 +- gdb/doc/gdb.texinfo | 291 +++++ gdb/gdbarch.h | 12 +- gdb/observable.c | 1 + gdb/observable.h | 3 + gdb/regcache.c | 3 +- gdb/solib-rocm.c | 679 ++++++++++ gdb/solib-svr4.c | 15 +- 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 ++ gdbsupport/ptid.h | 18 +- 28 files changed, 5210 insertions(+), 159 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 base-commit: 1a8605a8c79b0c4ebc71f5691e36a1338d407837 -- 2.39.0