[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH qemu 1/2] monitor: Add CPU class callback to read
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH qemu 1/2] monitor: Add CPU class callback to read registers for monitor |
Date: |
Wed, 12 Aug 2015 11:12:04 +1000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Aug 06, 2015 at 03:25:56PM +1000, Alexey Kardashevskiy wrote:
> At the moment the monitor only prints registers from monitor_defs.
> Some may not be supported but it will print those anyway, other
> may be missing in the list so monitor_defs needs an update every time
> new register is added.
>
> This defines a CPUClass callback to read various registers from CPU.
>
> Next patch makes use of it.
>
> Signed-off-by: Alexey Kardashevskiy <address@hidden>
Reviewed-by: David Gibson <address@hidden>
> ---
> include/qom/cpu.h | 1 +
> monitor.c | 14 +++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 20aabc9..fcf981f 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -144,6 +144,7 @@ typedef struct CPUClass {
> int flags);
> void (*dump_statistics)(CPUState *cpu, FILE *f,
> fprintf_function cpu_fprintf, int flags);
> + int (*get_monitor_def)(CPUState *cs, const char *name, uint64_t *pval);
> int64_t (*get_arch_id)(CPUState *cpu);
> bool (*get_paging_enabled)(const CPUState *cpu);
> void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
> diff --git a/monitor.c b/monitor.c
> index aeea2b5..bdfcacc 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3303,13 +3303,25 @@ static int get_monitor_def(target_long *pval, const
> char *name)
> {
> const MonitorDef *md;
> void *ptr;
> + CPUState *cs = mon_get_cpu();
> + CPUClass *cc = CPU_GET_CLASS(cs);
> +
> + if (cc->get_monitor_def) {
> + uint64_t tmp = 0;
> + int ret = cc->get_monitor_def(cs, name, &tmp);
> +
> + if (!ret) {
> + *pval = (target_long) tmp;
> + }
> + return ret;
> + }
>
> for(md = monitor_defs; md->name != NULL; md++) {
> if (compare_cmd(name, md->name)) {
> if (md->get_value) {
> *pval = md->get_value(md, md->offset);
> } else {
> - CPUArchState *env = mon_get_cpu_env();
> + CPUArchState *env = cs->env_ptr;
> ptr = (uint8_t *)env + md->offset;
> switch(md->type) {
> case MD_I32:
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
pgpGEmNriGuPM.pgp
Description: PGP signature