* [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* Re: [PATCH] gdb, amdgpu: handle UNAVAILABLE error when accessing memory
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
1 sibling, 0 replies; 4+ messages in thread
From: Lancelot SIX @ 2026-10-14 10:42 UTC (permalink / raw)
To: Tankut Baris Aktemur, gdb-patches
On 14/10/2026 10:08, Tankut Baris Aktemur wrote:
> 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.
Hi,
This looks good to me, thanks.
Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Best,
Lancelot.
> ---
> 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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] gdb, amdgpu: handle UNAVAILABLE error when accessing memory
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
1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2026-10-15 15:40 UTC (permalink / raw)
To: Tankut Baris Aktemur; +Cc: gdb-patches, lancelot.six
>>>>> Tankut Baris Aktemur <tankutbaris.aktemur@amd.com> writes:
> + if (status == AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE)
> + {
I get this:
../../binutils-gdb/gdb/amd-dbgapi-target.c:789:17: error: ‘AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE’ was not declared in this scope; did you mean ‘AMD_DBGAPI_STATUS_ERROR_NOT_AVAILABLE’?
Not sure I have the right thing but:
bapiya. rpm -q rocdbgapi-devel
rocdbgapi-devel-7.1.0-4.fc44.x86_64
which seems to be the latest on Fedora 43.
Meanwhile I'm going to build with this feature disabled.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] gdb, amdgpu: handle UNAVAILABLE error when accessing memory
2026-10-15 15:40 ` Tom Tromey
@ 2026-10-15 16:06 ` Six, Lancelot
0 siblings, 0 replies; 4+ messages in thread
From: Six, Lancelot @ 2026-10-15 16:06 UTC (permalink / raw)
To: Tom Tromey, Aktemur, Baris; +Cc: gdb-patches
AMD General
> -----Original Message-----
> From: Tom Tromey <tom@tromey.com>
> Sent: 15 October 2026 16:40
> To: Aktemur, Baris <TankutBaris.Aktemur@amd.com>
> Cc: gdb-patches@sourceware.org; Six, Lancelot <Lancelot.Six@amd.com>
> Subject: Re: [PATCH] gdb, amdgpu: handle UNAVAILABLE error when
> accessing memory
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> >>>>> Tankut Baris Aktemur <tankutbaris.aktemur@amd.com> writes:
>
> > + if (status == AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE)
> > + {
>
> I get this:
>
> ../../binutils-gdb/gdb/amd-dbgapi-target.c:789:17: error:
> ‘AMD_DBGAPI_STATUS_ERROR_MEMORY_UNAVAILABLE’ was not declared in
> this scope; did you mean ‘AMD_DBGAPI_STATUS_ERROR_NOT_AVAILABLE’?
>
> Not sure I have the right thing but:
>
> bapiya. rpm -q rocdbgapi-devel
> rocdbgapi-devel-7.1.0-4.fc44.x86_64
>
> which seems to be the latest on Fedora 43.
>
> Meanwhile I'm going to build with this feature disabled.
>
> Tom
Oh, sorry about that.
I think this comes from version in rocm-10. Will add the configury checks and guards to avoid the breakage.
Best,
Lancelot.
^ 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