cpus: Introduce SysemuCPUOps::monitor_get_register() hook

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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260427080738.77138-20-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé
2026-03-20 14:17:18 +01:00
parent bb1573600b
commit 25e28a7fa1
2 changed files with 16 additions and 3 deletions

View File

@@ -85,6 +85,14 @@ typedef struct SysemuCPUOps {
*/
bool (*internal_is_big_endian)(CPUState *cpu);
/**
* @monitor_get_register: Callback to fill @pval with register @name value.
* This field is legacy, use @gdb_core_xml_file
* to dump registers instead.
* Returns: 0 on success or negative errno on failure.
*/
int (*monitor_get_register)(CPUState *cs, const char *name, int64_t *pval);
/**
* @legacy_vmsd: Legacy state for migration.
* Do not use in new targets, use #DeviceClass::vmsd instead.

View File

@@ -35,6 +35,7 @@
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-machine.h"
#include "hw/core/sysemu-cpu-ops.h"
/* Make devices configuration available for use in hmp-commands*.hx templates */
#include CONFIG_DEVICES
@@ -85,9 +86,13 @@ int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
}
}
ret = target_get_monitor_def(cs, name, &tmp);
if (!ret) {
*pval = (target_long) tmp;
if (cs->cc->sysemu_ops->monitor_get_register) {
ret = cs->cc->sysemu_ops->monitor_get_register(cs, name, pval);
} else {
ret = target_get_monitor_def(cs, name, &tmp);
if (!ret) {
*pval = (target_long) tmp;
}
}
return ret;