[Bug testsuite/33345] [gdb/testsuite] FAIL: gdb.dap/scopes.exp: fetch all registers success
aburgess at redhat dot com
sourceware-bugzilla@sourceware.org
Mon Sep 1 17:09:22 GMT 2025
https://sourceware.org/bugzilla/show_bug.cgi?id=33345
--- Comment #14 from Andrew Burgess <aburgess at redhat dot com> ---
Disclaimer: everything I know about DAP, I've learnt in the last 4 hours.
When asking for the registers GDB sends back some JSON? formatted output, with
a bunch of key/value fields. Here's one snippet for the $rdx register:
{
"variablesReference": 0,
"name": "rdx",
"value": "140737488321608",
"type": "int64_t"
}
And here's another for the $rip register:
{
"variablesReference": 25,
"name": "rip",
"value": "0x401144 <main+62>",
"namedVariables": 1,
"memoryReference": "0x401144",
"type": "void (*)()"
}
The 'memoryReference' field is interesting, this is only added for registers
which are of pointer type. The way that we get the value in this field is by
doing:
result["memoryReference"] = hex(int(self._value))
So, if GDB reads a non-pointer register, the value is filled in by just
converting the gdb.Value to a string. For an unavailable register this gives
the string "<unavailable>".
For a pointer register, the value field is filled in the same way, no problem
there. But, when GDB tried to fill in the memoryReference field the conversion
to int throws a Python exception, which is not caught until much further up the
stack. In effect the DAP request fails with that exception as the message.
My claim is that, should a pointer register be unavailable, this shouldn't be
an error, we should just report that the register is unavailable. We should
either catch the exception, or avoid performing the conversion when we know the
value cannot be converted.
This would mean that, should $rip be unavailable, we'd get back something like:
{
"variablesReference": 25,
"name": "rip",
"value": "<unavailable>",
"namedVariables": 1,
"type": "void (*)()"
}
Notice the memoryReference field is missing. We could potentially add the
memoryReference field back, with the "<unavailable>" string. But I suspect it
isn't going to help much, so for now I propose just dropping it.
Patches to do all this posted here:
https://inbox.sourceware.org/gdb-patches/cover.1756745719.git.aburgess@redhat.com/
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list