Skip to contentSkip to conversation

gdbstub: Always infer base register index from GDB XML

PATCH Superseded Philippe Mathieu-Daudé 3 participants 14 messages Feb 27 – Mar 4 RISC-V

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover gdbstub: Always infer base register index from GDB XML

Generic fix for a latent bug reported by Florian:
https://lore.kernel.org/qemu-devel/[email protected]/

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(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/4 gdbstub: Have scripts/feature_to_c.py generate more verbose output

Make the structure field names explicit, so it is easier to figure what is what when reviewing multiple entries.

---
 scripts/feature_to_c.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
scripts/feature_to_c.py +8 -5
index 3aa62fb895f..1329695ad04 100644
@@ -85,13 +85,16 @@ def writeliteral(indent, bytes):
     num_regs = max(regnums) - base_reg + 1 if len(regnums) else 0
 
     sys.stdout.write('    {\n')
-    writeliteral(8, bytes(os.path.basename(input), 'utf-8'))
+    sys.stdout.write('        .xmlname = ')
+    writeliteral(0, bytes(os.path.basename(input), 'utf-8'))
     sys.stdout.write(',\n')
-    writeliteral(8, read)
+    sys.stdout.write('        .xml = \n')
+    writeliteral(12, read)
     sys.stdout.write(',\n')
-    writeliteral(8, bytes(feature_name, 'utf-8'))
+    sys.stdout.write('        .name = ')
+    writeliteral(0, bytes(feature_name, 'utf-8'))
     sys.stdout.write(',\n')
-    sys.stdout.write(f'        (const char * const [{num_regs}]) {{\n')
+    sys.stdout.write(f'        .regs = (const char * const [{num_regs}]) {{\n')
 
     for index, regname in enumerate(regnames):
         sys.stdout.write(f'            [{regnums[index] - base_reg}] =\n')
@@ -99,7 +102,7 @@ def writeliteral(indent, bytes):
         sys.stdout.write(',\n')
 
     sys.stdout.write( '        },\n')
-    sys.stdout.write(f'        {num_regs},\n')
+    sys.stdout.write(f'        .num_regs = {num_regs},\n')
     sys.stdout.write( '    },\n')
 
 sys.stdout.write('    { NULL }\n};\n')
Signature · 1 line
2.52.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] gdbstub: Have scripts/feature_to_c.py generate more verbose output

Quoted 8 lines · Philippe Mathieu-Daudé

Make the structure field names explicit, so it is easier to figure what is what when reviewing multiple entries.

---
  scripts/feature_to_c.py | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
#3 lore raw

PATCH 2/4 gdbstub: Make base register explicit in m68k GDB XML files

In reply to Philippe Mathieu-Daudé

Both gdb-xml/cf-fp.xml and gdb-xml/m68k-fp.xml aren't imported from GDB repository. Presumably they are hand-written, and lack the @regnum XML tag.

This might explain why gdb_register_coprocessor() have a @g_pos argument, only used for these 2 m68k files.

Fixes 56aebc89167 ("Add GDB XML register description support")
---
 target/m68k/helper.c | 4 ++--
 gdb-xml/cf-fp.xml    | 2 +-
 gdb-xml/m68k-fp.xml  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
target/m68k/helper.c +2 -2
index 15f110fa7a2..c566cb0a16c 100644
@@ -129,10 +129,10 @@ void m68k_cpu_init_gdb(M68kCPU *cpu)
 
     if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
         gdb_register_coprocessor(cs, cf_fpu_gdb_get_reg, cf_fpu_gdb_set_reg,
-                                 gdb_find_static_feature("cf-fp.xml"), 18);
+                                 gdb_find_static_feature("cf-fp.xml"), 0);
     } else if (m68k_feature(env, M68K_FEATURE_FPU)) {
         gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, m68k_fpu_gdb_set_reg,
-                                 gdb_find_static_feature("m68k-fp.xml"), 18);
+                                 gdb_find_static_feature("m68k-fp.xml"), 0);
     }
     /* TODO: Add [E]MAC registers.  */
 }
gdb-xml/cf-fp.xml +1 -1
index bf71c320bfc..27db66ae963 100644
@@ -6,7 +6,7 @@
      notice and this notice are preserved.  -->
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
 <feature name="org.gnu.gdb.coldfire.fp">
-  <reg name="fp0" bitsize="64" type="float" group="float"/>
+  <reg name="fp0" bitsize="64" type="float" group="float" regnum="18"/>
   <reg name="fp1" bitsize="64" type="float" group="float"/>
   <reg name="fp2" bitsize="64" type="float" group="float"/>
   <reg name="fp3" bitsize="64" type="float" group="float"/>
