From: Lancelot SIX <lancelot.six@amd.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] gdb/testsuite: add rocm-test-utils.h
Date: Wed, 4 Feb 2026 18:39:19 +0000 [thread overview]
Message-ID: <275ulgf45do46mb5yxe5fosqr3jqfbwung5lggymlzdsbkziyc@uqfvuyywm3tb> (raw)
In-Reply-To: <20260124051512.731-1-simon.marchi@polymtl.ca>
On Sat, Jan 24, 2026 at 12:14:59AM -0500, Simon Marchi wrote:
> Add this file and move the CHECK macro there. This macro is used by
> pretty much all tests, current and future.
Hi,
This looks good to me.
Best,
Lancelot.
Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
>
> 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 <hip/hip_runtime.h>
> #include <unistd.h>
>
> +#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 <hip/hip_runtime.h>
> #include <unistd.h>
>
> -#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 <hip/hip_runtime.h>
>
> -#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 <unistd.h>
> #include <hip/hip_runtime.h>
>
> -#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 <hip/hip_runtime.h>
>
> -#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 <hip/hip_runtime.h>
>
> -#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 <http://www.gnu.org/licenses/>. */
> +
> +#ifndef ROCM_TEST_UTILS_H
> +#define ROCM_TEST_UTILS_H
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +/* 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
prev parent reply other threads:[~2026-02-04 18:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 5:14 simon.marchi
2026-01-24 5:15 ` [PATCH 2/2] gdb/amd-dbgapi: add basic watchpoint support simon.marchi
2026-02-04 20:33 ` Lancelot SIX
2026-02-05 18:54 ` Simon Marchi
2026-02-04 18:39 ` Lancelot SIX [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=275ulgf45do46mb5yxe5fosqr3jqfbwung5lggymlzdsbkziyc@uqfvuyywm3tb \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox