Skip to contentSkip to conversation

monitor/hmp: Automatically handle gdb-xml exposed registers

PATCH In review Philippe Mathieu-Daudé 3 participants 15 messages Feb 16 – Feb 18

lore
Share & tools
lore
#0 lore raw

cover monitor/hmp: Automatically handle gdb-xml exposed registers

MonitorDef registers parsing is one of the oldest APIs in QEMU, thus predates gdbstub and XML register files. The latters are maintained by the GDB/binutils project and are more up-to-date. Getting the target register list from them allows to expose all accessible registers to the HMP commands.

This series adds gdb_get_register() to monitor to use XML generated registers, and remove the legacy MonitorDef entries which became unreachable.

First we need to have the SPARC target better follow the gdb-xml API.

Philippe Mathieu-Daudé (11):
target/sparc: Introduce sparc_cpu_register_gdb_regs() stub target/sparc: Restore 'gdb-xml/sparc64-cp0.xml' target/sparc: Restore 'gdb-xml/sparc64-fpu.xml' target/sparc: Restore 'gdb-xml/sparc64-cpu.xml' target/sparc: Expose gdbstub registers to sparc32plus target target/sparc: Expose gdbstub registers to sparc32 targets monitor/hmp: Handle gdb-xml exposed registers via gdb_get_register() target/sparc: Remove MonitorDef register entries available via gdbstub target/i386: Remove MonitorDef register entries available via gdbstub target/m68k: Remove MonitorDef register entries available via gdbstub target/ppc: Remove MonitorDef register entries available via gdbstub

 configs/targets/sparc-linux-user.mak          |   1 +
 configs/targets/sparc-softmmu.mak             |   1 +
 configs/targets/sparc32plus-linux-user.mak    |   1 +
 configs/targets/sparc64-linux-user.mak        |   2 +-
 configs/targets/sparc64-softmmu.mak           |   2 +-
 target/sparc/cpu.h                            |   1 +
 monitor/hmp.c                                 |  49 ++-
 target/i386/monitor.c                         |  35 ---
 target/m68k/monitor.c                         |  18 --
 target/ppc/ppc-qmp-cmds.c                     |   5 -
 target/sparc/cpu.c                            |   9 +-
 target/sparc/gdbstub.c                        | 295 +++++++++++-------
 target/sparc/monitor.c                        | 107 -------
 gdb-xml/sparc32-cp0.xml                       |  18 ++
 gdb-xml/sparc32-cpu.xml                       |  42 +++
 gdb-xml/sparc32-fpu.xml                       |  42 +++
 gdb-xml/sparc64-cp0.xml                       |  16 +
 gdb-xml/sparc64-cpu.xml                       |  42 +++
 gdb-xml/{sparc64-core.xml => sparc64-fpu.xml} |  44 +--
 19 files changed, 403 insertions(+), 327 deletions(-)
 create mode 100644 gdb-xml/sparc32-cp0.xml
 create mode 100644 gdb-xml/sparc32-cpu.xml
 create mode 100644 gdb-xml/sparc32-fpu.xml
 create mode 100644 gdb-xml/sparc64-cp0.xml
 create mode 100644 gdb-xml/sparc64-cpu.xml
 rename gdb-xml/{sparc64-core.xml => sparc64-fpu.xml} (59%)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/11 target/sparc: Introduce sparc_cpu_register_gdb_regs() stub

Introduce sparc_cpu_register_gdb_regs() which we are going to fill in the next commits.

---
 target/sparc/cpu.h     | 1 +
 target/sparc/cpu.c     | 2 ++
 target/sparc/gdbstub.c | 9 +++++++++
 3 files changed, 12 insertions(+)
target/sparc/cpu.h +1 -0
index 7169a502432..0139732e4cc 100644
@@ -586,6 +586,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
 void sparc_cpu_do_interrupt(CPUState *cpu);
 int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
+void sparc_cpu_register_gdb_regs(CPUState *cs);
 G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                               MMUAccessType access_type,
                                               int mmu_idx,
target/sparc/cpu.c +2 -0
index 3991681d1d1..f58d0298966 100644
@@ -897,6 +897,8 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
         return;
     }
 
+    sparc_cpu_register_gdb_regs(cs);
+
     qemu_init_vcpu(cs);
 
     scc->parent_realize(dev, errp);
target/sparc/gdbstub.c +9 -0
index 134617fb232..79d661fbc10 100644
@@ -215,3 +215,12 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
     return 8;
 #endif
 }
+
+void sparc_cpu_register_gdb_regs(CPUState *cs)
+{
+#if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
+    /* Not yet supported */
+#else
+    /* Not yet supported */
+#endif
+}
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/11 target/sparc: Restore 'gdb-xml/sparc64-cp0.xml'

In reply to Philippe Mathieu-Daudé

Restore gdb-xml/sparc64-cp0.xml from mainstream binutils, tag 'binutils-2_46', found in the gdb/features/sparc/folder [*].

Extract sparc_cp0_gdb_write_register() out of sparc_cpu_gdb_read_register() and sparc_cp0_gdb_write_register() out of sparc_cpu_gdb_write_register(), taking care to update the register indexes in the switch cases.

Register these helpers with a call to gdb_register_coprocessor() in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

---
 configs/targets/sparc64-linux-user.mak |   2 +-
 configs/targets/sparc64-softmmu.mak    |   2 +-
 target/sparc/cpu.c                     |   2 +-
 target/sparc/gdbstub.c                 | 193 ++++++++++++++-----------
 gdb-xml/sparc64-core.xml               |   7 -
 gdb-xml/sparc64-cp0.xml                |  16 ++
 6 files changed, 131 insertions(+), 91 deletions(-)
 create mode 100644 gdb-xml/sparc64-cp0.xml
