qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: "Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Alexander Graf" <agraf@suse.de>,
	"Luiz Capitulino" <lcapitulino@redhat.com>,
	qemu-ppc@nongnu.org, "Andreas Färber" <afaerber@suse.de>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH qemu 1/2] monitor: Add CPU class callback to read registers for monitor
Date: Thu,  6 Aug 2015 15:25:56 +1000	[thread overview]
Message-ID: <1438838757-32352-2-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1438838757-32352-1-git-send-email-aik@ozlabs.ru>

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 <aik@ozlabs.ru>
---
 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

  reply	other threads:[~2015-08-06  5:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06  5:25 [Qemu-devel] [PATCH qemu 0/2] monitor/ppc: Print correct SPRs Alexey Kardashevskiy
2015-08-06  5:25 ` Alexey Kardashevskiy [this message]
2015-08-12  1:12   ` [Qemu-devel] [PATCH qemu 1/2] monitor: Add CPU class callback to read registers for monitor David Gibson
2015-08-06  5:25 ` [Qemu-devel] [PATCH qemu 2/2] target-ppc: Define get_monitor_def Alexey Kardashevskiy
2015-08-06  6:33   ` Thomas Huth
2015-08-06  7:00     ` Alexey Kardashevskiy
2015-08-06  7:07       ` Thomas Huth
2015-08-12  1:21   ` David Gibson
2015-08-13 15:52     ` [Qemu-devel] [PATCH qemu v2] " Alexey Kardashevskiy
2015-08-13 22:39       ` David Gibson
2015-08-14  3:34         ` [Qemu-devel] [PATCH qemu v3] " Alexey Kardashevskiy
2015-09-07  1:26           ` Alexey Kardashevskiy
2015-09-23  3:40           ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438838757-32352-2-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).