gdb-xml/m68k-fp.xml +1 -1
index 64290d16306..ec45931b673 100644
@@ -6,7 +6,7 @@
      notice and this notice are preserved.  -->
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
 <feature name="org.gnu.gdb.coldfire.fp">
-  <reg name="fp0" bitsize="96" type="float" group="float"/>
+  <reg name="fp0" bitsize="96" type="float" group="float" regnum="18"/>
   <reg name="fp1" bitsize="96" type="float" group="float"/>
   <reg name="fp2" bitsize="96" type="float" group="float"/>
   <reg name="fp3" bitsize="96" type="float" group="float"/>
Signature · 1 line
2.52.0
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] gdbstub: Make base register explicit in m68k GDB XML files

Quoted 7 lines · Philippe Mathieu-Daudé

Both gdb-xml/cf-fp.xml and gdb-xml/m68k-fp.xml aren't imported from GDB repository. Presumably they are hand-written, and lack the @regnum XML tag.

This might explain why gdb_register_coprocessor() have a @g_pos argument, only used for these 2 m68k files.

Quoted 8 lines
Fixes 56aebc89167 ("Add GDB XML register description support")
---
  target/m68k/helper.c | 4 ++--
  gdb-xml/cf-fp.xml    | 2 +-
  gdb-xml/m68k-fp.xml  | 2 +-
  3 files changed, 4 insertions(+), 4 deletions(-)
#5 lore raw

PATCH 3/4 gdbstub: Emit base_register index in GDBFeature entries

In reply to Philippe Mathieu-Daudé

Record the base register index in the generated C file.

Check at runtime that either @g_pos argument of gdb_register_coprocessor() is zero, or it the base register index.

This change pass 'make check-tcg' test suite, which runs the tests/tcg/multiarch/gdbstub/registers.py test, itself calling gdb_register_coprocessor() for each target tested.

---
 include/exec/gdbstub.h  | 1 +
 gdbstub/gdbstub.c       | 2 ++
 scripts/feature_to_c.py | 1 +
 3 files changed, 4 insertions(+)
include/exec/gdbstub.h +1 -0
index bd7182c4d32..12e7b5b7282 100644
@@ -6,6 +6,7 @@ typedef struct GDBFeature {
     const char *xml;
     const char *name;
     const char * const *regs;
+    int base_reg;
     int num_regs;
 } GDBFeature;
 
gdbstub/gdbstub.c +2 -0
index 90f4b95135b..6eadae3804e 100644
@@ -610,6 +610,8 @@ void gdb_register_coprocessor(CPUState *cpu,
     guint i;
     int base_reg = cpu->gdb_num_regs;
 
+    assert(!g_pos || g_pos == feature->base_reg);
+
     for (i = 0; i < cpu->gdb_regs->len; i++) {
         /* Check for duplicates.  */
         s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
scripts/feature_to_c.py +1 -0
index 1329695ad04..a52cd2e9ec6 100644
@@ -102,6 +102,7 @@ def writeliteral(indent, bytes):
         sys.stdout.write(',\n')
 
     sys.stdout.write( '        },\n')
+    sys.stdout.write(f'        .base_reg = {base_reg},\n')
     sys.stdout.write(f'        .num_regs = {num_regs},\n')
     sys.stdout.write( '    },\n')
 
Signature · 1 line
2.52.0
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] gdbstub: Emit base_register index in GDBFeature entries

Quoted 10 lines · Philippe Mathieu-Daudé

Record the base register index in the generated C file.

Check at runtime that either @g_pos argument of gdb_register_coprocessor() is zero, or it the base register index.

This change pass 'make check-tcg' test suite, which runs the tests/tcg/multiarch/gdbstub/registers.py test, itself calling gdb_register_coprocessor() for each target tested.

Quoted 7 lines
---
  include/exec/gdbstub.h  | 1 +
  gdbstub/gdbstub.c       | 2 ++
  scripts/feature_to_c.py | 1 +
  3 files changed, 4 insertions(+)
#7 lore raw

PATCH 4/4 gdbstub: Remove @g_pos argument in gdb_register_coprocessor()

In reply to Philippe Mathieu-Daudé

gdb_register_coprocessor()'s @g_pos argument is always '0', meaning it is inferred from cpu->gdb_num_regs. Use instead feature->base_reg, but check we don't overwrite other indexed registers.

This fixes a bug with the "power-fpu.xml" file [*] which was loaded at index 70 while the base register is 71. This latent bug was exposed by commit 1ec0fbe2dda ("target/ppc: Fix CPUClass::gdb_num_core_regs value").

[*] https://lore.kernel.org/qemu-devel/[email protected]/

---
 include/exec/gdbstub.h     |  3 +--
 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 ++++--------
 13 files changed, 53 insertions(+), 85 deletions(-)
include/exec/gdbstub.h +1 -2
index 12e7b5b7282..75eb4d9c365 100644
@@ -35,11 +35,10 @@ void gdb_init_cpu(CPUState *cpu);
  * @set_reg - set function (gdb modifying)
  * @num_regs - number of registers in set
  * @xml - xml name of set
- * @gpos - non-zero to append to "general" register set at @gpos
  */
 void gdb_register_coprocessor(CPUState *cpu,
                               gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
-                              const GDBFeature *feature, int g_pos);
+                              const GDBFeature *feature);
 
 /**
  * gdb_unregister_coprocessor_all() - unregisters supplemental set of registers
gdbstub/gdbstub.c +5 -11
index 6eadae3804e..882bc67e182 100644
@@ -604,13 +604,14 @@ void gdb_init_cpu(CPUState *cpu)
 
 void gdb_register_coprocessor(CPUState *cpu,
                               gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
-                              const GDBFeature *feature, int g_pos)
+                              const GDBFeature *feature)
 {
     GDBRegisterState *s;
     guint i;
-    int base_reg = cpu->gdb_num_regs;
+    int base_reg;
 
-    assert(!g_pos || g_pos == feature->base_reg);
+    assert(feature->base_reg >= cpu->gdb_num_regs);
+    base_reg = feature->base_reg;
 
     for (i = 0; i < cpu->gdb_regs->len; i++) {
         /* Check for duplicates.  */
