Allow targets to register their legacy target_get_monitor_def()
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>
---
include/hw/core/sysemu-cpu-ops.h | 8 ++++++++
monitor/hmp.c | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h
index a96f4907d05..a9200ec5737 100644
--- a/include/hw/core/sysemu-cpu-ops.h
+++ b/include/hw/core/sysemu-cpu-ops.h
@@ -85,11 +85,19 @@ typedef struct SysemuCPUOps {
*/
bool (*internal_is_big_endian)(CPUState *cpu);
+ /**
+ * @monitor_get_register: Callback to fill @pval with register @name.
+ * This field is legacy, use @gdb_core_xml_file
+ * to dump registers instead.
+ */
+ int (*monitor_get_register)(CPUState *cs, const char *name, uint64_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 3d812ea3068..799855f3f68 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1632,7 +1632,11 @@ static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
}
}
- ret = target_get_monitor_def(cs, name, &tmp);
+ if (cs->cc->sysemu_ops->monitor_get_register) {
+ ret = cs->cc->sysemu_ops->monitor_get_register(cs, name, &tmp);
+ } else {
+ ret = target_get_monitor_def(cs, name, &tmp);
+ }
if (!ret) {
*pval = target_long_bits() == 32 ? (int32_t)tmp : tmp;
}
--
2.53.0