configs/targets/sparc64-linux-user.mak +1 -1
index 3bbd8495210..930f7e13ab9 100644
@@ -4,6 +4,6 @@ TARGET_ABI_DIR=sparc
 TARGET_SYSTBL_ABI=common,64
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml
+TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-softmmu.mak +1 -1
index 8a0290c2093..22e7f3c94a7 100644
@@ -1,7 +1,7 @@
 TARGET_ARCH=sparc64
 TARGET_BASE_ARCH=sparc
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml
+TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
target/sparc/cpu.c +1 -1
index f58d0298966..6f7b250abb3 100644
@@ -1094,7 +1094,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
 
 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
     cc->gdb_core_xml_file = "sparc64-core.xml";
-    cc->gdb_num_core_regs = 86;
+    cc->gdb_num_core_regs = 80;
 #else
     cc->gdb_num_core_regs = 72;
 #endif
target/sparc/gdbstub.c +112 -81

237 lines not on this page · raw message

gdb-xml/sparc64-core.xml +0 -7
index 375b9bb0cc6..1c26d8c01c1 100644
@@ -89,11 +89,4 @@
   <reg name="f58" bitsize="64" type="ieee_double" regnum="77"/>
   <reg name="f60" bitsize="64" type="ieee_double" regnum="78"/>
   <reg name="f62" bitsize="64" type="ieee_double" regnum="79"/>
-
-  <reg name="pc" bitsize="64" type="code_ptr" regnum="80"/>
-  <reg name="npc" bitsize="64" type="code_ptr" regnum="81"/>
-  <reg name="state" bitsize="64" type="uint64" regnum="82"/>
-  <reg name="fsr" bitsize="64" type="uint64" regnum="83"/>
-  <reg name="fprs" bitsize="64" type="uint64" regnum="84"/>
-  <reg name="y" bitsize="64" type="uint64" regnum="85"/>
 </feature>
gdb-xml/sparc64-cp0.xml new file +16 -0
new file mode 100644
index 00000000000..9b938dc7ecc
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2013-2026 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.sparc.cp0">
+  <reg name="pc" bitsize="64" type="code_ptr" regnum="80"/>
+  <reg name="npc" bitsize="64" type="code_ptr" regnum="81"/>
+  <reg name="state" bitsize="64" type="uint64" regnum="82"/>
+  <reg name="fsr" bitsize="64" type="uint64" regnum="83"/>
+  <reg name="fprs" bitsize="64" type="uint64" regnum="84"/>
+  <reg name="y" bitsize="64" type="uint64" regnum="85"/>
+</feature>
Signature · 1 line
2.52.0
#3 lore raw

PATCH 3/11 target/sparc: Restore 'gdb-xml/sparc64-fpu.xml'

In reply to Philippe Mathieu-Daudé

Restore gdb-xml/sparc64-fpu.xml from mainstream binutils, tag 'binutils-2_46', found in the gdb/features/sparc/folder [*].

Extract sparc_fpu_gdb_write_register() out of sparc_cpu_gdb_read_register() and sparc_fpu_gdb_write_register() out of sparc_cpu_gdb_write_register(), taking care to update the register indexes in the switch cases.

Register these helpers with a call to gdb_register_coprocessor() in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

---
 configs/targets/sparc64-linux-user.mak |  2 +-
 configs/targets/sparc64-softmmu.mak    |  2 +-
 target/sparc/cpu.c                     |  2 +-
 target/sparc/gdbstub.c                 | 88 +++++++++++++++++---------
 gdb-xml/sparc64-core.xml               | 50 ---------------
 gdb-xml/sparc64-fpu.xml                | 59 +++++++++++++++++
 6 files changed, 120 insertions(+), 83 deletions(-)
 create mode 100644 gdb-xml/sparc64-fpu.xml
configs/targets/sparc64-linux-user.mak +1 -1
index 930f7e13ab9..a5f8f8d51a2 100644
@@ -4,6 +4,6 @@ TARGET_ABI_DIR=sparc
 TARGET_SYSTBL_ABI=common,64
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-cp0.xml
+TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-softmmu.mak +1 -1
index 22e7f3c94a7..c35b6b1bb8a 100644
@@ -1,7 +1,7 @@
 TARGET_ARCH=sparc64
 TARGET_BASE_ARCH=sparc
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-cp0.xml
+TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
target/sparc/cpu.c +1 -1
index 6f7b250abb3..2db34d88b97 100644
@@ -1094,7 +1094,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
 
 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
     cc->gdb_core_xml_file = "sparc64-core.xml";
-    cc->gdb_num_core_regs = 80;
+    cc->gdb_num_core_regs = 32;
 #else
     cc->gdb_num_core_regs = 72;
 #endif
target/sparc/gdbstub.c +58 -30

135 lines not on this page · raw message

gdb-xml/sparc64-core.xml +0 -50

54 lines not on this page · raw message

gdb-xml/sparc64-fpu.xml new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.52.0
#4 lore raw

PATCH 4/11 target/sparc: Restore 'gdb-xml/sparc64-cpu.xml'

In reply to Philippe Mathieu-Daudé

Restore gdb-xml/sparc64-cpu.xml from mainstream binutils, tag 'binutils-2_46', found in the gdb/features/sparc/folder [*].

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

---
 configs/targets/sparc64-linux-user.mak        | 2 +-
 configs/targets/sparc64-softmmu.mak           | 2 +-
 target/sparc/cpu.c                            | 2 +-
 gdb-xml/{sparc64-core.xml => sparc64-cpu.xml} | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
 rename gdb-xml/{sparc64-core.xml => sparc64-cpu.xml} (95%)
configs/targets/sparc64-linux-user.mak +1 -1
index a5f8f8d51a2..81d18fcc85b 100644
@@ -4,6 +4,6 @@ TARGET_ABI_DIR=sparc
 TARGET_SYSTBL_ABI=common,64
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
+TARGET_XML_FILES=gdb-xml/sparc64-cpu.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-softmmu.mak +1 -1
index c35b6b1bb8a..602783ef0f6 100644
@@ -1,7 +1,7 @@
 TARGET_ARCH=sparc64
 TARGET_BASE_ARCH=sparc
 TARGET_BIG_ENDIAN=y
-TARGET_XML_FILES=gdb-xml/sparc64-core.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
+TARGET_XML_FILES=gdb-xml/sparc64-cpu.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
target/sparc/cpu.c +1 -1
index 2db34d88b97..08ebbd3640b 100644
@@ -1093,7 +1093,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
     cc->disas_set_info = cpu_sparc_disas_set_info;
 
 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
-    cc->gdb_core_xml_file = "sparc64-core.xml";
+    cc->gdb_core_xml_file = "sparc64-cpu.xml";
     cc->gdb_num_core_regs = 32;
 #else
     cc->gdb_num_core_regs = 72;
gdb-xml/sparc64-cpu.xml renamed from gdb-xml/sparc64-core.xml +2 -2
similarity index 95%
rename from gdb-xml/sparc64-core.xml
rename to gdb-xml/sparc64-cpu.xml
index 85b0820a408..a9bfc95ea65 100644
@@ -1,12 +1,12 @@
 <?xml version="1.0"?>
-<!-- Copyright (C) 2013-2025 Free Software Foundation, Inc.
+<!-- Copyright (C) 2013-2026 Free Software Foundation, Inc.
 
      Copying and distribution of this file, with or without modification,
      are permitted in any medium without royalty provided the copyright
      notice and this notice are preserved.  -->
 
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
-<feature name="org.gnu.gdb.sparc.core">
+<feature name="org.gnu.gdb.sparc.cpu">
   <reg name="g0" bitsize="64" type="uint64" regnum="0"/>
   <reg name="g1" bitsize="64" type="uint64" regnum="1"/>
   <reg name="g2" bitsize="64" type="uint64" regnum="2"/>
Signature · 1 line
2.52.0
#5 lore raw

PATCH 5/11 target/sparc: Expose gdbstub registers to sparc32plus target

In reply to Philippe Mathieu-Daudé
---
 configs/targets/sparc32plus-linux-user.mak | 1 +
 1 file changed, 1 insertion(+)
configs/targets/sparc32plus-linux-user.mak +1 -0
index 3e6c72e793e..cf49c53ce44 100644
@@ -5,5 +5,6 @@ TARGET_ABI_DIR=sparc
 TARGET_SYSTBL_ABI=common,32
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
+TARGET_XML_FILES=gdb-xml/sparc64-cpu.xml gdb-xml/sparc64-fpu.xml gdb-xml/sparc64-cp0.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
Signature · 1 line
2.52.0
#6 lore raw

PATCH 6/11 target/sparc: Expose gdbstub registers to sparc32 targets

In reply to Philippe Mathieu-Daudé

Import gdb-xml/sparc32-{cpu,fpu,cp0}.xml from mainstream binutils, tag 'binutils-2_46', found in the gdb/features/sparc/folder [*].

Register them by setting the CPUClass::gdb_core_xml_file field and calling gdb_register_coprocessor() in sparc_cpu_register_gdb_regs().

[*] https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/features/sparc;hb=refs/tags/binutils-2_46

---
 configs/targets/sparc-linux-user.mak |  1 +
 configs/targets/sparc-softmmu.mak    |  1 +
 target/sparc/cpu.c                   |  3 +-
 target/sparc/gdbstub.c               | 13 +++++----
 gdb-xml/sparc32-cp0.xml              | 18 ++++++++++++
 gdb-xml/sparc32-cpu.xml              | 42 ++++++++++++++++++++++++++++
 gdb-xml/sparc32-fpu.xml              | 42 ++++++++++++++++++++++++++++
 7 files changed, 114 insertions(+), 6 deletions(-)
 create mode 100644 gdb-xml/sparc32-cp0.xml
 create mode 100644 gdb-xml/sparc32-cpu.xml
 create mode 100644 gdb-xml/sparc32-fpu.xml
configs/targets/sparc-linux-user.mak +1 -0
index d3f0716ca2d..01446e28783 100644
@@ -2,5 +2,6 @@ TARGET_ARCH=sparc
 TARGET_SYSTBL_ABI=common,32
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
+TARGET_XML_FILES=gdb-xml/sparc32-cpu.xml gdb-xml/sparc32-fpu.xml gdb-xml/sparc32-cp0.xml
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc-softmmu.mak +1 -0
index c4c38946d54..ed846735f41 100644
@@ -1,5 +1,6 @@
 TARGET_ARCH=sparc
 TARGET_BIG_ENDIAN=y
+TARGET_XML_FILES=gdb-xml/sparc32-cpu.xml gdb-xml/sparc32-fpu.xml gdb-xml/sparc32-cp0.xml
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
target/sparc/cpu.c +2 -1
index 08ebbd3640b..ec454affaad 100644
@@ -1096,7 +1096,8 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
     cc->gdb_core_xml_file = "sparc64-cpu.xml";
     cc->gdb_num_core_regs = 32;
 #else
-    cc->gdb_num_core_regs = 72;
+    cc->gdb_core_xml_file = "sparc32-cpu.xml";
+    cc->gdb_num_core_regs = 32;
 #endif
     cc->tcg_ops = &sparc_tcg_ops;
 }
target/sparc/gdbstub.c +8 -5
index b5b1494950a..ed52e521dcc 100644
@@ -43,7 +43,6 @@ int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     return 0;
 }
 
-__attribute__((unused))
 static int sparc_fpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 {
     CPUSPARCState *env = cpu_env(cs);
@@ -79,7 +78,6 @@ static int sparc_fpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     return 0;
 }
 
-__attribute__((unused))
 static int sparc_cp0_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 {
     CPUSPARCState *env = cpu_env(cs);
@@ -154,7 +152,6 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 #endif
 }
 
-__attribute__((unused))
 static int sparc_fpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUSPARCState *env = cpu_env(cs);
@@ -197,7 +194,6 @@ static int sparc_fpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 #endif
 }
 
-__attribute__((unused))
 static int sparc_cp0_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUSPARCState *env = cpu_env(cs);
@@ -271,7 +267,14 @@ static int sparc_cp0_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 void sparc_cpu_register_gdb_regs(CPUState *cs)
 {
 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
-    /* Not yet supported */
+    gdb_register_coprocessor(cs, sparc_fpu_gdb_read_register,
+                             sparc_fpu_gdb_write_register,
+                             gdb_find_static_feature("sparc32-fpu.xml"),
+                             0);
+    gdb_register_coprocessor(cs, sparc_cp0_gdb_read_register,
+                             sparc_cp0_gdb_write_register,
+                             gdb_find_static_feature("sparc32-cp0.xml"),
+                             0);
 #else
     gdb_register_coprocessor(cs, sparc_fpu_gdb_read_register,
                              sparc_fpu_gdb_write_register,
gdb-xml/sparc32-cp0.xml new file +18 -0
new file mode 100644
index 00000000000..eacd89cf3b5
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2013-2026 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.sparc.cp0">
+  <reg name="y" bitsize="32" type="uint32" regnum="64"/>
+  <reg name="psr" bitsize="32" type="uint32" regnum="65"/>
+  <reg name="wim" bitsize="32" type="uint32" regnum="66"/>
+  <reg name="tbr" bitsize="32" type="uint32" regnum="67"/>
+  <reg name="pc" bitsize="32" type="code_ptr" regnum="68"/>
+  <reg name="npc" bitsize="32" type="code_ptr" regnum="69"/>
+  <reg name="fsr" bitsize="32" type="uint32" regnum="70"/>
+  <reg name="csr" bitsize="32" type="uint32" regnum="71"/>
+</feature>
gdb-xml/sparc32-cpu.xml new file +42 -0

42 lines not on this page · raw message

gdb-xml/sparc32-fpu.xml new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.52.0
#7 lore raw

PATCH 7/11 monitor/hmp: Handle gdb-xml exposed registers via gdb_get_register()

In reply to Philippe Mathieu-Daudé

Implement the gdb_get_register() helper and call it before the regular get_monitor_def() one. Registers is exposed via the GDB XML files will be directly handled, possibily allowing new registers added to XML files to be automatically accessible in QEMU monitor. All targets having GDB XML files can now be used within the monitor.

---
 monitor/hmp.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)
monitor/hmp.c +46 -3
index 0a5bbf82197..0e5913fabb1 100644
@@ -27,14 +27,18 @@
 #include "hw/core/qdev.h"
 #include "monitor-internal.h"
 #include "monitor/hmp.h"
+#include "monitor/hmp-target.h"
 #include "qobject/qdict.h"
 #include "qobject/qnum.h"
+#include "qemu/bswap.h"
 #include "qemu/config-file.h"
 #include "qemu/ctype.h"
 #include "qemu/cutils.h"
 #include "qemu/log.h"
 #include "qemu/option.h"
+#include "qemu/target-info.h"
 #include "qemu/units.h"
+#include "exec/gdbstub.h"
 #include "system/block-backend.h"
 #include "trace.h"
 
@@ -306,6 +310,46 @@ void hmp_help_cmd(Monitor *mon, const char *name)
     free_cmdline_args(args, nb_args);
 }
 
+/*
+ * Set @pval to the value in the register identified by @name.
+ * return %true if the register is found, %false otherwise.
+ */
+static bool gdb_get_register(Monitor *mon, int64_t *pval, const char *name)
+{
+    g_autoptr(GArray) regs = NULL;
+    CPUState *cs = mon_get_cpu(mon);
+
+    if (cs == NULL) {
+        return false;
+    }
+
+    regs = gdb_get_register_list(cs);
+
+    for (int i = 0; i < regs->len; i++) {
+        GDBRegDesc *reg = &g_array_index(regs, GDBRegDesc, i);
+        g_autoptr(GByteArray) buf = NULL;
+        int reg_size;
+
+        if (!reg->name || g_strcmp0(name, reg->name)) {
+            continue;
+        }
+
+        buf = g_byte_array_new();
+        reg_size = gdb_read_register(cs, buf, reg->gdb_reg);
+        if (reg_size > sizeof(*pval)) {
+            return false;
+        }
+
+        if (target_big_endian()) {
+            *pval = ldn_be_p(buf->data, reg_size);
+        } else {
+            *pval = ldn_le_p(buf->data, reg_size);
+        }
+        return true;
+    }
+    return false;
+}
+
 /*******************************************************************/
 
 static const char *pch;
