From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Ue7QLKNVdGkFXhIAWB0awg (envelope-from ) for ; Sat, 24 Jan 2026 00:16:19 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=Pl1ufd2C; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B271B1E0AD; Sat, 24 Jan 2026 00:16:19 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E29891E089 for ; Sat, 24 Jan 2026 00:16:18 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 587094BCA43C for ; Sat, 24 Jan 2026 05:16:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 587094BCA43C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=Pl1ufd2C Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 95A6C4BCA43A for ; Sat, 24 Jan 2026 05:15:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95A6C4BCA43A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 95A6C4BCA43A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769231729; cv=none; b=uWAR1y/0U0m+g6vxDmBNI1JiXOUKeaND/rFiPBCKprWTvVlaXR5nMX50kkBXHAGUMP+U47bHicTFwv398/8Youx5dSezfauKkDB5m0A2ecTaTQsUnfAYR5HkQTjQ1sfLxRTHkqI+/yE8DUwm6UMfUHRImrGE1bdpusxJqEOM9oM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769231729; c=relaxed/simple; bh=OSleQuf+3GvuGQKKlD/0eqvp9sgFJG0zWd8Z5LjcIEU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fqoBYSXAG/naR8v7FaQ/NqofQf+9WVKJvgajB/n5bR7EvUdxzRRhC83JWlh7nOGzbWM7YIX+FJt5ygnBErYIlo/+nv0XvMwxBGgnJOMorhOP5LLurMrxfBBSbCJrAz2ArJEnIthQQ+7S94R7Of1wf02dLi5j3ixlRFDP1i2407I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95A6C4BCA43A 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 60O5FNIq168774 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 24 Jan 2026 00:15:28 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 60O5FNIq168774 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1769231728; bh=fzasaRX6ywSfC55l9cMxeZFOJwW80kirETfOIxobTlE=; h=From:To:Cc:Subject:Date:From; b=Pl1ufd2CyUD5oZATcwDNIxFyvwCCLW/RrFaJos2vGm12T3alBGJcGzgxVW6hvQXWB Dib0OM3yMCzSxnLFEgHlxjnHB28iqL+KEcNJXrmaLE7JSspTZATrU9808890OR7e8P zs7gtN37kYbxpSxfAMd4ZtWXLb//jE3fKl87cvMRqkLo6LwBMpSkVpxbt9v9ItnqnO OwGrd+dCDseES2A55ZnNctF7zlHf+FUKZKy58Wkm/l7MUvxB+2mFvor/+PWjivt2/C iraaZHUl2FcIDGCOM0pGWBTa28WDbWNUMeTx2T6AXs5xCWNZZrviMt2mH0bae32PQC qFEoHvEOP0w7A== Received: by simark.ca (Postfix) id 9625F1E089; Sat, 24 Jan 2026 00:15:23 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb/testsuite: add rocm-test-utils.h Date: Sat, 24 Jan 2026 00:14:59 -0500 Message-ID: <20260124051512.731-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 24 Jan 2026 05:15:23 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi Add this file and move the CHECK macro there. This macro is used by pretty much all tests, current and future. Change-Id: I54714ae5fb34d31a24d72ad48abaedcbf928cb3b --- .../code-object-load-while-breakpoint-hit.cpp | 13 +----- .../fork-exec-gpu-to-non-gpu-execer.cpp | 11 +---- .../fork-exec-non-gpu-to-gpu-execee.cpp | 12 +----- gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp | 11 +---- .../precise-memory-warning-sigsegv.cpp | 11 +---- gdb/testsuite/gdb.rocm/precise-memory.cpp | 11 +---- gdb/testsuite/gdb.rocm/rocm-test-utils.h | 40 +++++++++++++++++++ 7 files changed, 47 insertions(+), 62 deletions(-) create mode 100644 gdb/testsuite/gdb.rocm/rocm-test-utils.h diff --git a/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.cpp b/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.cpp index d1d5f352d772..d2f2ddcbf6c1 100644 --- a/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.cpp +++ b/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.cpp @@ -38,22 +38,13 @@ kernel () #include #include +#include "rocm-test-utils.h" + constexpr unsigned int NUM_ITEMS_PER_BLOCK = 256; constexpr unsigned int NUM_BLOCKS = 128; constexpr unsigned int NUM_ITEMS = NUM_ITEMS_PER_BLOCK * NUM_BLOCKS; constexpr unsigned int NUM_LOAD_UNLOADS = 5; -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } - int main (int argc, const char **argv) { diff --git a/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu-execer.cpp b/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu-execer.cpp index 758be54d3813..62938992baef 100644 --- a/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu-execer.cpp +++ b/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu-execer.cpp @@ -18,16 +18,7 @@ #include #include -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } +#include "rocm-test-utils.h" __global__ static void kernel1 () diff --git a/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu-execee.cpp b/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu-execee.cpp index c73df22a3e05..9f84af7cd323 100644 --- a/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu-execee.cpp +++ b/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu-execee.cpp @@ -17,17 +17,7 @@ #include -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } - +#include "rocm-test-utils.h" __device__ static void break_here_execee () diff --git a/gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp b/gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp index 0a00a996e1ab..b60b51d39ed4 100644 --- a/gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp +++ b/gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp @@ -20,16 +20,7 @@ #include #include -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } +#include "rocm-test-utils.h" __global__ void kern () diff --git a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp index 657dcfdcd59e..2510e4381bf4 100644 --- a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp +++ b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp @@ -17,16 +17,7 @@ #include -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } +#include "rocm-test-utils.h" __global__ void kernel () diff --git a/gdb/testsuite/gdb.rocm/precise-memory.cpp b/gdb/testsuite/gdb.rocm/precise-memory.cpp index 49d98a1bf752..432d3cb576f1 100644 --- a/gdb/testsuite/gdb.rocm/precise-memory.cpp +++ b/gdb/testsuite/gdb.rocm/precise-memory.cpp @@ -17,16 +17,7 @@ #include -#define CHECK(cmd) \ - { \ - hipError_t error = cmd; \ - if (error != hipSuccess) \ - { \ - fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ - hipGetErrorString (error), error, __FILE__, __LINE__); \ - exit (EXIT_FAILURE); \ - } \ - } +#include "rocm-test-utils.h" __global__ void kernel () diff --git a/gdb/testsuite/gdb.rocm/rocm-test-utils.h b/gdb/testsuite/gdb.rocm/rocm-test-utils.h new file mode 100644 index 000000000000..70d232b873b8 --- /dev/null +++ b/gdb/testsuite/gdb.rocm/rocm-test-utils.h @@ -0,0 +1,40 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2021-2026 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef ROCM_TEST_UTILS_H +#define ROCM_TEST_UTILS_H + +#include +#include + +/* Check the return value of a HIP call, exit on error. */ + +#define CHECK(cmd) \ + do \ + { \ + hipError_t error = cmd; \ + if (error != hipSuccess) \ + { \ + fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ + hipGetErrorString (error), error, __FILE__, \ + __LINE__); \ + exit (EXIT_FAILURE); \ + } \ + } \ + while (0) + +#endif /* ROCM_TEST_UTILS_H */ base-commit: 3e0e90ac1e407c5a23f8c823679004043e38848f -- 2.52.0