[PATCH 0/4] gdbstub: Always infer base register index from GDB XML

Philippe Mathieu-Daudé posted 4 patches 2 days, 9 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260227213958.21170-1-philmd@linaro.org
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Brian Cain <brian.cain@oss.qualcomm.com>, Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Song Gao <gaosong@loongson.cn>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
include/exec/gdbstub.h     |  4 ++--
gdbstub/gdbstub.c          | 16 ++++++----------
target/arm/gdbstub.c       | 21 ++++++++-------------
target/arm/gdbstub64.c     | 19 +++++++------------
target/hexagon/cpu.c       |  2 +-
target/i386/gdbstub.c      |  8 +++-----
target/loongarch/gdbstub.c |  6 +++---
target/m68k/helper.c       |  4 ++--
target/microblaze/cpu.c    |  3 +--
target/ppc/gdbstub.c       | 11 +++++------
target/riscv/gdbstub.c     | 18 ++++++------------
target/s390x/gdbstub.c     | 15 +++++++--------
target/sparc/gdbstub.c     | 12 ++++--------
gdb-xml/cf-fp.xml          |  2 +-
gdb-xml/m68k-fp.xml        |  2 +-
scripts/feature_to_c.py    | 14 +++++++++-----
16 files changed, 66 insertions(+), 91 deletions(-)
[PATCH 0/4] gdbstub: Always infer base register index from GDB XML
Posted by Philippe Mathieu-Daudé 2 days, 9 hours ago
Generic fix for a latent bug reported by Florian:
https://lore.kernel.org/qemu-devel/e44df309-d40d-46f0-88a8-7ac55f9a3634@fhofhammer.de/

Use the 'regnum' XML tag for feature base register index
(after fixing the incorrect m68k FPU ones).

Philippe Mathieu-Daudé (4):
  gdbstub: Have scripts/feature_to_c.py generate more verbose output
  gdbstub: Make base register explicit in m68k GDB XML files
  gdbstub: Emit base_register index in GDBFeature entries
  gdbstub: Remove @g_pos argument in gdb_register_coprocessor()

 include/exec/gdbstub.h     |  4 ++--
 gdbstub/gdbstub.c          | 16 ++++++----------
 target/arm/gdbstub.c       | 21 ++++++++-------------
 target/arm/gdbstub64.c     | 19 +++++++------------
 target/hexagon/cpu.c       |  2 +-
 target/i386/gdbstub.c      |  8 +++-----
 target/loongarch/gdbstub.c |  6 +++---
 target/m68k/helper.c       |  4 ++--
 target/microblaze/cpu.c    |  3 +--
 target/ppc/gdbstub.c       | 11 +++++------
 target/riscv/gdbstub.c     | 18 ++++++------------
 target/s390x/gdbstub.c     | 15 +++++++--------
 target/sparc/gdbstub.c     | 12 ++++--------
 gdb-xml/cf-fp.xml          |  2 +-
 gdb-xml/m68k-fp.xml        |  2 +-
 scripts/feature_to_c.py    | 14 +++++++++-----
 16 files changed, 66 insertions(+), 91 deletions(-)

-- 
2.52.0


Re: [PATCH 0/4] gdbstub: Always infer base register index from GDB XML
Posted by Pierrick Bouvier 2 days, 8 hours ago
On 2/27/26 1:39 PM, Philippe Mathieu-Daudé wrote:
> Generic fix for a latent bug reported by Florian:
> https://lore.kernel.org/qemu-devel/e44df309-d40d-46f0-88a8-7ac55f9a3634@fhofhammer.de/
> 
> Use the 'regnum' XML tag for feature base register index
> (after fixing the incorrect m68k FPU ones).
> 
> Philippe Mathieu-Daudé (4):
>    gdbstub: Have scripts/feature_to_c.py generate more verbose output
>    gdbstub: Make base register explicit in m68k GDB XML files
>    gdbstub: Emit base_register index in GDBFeature entries
>    gdbstub: Remove @g_pos argument in gdb_register_coprocessor()
> 
>   include/exec/gdbstub.h     |  4 ++--
>   gdbstub/gdbstub.c          | 16 ++++++----------
>   target/arm/gdbstub.c       | 21 ++++++++-------------
>   target/arm/gdbstub64.c     | 19 +++++++------------
>   target/hexagon/cpu.c       |  2 +-
>   target/i386/gdbstub.c      |  8 +++-----
>   target/loongarch/gdbstub.c |  6 +++---
>   target/m68k/helper.c       |  4 ++--
>   target/microblaze/cpu.c    |  3 +--
>   target/ppc/gdbstub.c       | 11 +++++------
>   target/riscv/gdbstub.c     | 18 ++++++------------
>   target/s390x/gdbstub.c     | 15 +++++++--------
>   target/sparc/gdbstub.c     | 12 ++++--------
>   gdb-xml/cf-fp.xml          |  2 +-
>   gdb-xml/m68k-fp.xml        |  2 +-
>   scripts/feature_to_c.py    | 14 +++++++++-----
>   16 files changed, 66 insertions(+), 91 deletions(-)
> 