@@ -338,7 +382,6 @@ static int64_t expr_unary(Monitor *mon)
 {
     int64_t n;
     char *p;
-    int ret;
 
     switch (*pch) {
     case '+':
@@ -393,8 +436,8 @@ static int64_t expr_unary(Monitor *mon)
                 pch++;
             }
             *q = 0;
-            ret = get_monitor_def(mon, &reg, buf);
-            if (ret < 0) {
+            if (!gdb_get_register(mon, &reg, buf)
+                && get_monitor_def(mon, &reg, buf) < 0) {
                 expr_error(mon, "unknown register");
             }
             n = reg;
Signature · 1 line
2.52.0
#8 lore raw

Re: [PATCH 07/11] monitor/hmp: Handle gdb-xml exposed registers via gdb_get_register()

Quoted 6 lines · Philippe Mathieu-Daudé

Implement the gdb_get_register() helper and call it before the regular get_monitor_def() one. Registers is exposed via the GDB XML files will be directly handled, possibily allowing new registers added to XML files to be automatically accessible in QEMU monitor. All targets having GDB XML files can now be used within the monitor.

For example with Loongarch, before:

  $ qemu-system-loongarch64 -M virt -S -monitor stdio
  QEMU 10.2.0 monitor - type 'help' for more information

(qemu) info registers

CPU#0
PC=000000001c000000 FCSR0 0x00000000
...

(qemu) p/x $pc
unknown register
Try "help p" for more information
(qemu)

and after:

  $ ./qemu-system-loongarch64 -M virt -S -monitor stdio
  QEMU 10.2.50 monitor - type 'help' for more information
  (qemu) p/x $pc
  0x1c000000
  (qemu)

Similarly RISC-V:

QEMU 10.2.0 monitor - type 'help' for more information (qemu) p/x $pc
unknown register
Try "help p" for more information

VS

QEMU 10.2.50 monitor - type 'help' for more information (qemu) p/x $pc
0x1000
(qemu)

Quoted 5 lines
---
  monitor/hmp.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 46 insertions(+), 3 deletions(-)
Reviewed-by on v1 7/11
#9 lore raw

Re: [PATCH 07/11] monitor/hmp: Handle gdb-xml exposed registers via gdb_get_register()

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:

Implement the gdb_get_register() helper and call it before the regular get_monitor_def() one. Registers is exposed via the GDB XML files will be directly handled, possibily allowing new registers added to XML files to be automatically accessible in QEMU monitor. All targets having GDB XML files can now be used within the monitor.

Nice; I might be tempted to add more checks on the return size of gdb_read_register(..) just in case any arch is a bit screwy (e.g. if they're 0 for example?) - but it should fine.

So for HMP;

Quoted 96 lines
---
 monitor/hmp.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)
monitor/hmp.c +46 -3
index 0a5bbf82197..0e5913fabb1 100644
@@ -27,14 +27,18 @@
 #include "hw/core/qdev.h"
 #include "monitor-internal.h"
 #include "monitor/hmp.h"
+#include "monitor/hmp-target.h"
 #include "qobject/qdict.h"
 #include "qobject/qnum.h"
+#include "qemu/bswap.h"
 #include "qemu/config-file.h"
 #include "qemu/ctype.h"
 #include "qemu/cutils.h"
 #include "qemu/log.h"
 #include "qemu/option.h"
+#include "qemu/target-info.h"
 #include "qemu/units.h"
+#include "exec/gdbstub.h"
 #include "system/block-backend.h"
 #include "trace.h"
 
@@ -306,6 +310,46 @@ void hmp_help_cmd(Monitor *mon, const char *name)
     free_cmdline_args(args, nb_args);
 }
 
+/*
+ * Set @pval to the value in the register identified by @name.
+ * return %true if the register is found, %false otherwise.
+ */
+static bool gdb_get_register(Monitor *mon, int64_t *pval, const char *name)
+{
+    g_autoptr(GArray) regs = NULL;
+    CPUState *cs = mon_get_cpu(mon);
+
+    if (cs == NULL) {
+        return false;
+    }
+
+    regs = gdb_get_register_list(cs);
+
+    for (int i = 0; i < regs->len; i++) {
+        GDBRegDesc *reg = &g_array_index(regs, GDBRegDesc, i);
+        g_autoptr(GByteArray) buf = NULL;
+        int reg_size;
+
+        if (!reg->name || g_strcmp0(name, reg->name)) {
+            continue;
+        }
+
+        buf = g_byte_array_new();
+        reg_size = gdb_read_register(cs, buf, reg->gdb_reg);
+        if (reg_size > sizeof(*pval)) {
+            return false;
+        }
+
+        if (target_big_endian()) {
+            *pval = ldn_be_p(buf->data, reg_size);
+        } else {
+            *pval = ldn_le_p(buf->data, reg_size);
+        }
+        return true;
+    }
+    return false;
+}
+
 /*******************************************************************/
 
 static const char *pch;
@@ -338,7 +382,6 @@ static int64_t expr_unary(Monitor *mon)
 {
     int64_t n;
     char *p;
-    int ret;
 
     switch (*pch) {
     case '+':
@@ -393,8 +436,8 @@ static int64_t expr_unary(Monitor *mon)
                 pch++;
             }
             *q = 0;
-            ret = get_monitor_def(mon, &reg, buf);
-            if (ret < 0) {
+            if (!gdb_get_register(mon, &reg, buf)
+                && get_monitor_def(mon, &reg, buf) < 0) {
                 expr_error(mon, "unknown register");
             }
             n = reg;
Signature · 1 line
2.52.0
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#10 lore raw

PATCH 8/11 target/sparc: Remove MonitorDef register entries available via gdbstub

In reply to Philippe Mathieu-Daudé

All these registers are already provided by via gdbstub parsed XML and handler by the gdb_get_register() helper in the monitor/hmp.c file. Remove as now unreachable code.

---
 target/sparc/monitor.c | 107 -----------------------------------------
 1 file changed, 107 deletions(-)
target/sparc/monitor.c +0 -107
index 73f15aa272d..a60671a60a4 100644
@@ -39,114 +39,8 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
     dump_mmu(env1);
 }
 
-#ifndef TARGET_SPARC64
-static target_long monitor_get_psr(Monitor *mon, const struct MonitorDef *md,
-                                   int val)
-{
-    CPUArchState *env = mon_get_cpu_env(mon);
-
-    return cpu_get_psr(env);
-}
-#endif
-
-static target_long monitor_get_reg(Monitor *mon, const struct MonitorDef *md,
-                                   int val)
-{
-    CPUArchState *env = mon_get_cpu_env(mon);
-    return env->regwptr[val];
-}
-
 const MonitorDef monitor_defs[] = {
-    { "g0", offsetof(CPUSPARCState, gregs[0]) },
-    { "g1", offsetof(CPUSPARCState, gregs[1]) },
-    { "g2", offsetof(CPUSPARCState, gregs[2]) },
-    { "g3", offsetof(CPUSPARCState, gregs[3]) },
-    { "g4", offsetof(CPUSPARCState, gregs[4]) },
-    { "g5", offsetof(CPUSPARCState, gregs[5]) },
-    { "g6", offsetof(CPUSPARCState, gregs[6]) },
-    { "g7", offsetof(CPUSPARCState, gregs[7]) },
-    { "o0", 0, monitor_get_reg },
-    { "o1", 1, monitor_get_reg },
-    { "o2", 2, monitor_get_reg },
-    { "o3", 3, monitor_get_reg },
-    { "o4", 4, monitor_get_reg },
-    { "o5", 5, monitor_get_reg },
-    { "o6", 6, monitor_get_reg },
-    { "o7", 7, monitor_get_reg },
-    { "l0", 8, monitor_get_reg },
-    { "l1", 9, monitor_get_reg },
-    { "l2", 10, monitor_get_reg },
-    { "l3", 11, monitor_get_reg },
-    { "l4", 12, monitor_get_reg },
-    { "l5", 13, monitor_get_reg },
-    { "l6", 14, monitor_get_reg },
-    { "l7", 15, monitor_get_reg },
-    { "i0", 16, monitor_get_reg },
-    { "i1", 17, monitor_get_reg },
-    { "i2", 18, monitor_get_reg },
-    { "i3", 19, monitor_get_reg },
-    { "i4", 20, monitor_get_reg },
-    { "i5", 21, monitor_get_reg },
-    { "i6", 22, monitor_get_reg },
-    { "i7", 23, monitor_get_reg },
-    { "pc", offsetof(CPUSPARCState, pc) },
-    { "npc", offsetof(CPUSPARCState, npc) },
-    { "y", offsetof(CPUSPARCState, y) },
-#ifndef TARGET_SPARC64
-    { "psr", 0, &monitor_get_psr, },
-    { "wim", offsetof(CPUSPARCState, wim) },
-#endif
-    { "tbr", offsetof(CPUSPARCState, tbr) },
-    { "fsr", offsetof(CPUSPARCState, fsr) },
-    { "f0", offsetof(CPUSPARCState, fpr[0].l.upper) },
-    { "f1", offsetof(CPUSPARCState, fpr[0].l.lower) },
-    { "f2", offsetof(CPUSPARCState, fpr[1].l.upper) },
-    { "f3", offsetof(CPUSPARCState, fpr[1].l.lower) },
-    { "f4", offsetof(CPUSPARCState, fpr[2].l.upper) },
-    { "f5", offsetof(CPUSPARCState, fpr[2].l.lower) },
-    { "f6", offsetof(CPUSPARCState, fpr[3].l.upper) },
-    { "f7", offsetof(CPUSPARCState, fpr[3].l.lower) },
-    { "f8", offsetof(CPUSPARCState, fpr[4].l.upper) },
-    { "f9", offsetof(CPUSPARCState, fpr[4].l.lower) },
-    { "f10", offsetof(CPUSPARCState, fpr[5].l.upper) },
-    { "f11", offsetof(CPUSPARCState, fpr[5].l.lower) },
-    { "f12", offsetof(CPUSPARCState, fpr[6].l.upper) },
-    { "f13", offsetof(CPUSPARCState, fpr[6].l.lower) },
-    { "f14", offsetof(CPUSPARCState, fpr[7].l.upper) },
-    { "f15", offsetof(CPUSPARCState, fpr[7].l.lower) },
-    { "f16", offsetof(CPUSPARCState, fpr[8].l.upper) },
-    { "f17", offsetof(CPUSPARCState, fpr[8].l.lower) },
-    { "f18", offsetof(CPUSPARCState, fpr[9].l.upper) },
-    { "f19", offsetof(CPUSPARCState, fpr[9].l.lower) },
-    { "f20", offsetof(CPUSPARCState, fpr[10].l.upper) },
-    { "f21", offsetof(CPUSPARCState, fpr[10].l.lower) },
-    { "f22", offsetof(CPUSPARCState, fpr[11].l.upper) },
-    { "f23", offsetof(CPUSPARCState, fpr[11].l.lower) },
-    { "f24", offsetof(CPUSPARCState, fpr[12].l.upper) },
-    { "f25", offsetof(CPUSPARCState, fpr[12].l.lower) },
-    { "f26", offsetof(CPUSPARCState, fpr[13].l.upper) },
-    { "f27", offsetof(CPUSPARCState, fpr[13].l.lower) },
-    { "f28", offsetof(CPUSPARCState, fpr[14].l.upper) },
-    { "f29", offsetof(CPUSPARCState, fpr[14].l.lower) },
-    { "f30", offsetof(CPUSPARCState, fpr[15].l.upper) },
-    { "f31", offsetof(CPUSPARCState, fpr[15].l.lower) },
 #ifdef TARGET_SPARC64
-    { "f32", offsetof(CPUSPARCState, fpr[16]) },
-    { "f34", offsetof(CPUSPARCState, fpr[17]) },
-    { "f36", offsetof(CPUSPARCState, fpr[18]) },
-    { "f38", offsetof(CPUSPARCState, fpr[19]) },
-    { "f40", offsetof(CPUSPARCState, fpr[20]) },
-    { "f42", offsetof(CPUSPARCState, fpr[21]) },
-    { "f44", offsetof(CPUSPARCState, fpr[22]) },
-    { "f46", offsetof(CPUSPARCState, fpr[23]) },
-    { "f48", offsetof(CPUSPARCState, fpr[24]) },
-    { "f50", offsetof(CPUSPARCState, fpr[25]) },
-    { "f52", offsetof(CPUSPARCState, fpr[26]) },
-    { "f54", offsetof(CPUSPARCState, fpr[27]) },
-    { "f56", offsetof(CPUSPARCState, fpr[28]) },
-    { "f58", offsetof(CPUSPARCState, fpr[29]) },
-    { "f60", offsetof(CPUSPARCState, fpr[30]) },
-    { "f62", offsetof(CPUSPARCState, fpr[31]) },
     { "asi", offsetof(CPUSPARCState, asi) },
     { "pstate", offsetof(CPUSPARCState, pstate) },
     { "cansave", offsetof(CPUSPARCState, cansave) },
@@ -154,7 +48,6 @@ const MonitorDef monitor_defs[] = {
     { "otherwin", offsetof(CPUSPARCState, otherwin) },
     { "wstate", offsetof(CPUSPARCState, wstate) },
     { "cleanwin", offsetof(CPUSPARCState, cleanwin) },
-    { "fprs", offsetof(CPUSPARCState, fprs), NULL, MD_I32 },
 #endif
     { NULL },
 };
Signature · 1 line
2.52.0
#11 lore raw

PATCH 9/11 target/i386: Remove MonitorDef register entries available via gdbstub

In reply to Philippe Mathieu-Daudé

All these registers are already provided by via gdbstub parsed XML and handler by the gdb_get_register() helper in the monitor/hmp.c file. Remove as now unreachable code.

---
 target/i386/monitor.c | 35 -----------------------------------
 1 file changed, 35 deletions(-)
target/i386/monitor.c +0 -35
index 99b32cb7b0f..0660fcabc2f 100644
@@ -605,41 +605,6 @@ const MonitorDef monitor_defs[] = {
     { name, offsetof(CPUX86State, segs[seg].selector), NULL, MD_I32 },\
     { name ".base", offsetof(CPUX86State, segs[seg].base) },\
     { name ".limit", offsetof(CPUX86State, segs[seg].limit), NULL, MD_I32 },
-
-    { "eax", offsetof(CPUX86State, regs[0]) },
-    { "ecx", offsetof(CPUX86State, regs[1]) },
-    { "edx", offsetof(CPUX86State, regs[2]) },
-    { "ebx", offsetof(CPUX86State, regs[3]) },
-    { "esp|sp", offsetof(CPUX86State, regs[4]) },
-    { "ebp|fp", offsetof(CPUX86State, regs[5]) },
-    { "esi", offsetof(CPUX86State, regs[6]) },
-    { "edi", offsetof(CPUX86State, regs[7]) },
-#ifdef TARGET_X86_64
-    { "r8", offsetof(CPUX86State, regs[8]) },
-    { "r9", offsetof(CPUX86State, regs[9]) },
-    { "r10", offsetof(CPUX86State, regs[10]) },
-    { "r11", offsetof(CPUX86State, regs[11]) },
-    { "r12", offsetof(CPUX86State, regs[12]) },
-    { "r13", offsetof(CPUX86State, regs[13]) },
-    { "r14", offsetof(CPUX86State, regs[14]) },
-    { "r15", offsetof(CPUX86State, regs[15]) },
-    { "r16", offsetof(CPUX86State, regs[16]) },
-    { "r17", offsetof(CPUX86State, regs[17]) },
-    { "r18", offsetof(CPUX86State, regs[18]) },
-    { "r19", offsetof(CPUX86State, regs[19]) },
-    { "r20", offsetof(CPUX86State, regs[20]) },
-    { "r21", offsetof(CPUX86State, regs[21]) },
-    { "r22", offsetof(CPUX86State, regs[22]) },
-    { "r23", offsetof(CPUX86State, regs[23]) },
-    { "r24", offsetof(CPUX86State, regs[24]) },
-    { "r25", offsetof(CPUX86State, regs[25]) },
-    { "r26", offsetof(CPUX86State, regs[26]) },
-    { "r27", offsetof(CPUX86State, regs[27]) },
-    { "r28", offsetof(CPUX86State, regs[28]) },
-    { "r29", offsetof(CPUX86State, regs[29]) },
-    { "r30", offsetof(CPUX86State, regs[30]) },
-    { "r31", offsetof(CPUX86State, regs[31]) },
-#endif
     { "eflags", offsetof(CPUX86State, eflags) },
     { "eip", offsetof(CPUX86State, eip) },
     SEG("cs", R_CS)
Signature · 1 line
2.52.0
#12 lore raw

PATCH 10/11 target/m68k: Remove MonitorDef register entries available via gdbstub

In reply to Philippe Mathieu-Daudé

All these registers are already provided by via gdbstub parsed XML and handler by the gdb_get_register() helper in the monitor/hmp.c file. Remove as now unreachable code.

---
 target/m68k/monitor.c | 18 ------------------
 1 file changed, 18 deletions(-)
target/m68k/monitor.c +0 -18
index 6d101c75df0..08ced037b47 100644
@@ -24,24 +24,6 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 }
 
 static const MonitorDef monitor_defs[] = {
-    { "d0", offsetof(CPUM68KState, dregs[0]), NULL, MD_I32 },
-    { "d1", offsetof(CPUM68KState, dregs[1]), NULL, MD_I32 },
-    { "d2", offsetof(CPUM68KState, dregs[2]), NULL, MD_I32 },
-    { "d3", offsetof(CPUM68KState, dregs[3]), NULL, MD_I32 },
-    { "d4", offsetof(CPUM68KState, dregs[4]), NULL, MD_I32 },
-    { "d5", offsetof(CPUM68KState, dregs[5]), NULL, MD_I32 },
-    { "d6", offsetof(CPUM68KState, dregs[6]), NULL, MD_I32 },
-    { "d7", offsetof(CPUM68KState, dregs[7]), NULL, MD_I32 },
-    { "a0", offsetof(CPUM68KState, aregs[0]), NULL, MD_I32 },
-    { "a1", offsetof(CPUM68KState, aregs[1]), NULL, MD_I32 },
-    { "a2", offsetof(CPUM68KState, aregs[2]), NULL, MD_I32 },
-    { "a3", offsetof(CPUM68KState, aregs[3]), NULL, MD_I32 },
-    { "a4", offsetof(CPUM68KState, aregs[4]), NULL, MD_I32 },
-    { "a5", offsetof(CPUM68KState, aregs[5]), NULL, MD_I32 },
-    { "a6", offsetof(CPUM68KState, aregs[6]), NULL, MD_I32 },
-    { "a7", offsetof(CPUM68KState, aregs[7]), NULL, MD_I32 },
-    { "pc", offsetof(CPUM68KState, pc), NULL, MD_I32 },
-    { "sr", offsetof(CPUM68KState, sr), NULL, MD_I32 },
     { "ssp", offsetof(CPUM68KState, sp[0]), NULL, MD_I32 },
     { "usp", offsetof(CPUM68KState, sp[1]), NULL, MD_I32 },
     { "isp", offsetof(CPUM68KState, sp[2]), NULL, MD_I32 },
Signature · 1 line
2.52.0
#13 lore raw

PATCH 11/11 target/ppc: Remove MonitorDef register entries available via gdbstub

In reply to Philippe Mathieu-Daudé

All these registers are already provided by via gdbstub parsed XML and handler by the gdb_get_register() helper in the monitor/hmp.c file. Remove as now unreachable code.

---
 target/ppc/ppc-qmp-cmds.c | 5 -----
 1 file changed, 5 deletions(-)
target/ppc/ppc-qmp-cmds.c +0 -5
index 7022564604f..7dfa78c2e0d 100644
@@ -93,16 +93,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 }
 
 const MonitorDef monitor_defs[] = {
-    { "fpscr", offsetof(CPUPPCState, fpscr) },
     /* Next instruction pointer */
-    { "nip|pc", offsetof(CPUPPCState, nip) },
-    { "lr", offsetof(CPUPPCState, lr) },
-    { "ctr", offsetof(CPUPPCState, ctr) },
     { "decr", 0, &monitor_get_decr, },
     { "ccr|cr", 0, &monitor_get_ccr, },
     /* Machine state register */
     { "xer", 0, &monitor_get_xer },
-    { "msr", offsetof(CPUPPCState, msr) },
     { "tbu", 0, &monitor_get_tbu, },
 #if defined(TARGET_PPC64)
     { "tb", 0, &monitor_get_tbl, },
Signature · 1 line
2.52.0
#14 lore raw

Re: [PATCH 11/11] target/ppc: Remove MonitorDef register entries available via gdbstub

Quoted 14 lines · Philippe Mathieu-Daudé

All these registers are already provided by via gdbstub parsed XML and handler by the gdb_get_register() helper in the monitor/hmp.c file. Remove as now unreachable code.

---
target/ppc/ppc-qmp-cmds.c | 5 -----

1 file changed, 5 deletions(-)
target/ppc/ppc-qmp-cmds.c +0 -0
index 7022564604f..7dfa78c2e0d 100644

target/ppc/ppc-qmp-cmds.c void hmp_info_tlb(Monitor *mon, const QDict *qdict) · line 96

Quoted 5 lines
target/ppc/ppc-qmp-cmds.c +0 -1
@@ -93,16 +93,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 }
 
 const MonitorDef monitor_defs[] = {
-    { "fpscr", offsetof(CPUPPCState, fpscr) },
    /* Next instruction pointer */

This comment should also go as it's for nip removed (nipped? :-) ) from next line.

Regards,
BALATON Zoltan

Quoted 12 lines
target/ppc/ppc-qmp-cmds.c +0 -4
-    { "nip|pc", offsetof(CPUPPCState, nip) },
-    { "lr", offsetof(CPUPPCState, lr) },
-    { "ctr", offsetof(CPUPPCState, ctr) },
    { "decr", 0, &monitor_get_decr, },
    { "ccr|cr", 0, &monitor_get_ccr, },
    /* Machine state register */
    { "xer", 0, &monitor_get_xer },
-    { "msr", offsetof(CPUPPCState, msr) },
    { "tbu", 0, &monitor_get_tbu, },
 #if defined(TARGET_PPC64)
    { "tb", 0, &monitor_get_tbl, },