Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Lancelot SIX <Lancelot.Six@amd.com>
To: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>,
	gdb-patches@sourceware.org, tom@tromey.com
Subject: Re: [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
Date: Tue, 20 Oct 2026 11:48:23 +0100	[thread overview]
Message-ID: <9f95b7eb-5477-4f12-abaf-2207a8851e45@amd.com> (raw)
In-Reply-To: <20261020070546.803912-1-tankutbaris.aktemur@amd.com>



On 20/10/2026 08:05, Tankut Baris Aktemur wrote:
> 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.

Hi,

The amdgpu part looks reasonable to me.  I expect the configury part 
should require a global maintainer approval.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)

Best,
Lancelot.

> ---
>   gdb/amd-dbgapi-target.c |  4 ++++
>   gdb/config.in           |  4 ++++
>   gdb/configure           | 21 +++++++++++++++++++++
>   gdb/configure.ac        | 10 ++++++++++
>   4 files changed, 39 insertions(+)
> 
> diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
> index 2fd175de6f7..a38a8bafb90 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 HAVE_DECL_AMD_DBGAPI_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 HAVE_DECL_AMD_DBGAPI_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..ce48cfd9e22 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -136,6 +136,10 @@
>      you don't. */
>   #undef HAVE_DECL_ADDR_NO_RANDOMIZE
>   
> +/* Define to 1 if you have the declaration of
> +   `AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE', and to 0 if you don't. */
> +#undef HAVE_DECL_AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
> +
>   /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
>      don't. */
>   #undef HAVE_DECL_ASPRINTF
> diff --git a/gdb/configure b/gdb/configure
> index 0ed49887480..0e3efec3f81 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -25105,6 +25105,27 @@ $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.
> +    # This value is available with amd-dbgapi version 0.78.0.
> +    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; }
> +    ac_fn_c_check_decl "$LINENO" "AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE" "ac_cv_have_decl_AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE" "#include <amd-dbgapi/amd-dbgapi.h>
> +"
> +if test "x$ac_cv_have_decl_AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE" = xyes; then :
> +  ac_have_decl=1
> +else
> +  ac_have_decl=0
> +fi
> +
> +cat >>confdefs.h <<_ACEOF
> +#define HAVE_DECL_AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE $ac_have_decl
> +_ACEOF
> +
> +    CPPFLAGS="$save_CPPFLAGS"
> +
>     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..ee10f555b3c 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -368,6 +368,16 @@ 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.
> +    # This value is available with amd-dbgapi version 0.78.0.
> +    save_CPPFLAGS="$CPPFLAGS"
> +    CPPFLAGS="$CPPFLAGS $AMD_DBGAPI_CFLAGS"
> +    AC_MSG_CHECKING([whether AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE is available])
> +    AC_CHECK_DECLS(AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE,
> +		   [], [], [[#include <amd-dbgapi/amd-dbgapi.h>]])
> +    CPPFLAGS="$save_CPPFLAGS"
> +
>     elif test "$gdb_require_amd_dbgapi" = true -o "$with_amd_dbgapi" = yes; then
>       # amd-dbgapi was not found and...
>       #


  reply	other threads:[~2026-10-20 10:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  7:05 Tankut Baris Aktemur
2026-10-20 10:48 ` Lancelot SIX [this message]
2026-10-20 14:52   ` Tom Tromey

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=9f95b7eb-5477-4f12-abaf-2207a8851e45@amd.com \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tankutbaris.aktemur@amd.com \
    --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