@@ -624,14 +625,7 @@ void gdb_register_coprocessor(CPUState *cpu,
 
     /* Add to end of list.  */
     cpu->gdb_num_regs += feature->num_regs;
-    if (g_pos) {
-        if (g_pos != base_reg) {
-            error_report("Error: Bad gdb register numbering for '%s', "
-                         "expected %d got %d", feature->xml, g_pos, base_reg);
-        } else {
-            cpu->gdb_num_g_regs = cpu->gdb_num_regs;
-        }
-    }
+    cpu->gdb_num_g_regs = cpu->gdb_num_regs;
 }
 
 void gdb_unregister_coprocessor_all(CPUState *cpu)
target/arm/gdbstub.c +8 -13
index c7d59fd3726..d6e29c4cf46 100644
@@ -534,15 +534,13 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
     } else {
         if (arm_feature(env, ARM_FEATURE_NEON)) {
             gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg,
-                                     gdb_find_static_feature("arm-neon.xml"),
-                                     0);
+                                     gdb_find_static_feature("arm-neon.xml"));
         } else if (cpu_isar_feature(aa32_simd_r32, cpu)) {
             gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg,
-                                     gdb_find_static_feature("arm-vfp3.xml"),
-                                     0);
+                                     gdb_find_static_feature("arm-vfp3.xml"));
         } else if (cpu_isar_feature(aa32_vfp_simd, cpu)) {
             gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg,
-                                     gdb_find_static_feature("arm-vfp.xml"), 0);
+                                     gdb_find_static_feature("arm-vfp.xml"));
         }
         if (!arm_feature(env, ARM_FEATURE_M)) {
             /*
@@ -550,29 +548,26 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
              * expose to gdb.
              */
             gdb_register_coprocessor(cs, vfp_gdb_get_sysreg, vfp_gdb_set_sysreg,
-                                     gdb_find_static_feature("arm-vfp-sysregs.xml"),
-                                     0);
+                                     gdb_find_static_feature("arm-vfp-sysregs.xml"));
         }
     }
     if (cpu_isar_feature(aa32_mve, cpu) && tcg_enabled()) {
         gdb_register_coprocessor(cs, mve_gdb_get_reg, mve_gdb_set_reg,
-                                 gdb_find_static_feature("arm-m-profile-mve.xml"),
-                                 0);
+                                 gdb_find_static_feature("arm-m-profile-mve.xml"));
     }
     gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg,
