Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb, amdgpu: handle UNAVAILABLE error when accessing memory
@ 2026-10-14  9:08 Tankut Baris Aktemur
  2026-10-14 10:42 ` Lancelot SIX
  2026-10-15 15:40 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Tankut Baris Aktemur @ 2026-10-14  9:08 UTC (permalink / raw)
  To: gdb-patches, lancelot.six

In amd_dbgapi_target, accessing memory through dbgapi may fail with
AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE.  Convert this error to
GDB's TARGET_XFER_UNAVAILABLE.  Similarly, in the global memory access
callback function, if the access result is TARGET_XFER_UNAVAILABLE, pass
the result back to dbgapi as AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE.

These conversions in both ways are useful to display to the user an
"<unavailable>" result instead of "Cannot access memory...".  This may
happen in lightweight corefiles, where some chunk of memory may not
have been captured.

Note that if xfer_partial target op replies with TARGET_XFER_UNAVAILABLE,
GDB expects xfered_len to be greater than zero.

Regression-tested in gfx1201.
---
 gdb/amd-dbgapi-target.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 93207a8fdd2..2fd175de6f7 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -786,6 +786,12 @@ amd_dbgapi_target::xfer_partial (enum target_object object, const char *annex,
 				      AMD_DBGAPI_ADDRESS_SPACE_GLOBAL,
 				      offset, &len, writebuf);
 
+  if (status == AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE)
+    {
+      *xfered_len = requested_len;
+      return TARGET_XFER_UNAVAILABLE;
+    }
+
   if (status != AMD_DBGAPI_STATUS_SUCCESS)
     return TARGET_XFER_E_IO;
 
@@ -2570,6 +2576,8 @@ amd_dbgapi_xfer_global_memory_callback
 
   if (status == TARGET_XFER_EOF)
     return AMD_DBGAPI_STATUS_ERROR_PROCESS_EXITED;
+  else if (status == TARGET_XFER_UNAVAILABLE)
+    return AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE;
   else if (status != TARGET_XFER_OK)
     return AMD_DBGAPI_STATUS_ERROR_MEMORY_ACCESS;
 
-- 
2.53.0


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14  9:08 [PATCH] gdb, amdgpu: handle UNAVAILABLE error when accessing memory Tankut Baris Aktemur
2026-10-14 10:42 ` Lancelot SIX
2026-10-15 15:40 ` Tom Tromey
2026-10-15 16:06   ` Six, Lancelot

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