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é <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> --- include/hw/core/sysemu-cpu-ops.h | 6 ++++++ monitor/hmp.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h index 5b831393cf4..94e36ecdd18 100644 --- a/include/hw/core/sysemu-cpu-ops.h +++ b/include/hw/core/sysemu-cpu-ops.h @@ -93,6 +93,12 @@ typedef struct SysemuCPUOps { */ int (*monitor_get_register)(CPUState *cs, const char *name, int64_t *pval); + /** + * @monitor_defs: Array of MonitorDef entries. This field is legacy, + * use @gdb_core_xml_file to dump registers instead. + */ + const MonitorDef *monitor_defs; + /** * @legacy_vmsd: Legacy state for migration. * Do not use in new targets, use #DeviceClass::vmsd instead. diff --git a/monitor/hmp.c b/monitor/hmp.c index 02e9d72e672..ad8b0d1a72e 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1608,11 +1608,15 @@ void monitor_register_hmp_info_hrt(const char *name, */ static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name) { - const MonitorDef *md = target_monitor_defs(); CPUState *cs = mon_get_cpu(mon); + const MonitorDef *md; void *ptr; - if (cs == NULL || md == NULL) { + if (cs == NULL) { + return -1; + } + md = cs->cc->sysemu_ops->monitor_defs ?: target_monitor_defs(); + if (md == NULL) { return -1; } -- 2.53.0