-                             arm_gen_dynamic_sysreg_feature(cs, cs->gdb_num_regs),
-                             0);
+                             arm_gen_dynamic_sysreg_feature(cs, cs->gdb_num_regs));
 
 #ifdef CONFIG_TCG
     if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) {
         gdb_register_coprocessor(cs,
             arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg,
-            arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs), 0);
+            arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs));
 #ifndef CONFIG_USER_ONLY
         if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
             gdb_register_coprocessor(cs,
                 arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg,
-                arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs), 0);
+                arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs));
         }
 #endif
     }
target/arm/gdbstub64.c +7 -12
index b71666c3a1d..a4fa740caf6 100644
@@ -887,24 +887,22 @@ void aarch64_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
         isar_feature_aa64_sme(&cpu->isar)) {
         GDBFeature *feature = arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_regs);
         gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg,
-                                 aarch64_gdb_set_sve_reg, feature, 0);
+                                 aarch64_gdb_set_sve_reg, feature);
     } else {
         gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg,
                                  aarch64_gdb_set_fpu_reg,
-                                 gdb_find_static_feature("aarch64-fpu.xml"),
-                                 0);
+                                 gdb_find_static_feature("aarch64-fpu.xml"));
     }
 
     if (isar_feature_aa64_sme(&cpu->isar)) {
         GDBFeature *sme_feature =
             arm_gen_dynamic_smereg_feature(cs, cs->gdb_num_regs);
         gdb_register_coprocessor(cs, aarch64_gdb_get_sme_reg,
-                                 aarch64_gdb_set_sme_reg, sme_feature, 0);
+                                 aarch64_gdb_set_sme_reg, sme_feature);
         if (isar_feature_aa64_sme2(&cpu->isar)) {
             gdb_register_coprocessor(cs, aarch64_gdb_get_sme2_reg,
                                      aarch64_gdb_set_sme2_reg,
-                                     gdb_find_static_feature("aarch64-sme2.xml"),
-                                     0);
+                                     gdb_find_static_feature("aarch64-sme2.xml"));
         }
     }
     /*
@@ -916,8 +914,7 @@ void aarch64_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
     if (isar_feature_aa64_pauth(&cpu->isar)) {
         gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg,
                                  aarch64_gdb_set_pauth_reg,
-                                 gdb_find_static_feature("aarch64-pauth.xml"),
-                                 0);
+                                 gdb_find_static_feature("aarch64-pauth.xml"));
     }
 
 #ifdef CONFIG_USER_ONLY
@@ -925,14 +922,12 @@ void aarch64_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
     if (cpu_isar_feature(aa64_mte, cpu)) {
         gdb_register_coprocessor(cs, aarch64_gdb_get_tag_ctl_reg,
                                  aarch64_gdb_set_tag_ctl_reg,
-                                 gdb_find_static_feature("aarch64-mte.xml"),
-                                 0);
+                                 gdb_find_static_feature("aarch64-mte.xml"));
     }
 #endif
 
     /* All AArch64 CPUs have at least TPIDR */
     gdb_register_coprocessor(cs, aarch64_gdb_get_tls_reg,
                              aarch64_gdb_set_tls_reg,
-                             arm_gen_dynamic_tls_feature(cs, cs->gdb_num_regs),
-                             0);
+                             arm_gen_dynamic_tls_feature(cs, cs->gdb_num_regs));
 }
target/hexagon/cpu.c +1 -1
index 58a22ee41f2..ffd14bb4678 100644
@@ -322,7 +322,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
 
     gdb_register_coprocessor(cs, hexagon_hvx_gdb_read_register,
                              hexagon_hvx_gdb_write_register,
-                             gdb_find_static_feature("hexagon-hvx.xml"), 0);
+                             gdb_find_static_feature("hexagon-hvx.xml"));
 
     qemu_init_vcpu(cs);
     cpu_reset(cs);
target/i386/gdbstub.c +3 -5
index f1ce90a046e..4e87b67cc13 100644
@@ -503,8 +503,7 @@ void x86_cpu_gdb_init(CPUState *cs)
     if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_APXF) {
         gdb_register_coprocessor(cs, i386_cpu_gdb_get_egprs,
                                  i386_cpu_gdb_set_egprs,
-                                 gdb_find_static_feature("i386-64bit-apx.xml"),
-                                 0);
+                                 gdb_find_static_feature("i386-64bit-apx.xml"));
     }
 #endif
 
@@ -512,10 +511,9 @@ void x86_cpu_gdb_init(CPUState *cs)
     gdb_register_coprocessor(cs, x86_cpu_gdb_read_linux_register,
                              x86_cpu_gdb_write_linux_register,
 #ifdef TARGET_X86_64
-                             gdb_find_static_feature("i386-64bit-linux.xml"),
+                             gdb_find_static_feature("i386-64bit-linux.xml"));
 #else
