Allow targets to register their legacy target_get_monitor_def()
in CPUClass; 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/cpu.h | 5 +++++
monitor/hmp.c | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 072f58bead5..8f9d62bfafb 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -150,6 +150,9 @@ struct SysemuCPUOps;
* CPUState::cpu_ases.
* @legacy_monitor_defs: Array of MonitorDef entries. This field is legacy,
* use @gdb_core_xml_file to dump registers instead.
+ * @legacy_monitor_get_register: Callback to fill @pval with register @name.
+ * This field is legacy, use @gdb_core_xml_file
+ * to dump registers instead.
*
* Represents a CPU family or model.
*/
@@ -177,6 +180,8 @@ struct CPUClass {
const char * (*gdb_arch_name)(CPUState *cpu);
const char * (*gdb_get_core_xml_file)(CPUState *cpu);
const MonitorDef *legacy_monitor_defs;
+ int (*legacy_monitor_get_register)(CPUState *cs, const char *name,
+ uint64_t *pval);
void (*disas_set_info)(const CPUState *cpu, disassemble_info *info);
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 6dfc59725c2..ad253347892 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1628,7 +1628,11 @@ int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
}
}
- ret = target_get_monitor_def(cs, name, &tmp);
+ if (cs->cc->legacy_monitor_get_register) {
+ ret = cs->cc->legacy_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