Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
@ 2026-10-15 17:04 Tankut Baris Aktemur
  2026-10-15 17:13 ` Six, Lancelot
  0 siblings, 1 reply; 2+ messages in thread
From: Tankut Baris Aktemur @ 2026-10-15 17:04 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           |  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;]]
+       )],
+       [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


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

* RE: [PATCH] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE
  2026-10-15 17:04 [PATCH] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE Tankut Baris Aktemur
@ 2026-10-15 17:13 ` Six, Lancelot
  0 siblings, 0 replies; 2+ messages in thread
From: Six, Lancelot @ 2026-10-15 17:13 UTC (permalink / raw)
  To: Aktemur, Baris, gdb-patches, tom

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


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 17:04 [PATCH] gdb, amdgpu: add config guards for AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE Tankut Baris Aktemur
2026-10-15 17:13 ` Six, Lancelot

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