-                             gdb_find_static_feature("i386-32bit-linux.xml"),
+                             gdb_find_static_feature("i386-32bit-linux.xml"));
 #endif
-                             0);
 #endif
 }
target/loongarch/gdbstub.c +3 -3
index 23a5eecc20b..3e9bdfa8bbf 100644
@@ -180,16 +180,16 @@ void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs)
 
     if (FIELD_EX32(env->cpucfg[2], CPUCFG2, FP)) {
         gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_fpu,
-                                 gdb_find_static_feature("loongarch-fpu.xml"), 0);
+                                 gdb_find_static_feature("loongarch-fpu.xml"));
     }
 
     if (FIELD_EX32(env->cpucfg[2], CPUCFG2, LSX)) {
         gdb_register_coprocessor(cs, loongarch_gdb_get_lsx, loongarch_gdb_set_lsx,
-                                 gdb_find_static_feature("loongarch-lsx.xml"), 0);
+                                 gdb_find_static_feature("loongarch-lsx.xml"));
     }
 
     if (FIELD_EX32(env->cpucfg[2], CPUCFG2, LASX)) {
         gdb_register_coprocessor(cs, loongarch_gdb_get_lasx, loongarch_gdb_set_lasx,
-                                 gdb_find_static_feature("loongarch-lasx.xml"), 0);
+                                 gdb_find_static_feature("loongarch-lasx.xml"));
     }
 }
target/m68k/helper.c +2 -2
index c566cb0a16c..9bab1843892 100644
@@ -129,10 +129,10 @@ void m68k_cpu_init_gdb(M68kCPU *cpu)
 
     if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
         gdb_register_coprocessor(cs, cf_fpu_gdb_get_reg, cf_fpu_gdb_set_reg,
-                                 gdb_find_static_feature("cf-fp.xml"), 0);
+                                 gdb_find_static_feature("cf-fp.xml"));
     } else if (m68k_feature(env, M68K_FEATURE_FPU)) {
         gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, m68k_fpu_gdb_set_reg,
-                                 gdb_find_static_feature("m68k-fp.xml"), 0);
+                                 gdb_find_static_feature("m68k-fp.xml"));
     }
     /* TODO: Add [E]MAC registers.  */
 }
target/microblaze/cpu.c +1 -2
index ae41a1a3287..ec513ae82d4 100644
@@ -265,8 +265,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
 
     gdb_register_coprocessor(cs, mb_cpu_gdb_read_stack_protect,
                              mb_cpu_gdb_write_stack_protect,
-                             gdb_find_static_feature("microblaze-stack-protect.xml"),
-                             0);
+                             gdb_find_static_feature("microblaze-stack-protect.xml"));
 
     qemu_init_vcpu(cs);
 
target/ppc/gdbstub.c +5 -6
index e0aae9c9eaf..4d622c5cad5 100644
@@ -502,24 +502,23 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc)
 {
     if (pcc->insns_flags & PPC_FLOAT) {
         gdb_register_coprocessor(cs, gdb_get_float_reg, gdb_set_float_reg,
-                                 gdb_find_static_feature("power-fpu.xml"), 0);
+                                 gdb_find_static_feature("power-fpu.xml"));
     }
     if (pcc->insns_flags & PPC_ALTIVEC) {
         gdb_register_coprocessor(cs, gdb_get_avr_reg, gdb_set_avr_reg,
-                                 gdb_find_static_feature("power-altivec.xml"),
-                                 0);
+                                 gdb_find_static_feature("power-altivec.xml"));
     }
     if (pcc->insns_flags & PPC_SPE) {
         gdb_register_coprocessor(cs, gdb_get_spe_reg, gdb_set_spe_reg,
-                                 gdb_find_static_feature("power-spe.xml"), 0);
+                                 gdb_find_static_feature("power-spe.xml"));
     }
     if (pcc->insns_flags2 & PPC2_VSX) {
         gdb_register_coprocessor(cs, gdb_get_vsx_reg, gdb_set_vsx_reg,
-                                 gdb_find_static_feature("power-vsx.xml"), 0);
+                                 gdb_find_static_feature("power-vsx.xml"));
     }
 #ifndef CONFIG_USER_ONLY
     gdb_gen_spr_feature(cs);
     gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg,
-                             &pcc->gdb_spr, 0);
+                             &pcc->gdb_spr);
 #endif
 }