See some check-tcg failures:
https://github.com/p-b-o/qemu-ci/actions/runs/22505136358/job/65203283939

Regards,
Pierrick

Re: [PATCH 0/4] gdbstub: Always infer base register index from GDB XML
Posted by Philippe Mathieu-Daudé 2 days, 7 hours ago
+Zhao/Paolo

On 27/2/26 23:39, Pierrick Bouvier wrote:
> On 2/27/26 1:39 PM, Philippe Mathieu-Daudé wrote:
>> Generic fix for a latent bug reported by Florian:
>> https://lore.kernel.org/qemu-devel/e44df309- 
>> d40d-46f0-88a8-7ac55f9a3634@fhofhammer.de/
>>
>> Use the 'regnum' XML tag for feature base register index
>> (after fixing the incorrect m68k FPU ones).
>>
>> Philippe Mathieu-Daudé (4):
>>    gdbstub: Have scripts/feature_to_c.py generate more verbose output
>>    gdbstub: Make base register explicit in m68k GDB XML files
>>    gdbstub: Emit base_register index in GDBFeature entries
>>    gdbstub: Remove @g_pos argument in gdb_register_coprocessor()
>>
>>   include/exec/gdbstub.h     |  4 ++--
>>   gdbstub/gdbstub.c          | 16 ++++++----------
>>   target/arm/gdbstub.c       | 21 ++++++++-------------
>>   target/arm/gdbstub64.c     | 19 +++++++------------
>>   target/hexagon/cpu.c       |  2 +-
>>   target/i386/gdbstub.c      |  8 +++-----
>>   target/loongarch/gdbstub.c |  6 +++---
>>   target/m68k/helper.c       |  4 ++--
>>   target/microblaze/cpu.c    |  3 +--
>>   target/ppc/gdbstub.c       | 11 +++++------
>>   target/riscv/gdbstub.c     | 18 ++++++------------
>>   target/s390x/gdbstub.c     | 15 +++++++--------
>>   target/sparc/gdbstub.c     | 12 ++++--------
>>   gdb-xml/cf-fp.xml          |  2 +-
>>   gdb-xml/m68k-fp.xml        |  2 +-
>>   scripts/feature_to_c.py    | 14 +++++++++-----
>>   16 files changed, 66 insertions(+), 91 deletions(-)
>>
> 
> See some check-tcg failures:
> https://github.com/p-b-o/qemu-ci/actions/runs/22505136358/job/65203283939

I ran check-tcg on a user-only build... And neglected system binaries.
Sigh. Thanks for testing / noticing.

Per commit f46e5073a8a ("i386/gdbstub: Add APX support for gdbstub"),
the gdb-xml/i386-64bit-apx.xml file comes from GDB, but I can not find
it there...

https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/i386;h=524dad125c554f6210e8987f141383b98ec606cf;hb=refs/tags/binutils-2_46

Maybe it has been generated manually like the m68k one? In that case
it could miss the @regnum tag, and the fix could be as easy as:

-- >8 --
diff --git a/gdb-xml/i386-64bit-apx.xml b/gdb-xml/i386-64bit-apx.xml
index 11a4ec67cae..34cd501881f 100644
--- a/gdb-xml/i386-64bit-apx.xml
+++ b/gdb-xml/i386-64bit-apx.xml
@@ -9,3 +9,3 @@
  <feature name="org.gnu.gdb.i386.apx">
