Received: from eggs.gnu.org ([2001:4830:134:3::10]:42257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNDht-0000uL-Cb for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNDhn-0007lk-Cu for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:09 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:37648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNDhm-0007kx-QF for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:03 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Aug 2015 15:26:58 +1000 From: Alexey Kardashevskiy Date: Thu, 6 Aug 2015 15:25:56 +1000 Message-Id: <1438838757-32352-2-git-send-email-aik@ozlabs.ru> In-Reply-To: <1438838757-32352-1-git-send-email-aik@ozlabs.ru> References: <1438838757-32352-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH qemu 1/2] monitor: Add CPU class callback to read registers for monitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Markus Armbruster , Alexander Graf , Luiz Capitulino , qemu-ppc@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , David Gibson 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 --- 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: -- 2.4.0.rc3.8.gfb3e7d5