target/riscv/gdbstub.c +6 -12
index a053009ccd3..6a5b7a82fd4 100644
@@ -348,32 +348,27 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs)
     CPURISCVState *env = &cpu->env;
     if (env->misa_ext & RVD) {
         gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
-                                 gdb_find_static_feature("riscv-64bit-fpu.xml"),
-                                 0);
+                                 gdb_find_static_feature("riscv-64bit-fpu.xml"));
     } else if (env->misa_ext & RVF) {
         gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
-                                 gdb_find_static_feature("riscv-32bit-fpu.xml"),
-                                 0);
+                                 gdb_find_static_feature("riscv-32bit-fpu.xml"));
     }
     if (cpu->cfg.ext_zve32x) {
         gdb_register_coprocessor(cs, riscv_gdb_get_vector,
                                  riscv_gdb_set_vector,
-                                 ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs),
-                                 0);
+                                 ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs));
     }
     switch (mcc->def->misa_mxl_max) {
     case MXL_RV32:
         gdb_register_coprocessor(cs, riscv_gdb_get_virtual,
                                  riscv_gdb_set_virtual,
-                                 gdb_find_static_feature("riscv-32bit-virtual.xml"),
-                                 0);
+                                 gdb_find_static_feature("riscv-32bit-virtual.xml"));
         break;
     case MXL_RV64:
     case MXL_RV128:
         gdb_register_coprocessor(cs, riscv_gdb_get_virtual,
                                  riscv_gdb_set_virtual,
-                                 gdb_find_static_feature("riscv-64bit-virtual.xml"),
-                                 0);
+                                 gdb_find_static_feature("riscv-64bit-virtual.xml"));
         break;
     default:
         g_assert_not_reached();
@@ -381,7 +376,6 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs)
 
     if (cpu->cfg.ext_zicsr) {
         gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr,
-                                 riscv_gen_dynamic_csr_feature(cs, cs->gdb_num_regs),
-                                 0);
+                                 riscv_gen_dynamic_csr_feature(cs, cs->gdb_num_regs));
     }
 }
target/s390x/gdbstub.c +7 -8
index 9ae715add4d..efdaaefa6d0 100644
@@ -347,34 +347,33 @@ void s390_cpu_gdb_init(CPUState *cs)
 {
     gdb_register_coprocessor(cs, cpu_read_ac_reg,
                              cpu_write_ac_reg,
-                             gdb_find_static_feature("s390-acr.xml"), 0);
+                             gdb_find_static_feature("s390-acr.xml"));
 
     gdb_register_coprocessor(cs, cpu_read_fp_reg,
                              cpu_write_fp_reg,
-                             gdb_find_static_feature("s390-fpr.xml"), 0);
+                             gdb_find_static_feature("s390-fpr.xml"));
 
     gdb_register_coprocessor(cs, cpu_read_vreg,
                              cpu_write_vreg,
-                             gdb_find_static_feature("s390-vx.xml"), 0);
+                             gdb_find_static_feature("s390-vx.xml"));
 
     gdb_register_coprocessor(cs, cpu_read_gs_reg,
                              cpu_write_gs_reg,
-                             gdb_find_static_feature("s390-gs.xml"), 0);
+                             gdb_find_static_feature("s390-gs.xml"));
 
 #ifndef CONFIG_USER_ONLY
     gdb_register_coprocessor(cs, cpu_read_c_reg,
                              cpu_write_c_reg,
-                             gdb_find_static_feature("s390-cr.xml"), 0);
+                             gdb_find_static_feature("s390-cr.xml"));
 
     gdb_register_coprocessor(cs, cpu_read_virt_reg,
                              cpu_write_virt_reg,
-                             gdb_find_static_feature("s390-virt.xml"), 0);
+                             gdb_find_static_feature("s390-virt.xml"));
 
     if (kvm_enabled()) {
         gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg,
                                  cpu_write_virt_kvm_reg,
-                                 gdb_find_static_feature("s390-virt-kvm.xml"),
-                                 0);
+                                 gdb_find_static_feature("s390-virt-kvm.xml"));
     }
 #endif
 }