-  <reg name="r16" bitsize="64" type="int64"/>
+  <reg name="r16" bitsize="64" type="int64" regnum="16"/>
    <reg name="r17" bitsize="64" type="int64"/>
---

But I have no clue, it is too late for me to look at GDB source code
so I'll defer to Zhao / Paolo and revisit after the week-end.

Thanks,

Phil.

Re: [PATCH 0/4] gdbstub: Always infer base register index from GDB XML
Posted by Akihiko Odaki 1 day, 23 hours ago
On 2026/02/28 8:10, Philippe Mathieu-Daudé wrote:
> +Zhao/Paolo
> 
> On 27/2/26 23:39, Pierrick Bouvier wrote:
>> On 2/27/26 1:39 PM, Philippe Mathieu-Daudé wrote:
>>> Generic fix for a latent bug reported by Florian:
>>> https://lore.kernel.org/qemu-devel/e44df309- 
>>> d40d-46f0-88a8-7ac55f9a3634@fhofhammer.de/
>>>
>>> Use the 'regnum' XML tag for feature base register index
>>> (after fixing the incorrect m68k FPU ones).
>>>
>>> Philippe Mathieu-Daudé (4):
>>>    gdbstub: Have scripts/feature_to_c.py generate more verbose output
>>>    gdbstub: Make base register explicit in m68k GDB XML files
>>>    gdbstub: Emit base_register index in GDBFeature entries
>>>    gdbstub: Remove @g_pos argument in gdb_register_coprocessor()
>>>
>>>   include/exec/gdbstub.h     |  4 ++--
>>>   gdbstub/gdbstub.c          | 16 ++++++----------
>>>   target/arm/gdbstub.c       | 21 ++++++++-------------
>>>   target/arm/gdbstub64.c     | 19 +++++++------------
>>>   target/hexagon/cpu.c       |  2 +-
>>>   target/i386/gdbstub.c      |  8 +++-----
>>>   target/loongarch/gdbstub.c |  6 +++---
>>>   target/m68k/helper.c       |  4 ++--
>>>   target/microblaze/cpu.c    |  3 +--
>>>   target/ppc/gdbstub.c       | 11 +++++------
>>>   target/riscv/gdbstub.c     | 18 ++++++------------
>>>   target/s390x/gdbstub.c     | 15 +++++++--------
>>>   target/sparc/gdbstub.c     | 12 ++++--------
>>>   gdb-xml/cf-fp.xml          |  2 +-
>>>   gdb-xml/m68k-fp.xml        |  2 +-
>>>   scripts/feature_to_c.py    | 14 +++++++++-----
>>>   16 files changed, 66 insertions(+), 91 deletions(-)
>>>
>>
>> See some check-tcg failures:
>> https://github.com/p-b-o/qemu-ci/actions/runs/22505136358/job/65203283939
> 
> I ran check-tcg on a user-only build... And neglected system binaries.
> Sigh. Thanks for testing / noticing.
> 
> Per commit f46e5073a8a ("i386/gdbstub: Add APX support for gdbstub"),
> the gdb-xml/i386-64bit-apx.xml file comes from GDB, but I can not find
> it there...
> 
> https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/ 
> i386;h=524dad125c554f6210e8987f141383b98ec606cf;hb=refs/tags/binutils-2_46
> 
> Maybe it has been generated manually like the m68k one? In that case
> it could miss the @regnum tag, and the fix could be as easy as:
> 
> -- >8 --
> diff --git a/gdb-xml/i386-64bit-apx.xml b/gdb-xml/i386-64bit-apx.xml
> index 11a4ec67cae..34cd501881f 100644
> --- a/gdb-xml/i386-64bit-apx.xml
> +++ b/gdb-xml/i386-64bit-apx.xml
> @@ -9,3 +9,3 @@
>   <feature name="org.gnu.gdb.i386.apx">
> -  <reg name="r16" bitsize="64" type="int64"/>
> +  <reg name="r16" bitsize="64" type="int64" regnum="16"/>
>     <reg name="r17" bitsize="64" type="int64"/>
> ---
> 
> But I have no clue, it is too late for me to look at GDB source code
> so I'll defer to Zhao / Paolo and revisit after the week-end.

Found this:
https://github.com/intel/gdb/commit/de7fe4e5efa952da2499424f7b70a5d4fad7cf6c

Regards,Akihiko Odaki