From: "Six, Lancelot" <Lancelot.Six@amd.com>
To: "Aktemur, Baris" <TankutBaris.Aktemur@amd.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
"tom@tromey.com" <tom@tromey.com>
Subject: RE: [PATCH] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
Date: Thu, 15 Oct 2026 17:13:23 +0000 [thread overview]
Message-ID: <PH0PR12MB5607A3A17F9E971A24198D6E839C2@PH0PR12MB5607.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20261015170450.2520815-1-tankutbaris.aktemur@amd.com>
AMD General
> -----Original Message-----
> From: Aktemur, Baris <TankutBaris.Aktemur@amd.com>
> Sent: 15 October 2026 18:05
> To: gdb-patches@sourceware.org; Six, Lancelot <Lancelot.Six@amd.com>;
> tom@tromey.com
> Subject: [PATCH] gdb, amdgpu: add config guards for
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
>
> Commit e52a8aca2baf6481c4e8fea45530283759096be5 "gdb, amdgpu:
> handle
> UNAVAILABLE error when accessing memory" used an enum value from
> amd-dbgapi named AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
> that may
> not be available in all installed packages. This causes a build
> failure as reported by Tom Tromey at
>
> https://sourceware.org/pipermail/gdb-patches/2026-October/231115.html
>
> Detect at configuration time if the enum value exists and guard the
> newly added code accordingly.
> ---
> gdb/amd-dbgapi-target.c | 4 ++++
> gdb/config.in | 3 +++
> gdb/configure | 36 ++++++++++++++++++++++++++++++++++++
> gdb/configure.ac | 21 +++++++++++++++++++++
> 4 files changed, 64 insertions(+)
>
> diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
> index 2fd175de6f7..1446187c75f 100644
> --- a/gdb/amd-dbgapi-target.c
> +++ b/gdb/amd-dbgapi-target.c
> @@ -786,11 +786,13 @@ amd_dbgapi_target::xfer_partial (enum
> target_object object, const char *annex,
> AMD_DBGAPI_ADDRESS_SPACE_GLOBAL,
> offset, &len, writebuf);
>
> +#if AMD_DBGAPI_HAS_STATUS_ERROR_MEMORY_UNAVAILABLE
> if (status == AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE)
> {
> *xfered_len = requested_len;
> return TARGET_XFER_UNAVAILABLE;
> }
> +#endif
>
> if (status != AMD_DBGAPI_STATUS_SUCCESS)
> return TARGET_XFER_E_IO;
> @@ -2576,8 +2578,10 @@ amd_dbgapi_xfer_global_memory_callback
>
> if (status == TARGET_XFER_EOF)
> return AMD_DBGAPI_STATUS_ERROR_PROCESS_EXITED;
> +#if AMD_DBGAPI_HAS_STATUS_ERROR_MEMORY_UNAVAILABLE
> else if (status == TARGET_XFER_UNAVAILABLE)
> return AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE;
> +#endif
> else if (status != TARGET_XFER_OK)
> return AMD_DBGAPI_STATUS_ERROR_MEMORY_ACCESS;
>
> diff --git a/gdb/config.in b/gdb/config.in
> index 7ea0e9cfce8..93060f573c5 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -6,6 +6,9 @@
> /* Additional directories to look for separate debug info. */
> #undef ADDITIONAL_DEBUG_DIRS
>
> +/* Define if AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is
> available. */
> +#undef AMD_DBGAPI_HAS_STATUS_ERROR_MEMORY_UNAVAILABLE
> +
> /* Directories from which to load auto-loaded scripts. */
> #undef AUTO_LOAD_DIR
>
> diff --git a/gdb/configure b/gdb/configure
> index 0ed49887480..eaa8588fe69 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -25105,6 +25105,42 @@ $as_echo "#define HAVE_AMD_DBGAPI 1"
> >>confdefs.h
> as_fn_error $? "amd-dbgapi not supported for host ${gdb_host}"
> "$LINENO" 5
> ;;
> esac
> +
> + # Detect if AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE can be
> used.
> + save_CPPFLAGS="$CPPFLAGS"
> + CPPFLAGS="$CPPFLAGS $AMD_DBGAPI_CFLAGS"
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is available" >&5
> +$as_echo_n "checking whether
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is available... " >&6; }
> + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h. */
> +#include <amd-dbgapi/amd-dbgapi.h>
> +int
> +main ()
> +{
> +amd_dbgapi_status_t s =
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE;
> +
> + ;
> + return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> + amd_dbgapi_has_status_error_memory_unavailable=yes
> + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> +$as_echo "yes" >&6; }
> +else
> + amd_dbgapi_has_status_error_memory_unavailable=no
> + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> + CPPFLAGS="$save_CPPFLAGS"
> +
> + if test "x${amd_dbgapi_has_status_error_memory_unavailable}" = "xyes";
> then
> +
> +$as_echo "#define
> AMD_DBGAPI_HAS_STATUS_ERROR_MEMORY_UNAVAILABLE 1"
> >>confdefs.h
> +
> + fi
> +
> elif test "$gdb_require_amd_dbgapi" = true -o "$with_amd_dbgapi" = yes;
> then
> # amd-dbgapi was not found and...
> #
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index e0117ede292..274d248a64d 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -368,6 +368,27 @@ if test "$gdb_require_amd_dbgapi" = true \
> AC_MSG_ERROR([amd-dbgapi not supported for host ${gdb_host}])
> ;;
> esac
> +
> + # Detect if AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE can be
> used.
> + save_CPPFLAGS="$CPPFLAGS"
> + CPPFLAGS="$CPPFLAGS $AMD_DBGAPI_CFLAGS"
> + AC_MSG_CHECKING([whether
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is available])
> + AC_COMPILE_IFELSE(
> + [AC_LANG_PROGRAM(
> + [[#include <amd-dbgapi/amd-dbgapi.h>]],
> + [[amd_dbgapi_status_t s =
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE;]]
> + )],
Hi,
Silly question. If CPPFLAGS contains "-Werror -Wall", wouldn't this risk to complain about s not being used? Would fallback to the conservative solution to not use MEMORY_UNAVAILABLE, so nothing really dramatic.
Might be worth using "(void) AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE" (or anything to avoid the potential warning).
Best,
Lancelot.
> + [amd_dbgapi_has_status_error_memory_unavailable=yes
> + AC_MSG_RESULT([yes])],
> + [amd_dbgapi_has_status_error_memory_unavailable=no
> + AC_MSG_RESULT([no])])
> + CPPFLAGS="$save_CPPFLAGS"
> +
> + if test "x${amd_dbgapi_has_status_error_memory_unavailable}" = "xyes";
> then
> +
> AC_DEFINE(AMD_DBGAPI_HAS_STATUS_ERROR_MEMORY_UNAVAILABLE, 1,
> + [Define if
> AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is available.])
> + fi
> +
> elif test "$gdb_require_amd_dbgapi" = true -o "$with_amd_dbgapi" = yes;
> then
> # amd-dbgapi was not found and...
> #
> --
> 2.53.0
prev parent reply other threads:[~2026-10-15 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 17:04 Tankut Baris Aktemur
2026-10-15 17:13 ` Six, Lancelot [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=PH0PR12MB5607A3A17F9E971A24198D6E839C2@PH0PR12MB5607.namprd12.prod.outlook.com \
--to=lancelot.six@amd.com \
--cc=TankutBaris.Aktemur@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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