target/sparc/gdbstub.c +4 -8
index 792bf70a145..2874ce1b350 100644
@@ -271,20 +271,16 @@ void sparc_cpu_register_gdb_regs(CPUState *cs)
 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
     gdb_register_coprocessor(cs, sparc_fpu_gdb_read_register,
                              sparc_fpu_gdb_write_register,
-                             gdb_find_static_feature("sparc32-fpu.xml"),
-                             0);
+                             gdb_find_static_feature("sparc32-fpu.xml"));
     gdb_register_coprocessor(cs, sparc_cp0_gdb_read_register,
                              sparc_cp0_gdb_write_register,
-                             gdb_find_static_feature("sparc32-cp0.xml"),
-                             0);
+                             gdb_find_static_feature("sparc32-cp0.xml"));
 #else
     gdb_register_coprocessor(cs, sparc_fpu_gdb_read_register,
                              sparc_fpu_gdb_write_register,
-                             gdb_find_static_feature("sparc64-fpu.xml"),
-                             0);
+                             gdb_find_static_feature("sparc64-fpu.xml"));
     gdb_register_coprocessor(cs, sparc_cp0_gdb_read_register,
                              sparc_cp0_gdb_write_register,
-                             gdb_find_static_feature("sparc64-cp0.xml"),
-                             0);
+                             gdb_find_static_feature("sparc64-cp0.xml"));
 #endif
 }
Signature · 1 line
2.52.0
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] gdbstub: Remove @g_pos argument in gdb_register_coprocessor()

Quoted 14 lines · Philippe Mathieu-Daudé

gdb_register_coprocessor()'s @g_pos argument is always '0', meaning it is inferred from cpu->gdb_num_regs. Use instead feature->base_reg, but check we don't overwrite other indexed registers.

This fixes a bug with the "power-fpu.xml" file [*] which was loaded at index 70 while the base register is 71. This latent bug was exposed by commit 1ec0fbe2dda ("target/ppc: Fix CPUClass::gdb_num_core_regs value").

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 16 lines
---
  include/exec/gdbstub.h     |  3 +--
  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 ++++--------
  13 files changed, 53 insertions(+), 85 deletions(-)
#9 lore raw

Re: [PATCH 4/4] gdbstub: Remove @g_pos argument in gdb_register_coprocessor()

In reply to Philippe Mathieu-Daudé
Quoted 55 lines · Philippe Mathieu-Daudé

gdb_register_coprocessor()'s @g_pos argument is always '0', meaning it is inferred from cpu->gdb_num_regs. Use instead feature->base_reg, but check we don't overwrite other indexed registers.

This fixes a bug with the "power-fpu.xml" file [*] which was loaded at index 70 while the base register is 71. This latent bug was exposed by commit 1ec0fbe2dda ("target/ppc: Fix CPUClass::gdb_num_core_regs value").

[*] https://lore.kernel.org/qemu-devel/[email protected]/

---
  include/exec/gdbstub.h     |  3 +--
  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 ++++--------
  13 files changed, 53 insertions(+), 85 deletions(-)
include/exec/gdbstub.h +1 -2
index 12e7b5b7282..75eb4d9c365 100644
@@ -35,11 +35,10 @@ void gdb_init_cpu(CPUState *cpu);
   * @set_reg - set function (gdb modifying)
   * @num_regs - number of registers in set
   * @xml - xml name of set
- * @gpos - non-zero to append to "general" register set at @gpos
   */
  void gdb_register_coprocessor(CPUState *cpu,
                                gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
-                              const GDBFeature *feature, int g_pos);
+                              const GDBFeature *feature);
 
  /**
   * gdb_unregister_coprocessor_all() - unregisters supplemental set of registers
gdbstub/gdbstub.c +0 -0
index 6eadae3804e..882bc67e182 100644
@@ -604,13 +604,14 @@ void gdb_init_cpu(CPUState *cpu)
 
  void gdb_register_coprocessor(CPUState *cpu,
                                gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,

gdbstub/gdbstub.c void gdb_init_cpu(CPUState *cpu) · line 613

Quoted 10 lines
gdbstub/gdbstub.c +3 -3
-                              const GDBFeature *feature, int g_pos)
+                              const GDBFeature *feature)
  {
      GDBRegisterState *s;
      guint i;
-    int base_reg = cpu->gdb_num_regs;
+    int base_reg;
 
-    assert(!g_pos || g_pos == feature->base_reg);
+    assert(feature->base_reg >= cpu->gdb_num_regs);

This should be:

+ assert(!feature->base_reg || feature->base_reg >=
cpu->gdb_num_regs);

Quoted 19 lines
gdbstub/gdbstub.c +2 -8
+    base_reg = feature->base_reg;
 
      for (i = 0; i < cpu->gdb_regs->len; i++) {
          /* Check for duplicates.  */
@@ -624,14 +625,7 @@ void gdb_register_coprocessor(CPUState *cpu,
 
      /* Add to end of list.  */
      cpu->gdb_num_regs += feature->num_regs;
-    if (g_pos) {
-        if (g_pos != base_reg) {
-            error_report("Error: Bad gdb register numbering for '%s', "
-                         "expected %d got %d", feature->xml, g_pos, base_reg);
-        } else {
-            cpu->gdb_num_g_regs = cpu->gdb_num_regs;
-        }
-    }
+    cpu->gdb_num_g_regs = cpu->gdb_num_regs;
  }
 
#10 lore raw

Re: [PATCH 4/4] gdbstub: Remove @g_pos argument in gdb_register_coprocessor()

Quoted 66 lines · Philippe Mathieu-Daudé
Quoted 52 lines · Philippe Mathieu-Daudé

gdb_register_coprocessor()'s @g_pos argument is always '0', meaning it is inferred from cpu->gdb_num_regs. Use instead feature->base_reg, but check we don't overwrite other indexed registers.

This fixes a bug with the "power-fpu.xml" file [*] which was loaded at index 70 while the base register is 71. This latent bug was exposed by commit 1ec0fbe2dda ("target/ppc: Fix CPUClass::gdb_num_core_regs value").

[*] https://lore.kernel.org/qemu-devel/e44df309- [email protected]/

---
  include/exec/gdbstub.h     |  3 +-- 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 ++++--------
  13 files changed, 53 insertions(+), 85 deletions(-)
include/exec/gdbstub.h +1 -2
index 12e7b5b7282..75eb4d9c365 100644
@@ -35,11 +35,10 @@ void gdb_init_cpu(CPUState *cpu);
    * @set_reg - set function (gdb modifying)
    * @num_regs - number of registers in set
    * @xml - xml name of set
- * @gpos - non-zero to append to "general" register set at @gpos
    */
   void gdb_register_coprocessor(CPUState *cpu,
                                 gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
-                              const GDBFeature *feature, int g_pos);
+                              const GDBFeature *feature);
   /**
    * gdb_unregister_coprocessor_all() - unregisters supplemental set of registers
gdbstub/gdbstub.c +0 -0
index 6eadae3804e..882bc67e182 100644
@@ -604,13 +604,14 @@ void gdb_init_cpu(CPUState *cpu)
   void gdb_register_coprocessor(CPUState *cpu,

gdbstub/gdbstub.c void gdb_init_cpu(CPUState *cpu) · line 611

Quoted 10 lines
gdbstub/gdbstub.c +3 -3
                                 gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
-                              const GDBFeature *feature, int g_pos)
+                              const GDBFeature *feature)
   {
       GDBRegisterState *s;
       guint i;
-    int base_reg = cpu->gdb_num_regs;
+    int base_reg;
-    assert(!g_pos || g_pos == feature->base_reg);
+    assert(feature->base_reg >= cpu->gdb_num_regs);

This should be:

Quoted 2 lines

  +    assert(!feature->base_reg || feature->base_reg >= cpu-

Quoted 1 line
gdbstub/gdbstub.c +0 -0
 gdb_num_regs);

But still not enough:

https://github.com/philmd/qemu/actions/runs/22658072426/job/65672033735

:(

#11 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 21 lines · Philippe Mathieu-Daudé

Generic fix for a latent bug reported by Florian:
https://lore.kernel.org/qemu-devel/[email protected]/

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 +--
Quoted 9 lines
  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

#12 lore raw

+Zhao/Paolo

Quoted 32 lines · Pierrick Bouvier
Quoted 22 lines · Philippe Mathieu-Daudé

Generic fix for a latent bug reported by Florian:
https://lore.kernel.org/qemu-devel/e44df309- [email protected]/

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 +++++------

Quoted 8 lines
  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(-)
Quoted 2 lines

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 --

gdb-xml/i386-64bit-apx.xml +1 -1
index 11a4ec67cae..34cd501881f 100644
@@ -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.

#13 lore raw
Quoted 62 lines · Philippe Mathieu-Daudé

+Zhao/Paolo

Quoted 32 lines · Pierrick Bouvier
Quoted 22 lines · Philippe Mathieu-Daudé

Generic fix for a latent bug reported by Florian:
https://lore.kernel.org/qemu-devel/e44df309- [email protected]/

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 +++++------

Quoted 8 lines
  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(-)
Quoted 2 lines

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 --

gdb-xml/i386-64bit-apx.xml +1 -2
index 11a4ec67cae..34cd501881f 100644
@@ -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"/>
---
Quoted 2 lines

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