@samitouri / QOSamiQemu / commits / 57a646e822

cpus: Introduce SysemuCPUOps::monitor_defs hook

Allow targets to register their legacy target_monitor_defs() in SysemuCPUOps; check it first in get_monitor_def() otherwise fall back to previous per-target helper. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260427080738.77138-27-philmd@linaro.org>

Philippe Mathieu-Daudé committed Mar 20, 2026 at 14:13 UTC 57a646e8227b804a2f9d6eb5bb6b3fd2b838252d
2 files changed +12 -2
include/hw/core/sysemu-cpu-ops.h
+6
@@ -93,6 +93,12 @@ typedef struct SysemuCPUOps {
93 */
94 int (*monitor_get_register)(CPUState *cs, const char *name, int64_t *pval);
95
96 + /**
97 + * @monitor_defs: Array of MonitorDef entries. This field is legacy,
98 + * use @gdb_core_xml_file to dump registers instead.
99 + */
100 + const MonitorDef *monitor_defs;
101 +
102 /**
103 * @legacy_vmsd: Legacy state for migration.
104 * Do not use in new targets, use #DeviceClass::vmsd instead.
monitor/hmp.c
+6 -2
@@ -1608,11 +1608,15 @@ void monitor_register_hmp_info_hrt(const char *name,
1608 */
1609 static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
1610 {
1611 - const MonitorDef *md = target_monitor_defs();
1611 CPUState *cs = mon_get_cpu(mon);
1612 + const MonitorDef *md;
1613 void *ptr;
1614
1615 - if (cs == NULL || md == NULL) {
1615 + if (cs == NULL) {
1616 + return -1;
1617 + }
1618 + md = cs->cc->sysemu_ops->monitor_defs ?: target_monitor_defs();
1619 + if (md == NULL) {
1620 return -1;
1621 }
1622