Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
@ 2026-10-20  7:05 Tankut Baris Aktemur
  2026-10-20 10:48 ` Lancelot SIX
  0 siblings, 1 reply; 3+ messages in thread
From: Tankut Baris Aktemur @ 2026-10-20  7:05 UTC (permalink / raw)
  To: gdb-patches, Lancelot.Six, tom

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           |  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...
     #
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
  2026-10-20  7:05 [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE Tankut Baris Aktemur
@ 2026-10-20 10:48 ` Lancelot SIX
  2026-10-20 14:52   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Lancelot SIX @ 2026-10-20 10:48 UTC (permalink / raw)
  To: Tankut Baris Aktemur, gdb-patches, tom



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...
>       #


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
  2026-10-20 10:48 ` Lancelot SIX
@ 2026-10-20 14:52   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2026-10-20 14:52 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: Tankut Baris Aktemur, gdb-patches, tom

>>>>> "Lancelot" == Lancelot SIX <Lancelot.Six@amd.com> writes:

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

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

Thanks, this is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-20 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20  7:05 [PATCH v3] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE Tankut Baris Aktemur
2026-10-20 10:48 ` Lancelot SIX
2026-10-20 14:52   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox