diff mbox series

[v2,62/76] target/microblaze: Tidy mb_cpu_dump_state

Message ID 20200828141929.77854-63-richard.henderson@linaro.org
State Superseded
Headers show
Series target/microblaze improvements | expand

Commit Message

Richard Henderson Aug. 28, 2020, 2:19 p.m. UTC
Using lookup_symbol is quite slow; remove that.  Decode the
various bits of iflags; only show imm, btaken, btarget when
they are relevant to iflags.  Improve formatting.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/microblaze/translate.c | 67 +++++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 26 deletions(-)

-- 
2.25.1

Comments

Philippe Mathieu-Daudé Aug. 31, 2020, 9:08 p.m. UTC | #1
Hi Richard,

Le ven. 28 août 2020 16:46, Richard Henderson <richard.henderson@linaro.org>
a écrit :

> Using lookup_symbol is quite slow; remove that.  Decode the

>


Can we add some runtime option to enable its use instead?

various bits of iflags; only show imm, btaken, btarget when
> they are relevant to iflags.  Improve formatting.

>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  target/microblaze/translate.c | 67 +++++++++++++++++++++--------------

>  1 file changed, 41 insertions(+), 26 deletions(-)

>

> diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c

> index 811c92d23b..3b63fd79e5 100644

> --- a/target/microblaze/translate.c

> +++ b/target/microblaze/translate.c

> @@ -1818,41 +1818,56 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, int

> flags)

>  {

>      MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);

>      CPUMBState *env = &cpu->env;

> +    uint32_t iflags;

>      int i;

>

> -    if (!env) {

> -        return;

> -    }

> -

> -    qemu_fprintf(f, "IN: PC=%x %s\n",

> -                 env->pc, lookup_symbol(env->pc));

> -    qemu_fprintf(f, "rmsr=%x resr=%x rear=%" PRIx64 " "

> -                 "imm=%x iflags=%x fsr=%x rbtr=%x\n",

> -                 env->msr, env->esr, env->ear,

> -                 env->imm, env->iflags, env->fsr, env->btr);

> -    qemu_fprintf(f, "btaken=%d btarget=%x mode=%s(saved=%s) eip=%d

> ie=%d\n",

> -                 env->btaken, env->btarget,

> +    qemu_fprintf(f, "pc=0x%08x msr=0x%05x mode=%s(saved=%s) eip=%d

> ie=%d\n",

> +                 env->pc, env->msr,

>                   (env->msr & MSR_UM) ? "user" : "kernel",

>                   (env->msr & MSR_UMS) ? "user" : "kernel",

>                   (bool)(env->msr & MSR_EIP),

>                   (bool)(env->msr & MSR_IE));

> -    for (i = 0; i < 12; i++) {

> -        qemu_fprintf(f, "rpvr%2.2d=%8.8x ", i, env->pvr.regs[i]);

> -        if ((i + 1) % 4 == 0) {

> -            qemu_fprintf(f, "\n");

> -        }

> +

> +    iflags = env->iflags;

> +    qemu_fprintf(f, "iflags: 0x%08x", iflags);

> +    if (iflags & IMM_FLAG) {

> +        qemu_fprintf(f, " IMM(0x%08x)", env->imm);

> +    }

> +    if (iflags & BIMM_FLAG) {

> +        qemu_fprintf(f, " BIMM");

> +    }

> +    if (iflags & D_FLAG) {

> +        qemu_fprintf(f, " D(btaken=%d btarget=0x%08x)",

> +                     env->btaken, env->btarget);

> +    }

> +    if (iflags & DRTI_FLAG) {

> +        qemu_fprintf(f, " DRTI");

> +    }

> +    if (iflags & DRTE_FLAG) {

> +        qemu_fprintf(f, " DRTE");

> +    }

> +    if (iflags & DRTB_FLAG) {

> +        qemu_fprintf(f, " DRTB");

> +    }

> +    if (iflags & ESR_ESS_FLAG) {

> +        qemu_fprintf(f, " ESR_ESS(0x%04x)", iflags & ESR_ESS_MASK);

> +    }

> +

> +    qemu_fprintf(f, "\nesr=0x%04x fsr=0x%02x btr=0x%08x edr=0x%x\n"

> +                 "ear=0x%016" PRIx64 " slr=0x%x shr=0x%x\n",

> +                 env->esr, env->fsr, env->btr, env->edr,

> +                 env->ear, env->slr, env->shr);

> +

> +    for (i = 0; i < 12; i++) {

> +        qemu_fprintf(f, "rpvr%-2d=%08x%c",

> +                     i, env->pvr.regs[i], i % 4 == 3 ? '\n' : ' ');

>      }

>

> -    /* Registers that aren't modeled are reported as 0 */

> -    qemu_fprintf(f, "redr=%x rpid=0 rzpr=0 rtlbx=0 rtlbsx=0 "

> -                    "rtlblo=0 rtlbhi=0\n", env->edr);

> -    qemu_fprintf(f, "slr=%x shr=%x\n", env->slr, env->shr);

>      for (i = 0; i < 32; i++) {

> -        qemu_fprintf(f, "r%2.2d=%8.8x ", i, env->regs[i]);

> -        if ((i + 1) % 4 == 0)

> -            qemu_fprintf(f, "\n");

> -        }

> -    qemu_fprintf(f, "\n\n");

> +        qemu_fprintf(f, "r%2.2d=%08x%c",

> +                     i, env->regs[i], i % 4 == 3 ? '\n' : ' ');

> +    }

> +    qemu_fprintf(f, "\n");

>  }

>

>  void mb_tcg_init(void)

> --

> 2.25.1

>

>

>
<div dir="auto"><div>Hi Richard, <br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 28 août 2020 16:46, Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>&gt; a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Using lookup_symbol is quite slow; remove that.  Decode the<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Can we add some runtime option to enable its use instead?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
various bits of iflags; only show imm, btaken, btarget when<br>
they are relevant to iflags.  Improve formatting.<br>
<br>
Signed-off-by: Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org" target="_blank" rel="noreferrer">richard.henderson@linaro.org</a>&gt;<br>

---<br>
 target/microblaze/translate.c | 67 +++++++++++++++++++++--------------<br>
 1 file changed, 41 insertions(+), 26 deletions(-)<br>
<br>
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c<br>
index 811c92d23b..3b63fd79e5 100644<br>
--- a/target/microblaze/translate.c<br>
+++ b/target/microblaze/translate.c<br>
@@ -1818,41 +1818,56 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags)<br>
 {<br>
     MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);<br>
     CPUMBState *env = &amp;cpu-&gt;env;<br>
+    uint32_t iflags;<br>
     int i;<br>
<br>
-    if (!env) {<br>
-        return;<br>
-    }<br>
-<br>
-    qemu_fprintf(f, &quot;IN: PC=%x %s\n&quot;,<br>
-                 env-&gt;pc, lookup_symbol(env-&gt;pc));<br>
-    qemu_fprintf(f, &quot;rmsr=%x resr=%x rear=%&quot; PRIx64 &quot; &quot;<br>
-                 &quot;imm=%x iflags=%x fsr=%x rbtr=%x\n&quot;,<br>
-                 env-&gt;msr, env-&gt;esr, env-&gt;ear,<br>
-                 env-&gt;imm, env-&gt;iflags, env-&gt;fsr, env-&gt;btr);<br>
-    qemu_fprintf(f, &quot;btaken=%d btarget=%x mode=%s(saved=%s) eip=%d ie=%d\n&quot;,<br>
-                 env-&gt;btaken, env-&gt;btarget,<br>
+    qemu_fprintf(f, &quot;pc=0x%08x msr=0x%05x mode=%s(saved=%s) eip=%d ie=%d\n&quot;,<br>
+                 env-&gt;pc, env-&gt;msr,<br>
                  (env-&gt;msr &amp; MSR_UM) ? &quot;user&quot; : &quot;kernel&quot;,<br>
                  (env-&gt;msr &amp; MSR_UMS) ? &quot;user&quot; : &quot;kernel&quot;,<br>
                  (bool)(env-&gt;msr &amp; MSR_EIP),<br>
                  (bool)(env-&gt;msr &amp; MSR_IE));<br>
-    for (i = 0; i &lt; 12; i++) {<br>
-        qemu_fprintf(f, &quot;rpvr%2.2d=%8.8x &quot;, i, env-&gt;pvr.regs[i]);<br>
-        if ((i + 1) % 4 == 0) {<br>
-            qemu_fprintf(f, &quot;\n&quot;);<br>
-        }<br>
+<br>
+    iflags = env-&gt;iflags;<br>
+    qemu_fprintf(f, &quot;iflags: 0x%08x&quot;, iflags);<br>
+    if (iflags &amp; IMM_FLAG) {<br>
+        qemu_fprintf(f, &quot; IMM(0x%08x)&quot;, env-&gt;imm);<br>
+    }<br>
+    if (iflags &amp; BIMM_FLAG) {<br>
+        qemu_fprintf(f, &quot; BIMM&quot;);<br>
+    }<br>
+    if (iflags &amp; D_FLAG) {<br>
+        qemu_fprintf(f, &quot; D(btaken=%d btarget=0x%08x)&quot;,<br>
+                     env-&gt;btaken, env-&gt;btarget);<br>
+    }<br>
+    if (iflags &amp; DRTI_FLAG) {<br>
+        qemu_fprintf(f, &quot; DRTI&quot;);<br>
+    }<br>
+    if (iflags &amp; DRTE_FLAG) {<br>
+        qemu_fprintf(f, &quot; DRTE&quot;);<br>
+    }<br>
+    if (iflags &amp; DRTB_FLAG) {<br>
+        qemu_fprintf(f, &quot; DRTB&quot;);<br>
+    }<br>
+    if (iflags &amp; ESR_ESS_FLAG) {<br>
+        qemu_fprintf(f, &quot; ESR_ESS(0x%04x)&quot;, iflags &amp; ESR_ESS_MASK);<br>
+    }<br>
+<br>
+    qemu_fprintf(f, &quot;\nesr=0x%04x fsr=0x%02x btr=0x%08x edr=0x%x\n&quot;<br>
+                 &quot;ear=0x%016&quot; PRIx64 &quot; slr=0x%x shr=0x%x\n&quot;,<br>
+                 env-&gt;esr, env-&gt;fsr, env-&gt;btr, env-&gt;edr,<br>
+                 env-&gt;ear, env-&gt;slr, env-&gt;shr);<br>
+<br>
+    for (i = 0; i &lt; 12; i++) {<br>
+        qemu_fprintf(f, &quot;rpvr%-2d=%08x%c&quot;,<br>
+                     i, env-&gt;pvr.regs[i], i % 4 == 3 ? &#39;\n&#39; : &#39; &#39;);<br>
     }<br>
<br>
-    /* Registers that aren&#39;t modeled are reported as 0 */<br>
-    qemu_fprintf(f, &quot;redr=%x rpid=0 rzpr=0 rtlbx=0 rtlbsx=0 &quot;<br>
-                    &quot;rtlblo=0 rtlbhi=0\n&quot;, env-&gt;edr);<br>
-    qemu_fprintf(f, &quot;slr=%x shr=%x\n&quot;, env-&gt;slr, env-&gt;shr);<br>
     for (i = 0; i &lt; 32; i++) {<br>
-        qemu_fprintf(f, &quot;r%2.2d=%8.8x &quot;, i, env-&gt;regs[i]);<br>
-        if ((i + 1) % 4 == 0)<br>
-            qemu_fprintf(f, &quot;\n&quot;);<br>
-        }<br>
-    qemu_fprintf(f, &quot;\n\n&quot;);<br>
+        qemu_fprintf(f, &quot;r%2.2d=%08x%c&quot;,<br>
+                     i, env-&gt;regs[i], i % 4 == 3 ? &#39;\n&#39; : &#39; &#39;);<br>
+    }<br>
+    qemu_fprintf(f, &quot;\n&quot;);<br>
 }<br>
<br>
 void mb_tcg_init(void)<br>
-- <br>
2.25.1<br>
<br>
<br>
</blockquote></div></div></div>
Richard Henderson Aug. 31, 2020, 10:16 p.m. UTC | #2
On 8/31/20 2:08 PM, Philippe Mathieu-Daudé wrote:
> Hi Richard, 

> 

> Le ven. 28 août 2020 16:46, Richard Henderson <richard.henderson@linaro.org

> <mailto:richard.henderson@linaro.org>> a écrit :

> 

>     Using lookup_symbol is quite slow; remove that.  Decode the

> 

> 

> Can we add some runtime option to enable its use instead?


We do the lookup with -d in_asm.
Do we really need it with -d cpu as well?

The -d cpu can be called many millions of times more than -d in_asm, and the
two are relatively easy to correlate.


r~
Philippe Mathieu-Daudé Aug. 31, 2020, 10:25 p.m. UTC | #3
Le mar. 1 sept. 2020 00:16, Richard Henderson <richard.henderson@linaro.org>
a écrit :

> On 8/31/20 2:08 PM, Philippe Mathieu-Daudé wrote:

> > Hi Richard,

> >

> > Le ven. 28 août 2020 16:46, Richard Henderson <

> richard.henderson@linaro.org

> > <mailto:richard.henderson@linaro.org>> a écrit :

> >

> >     Using lookup_symbol is quite slow; remove that.  Decode the

> >

> >

> > Can we add some runtime option to enable its use instead?

>

> We do the lookup with -d in_asm.

> Do we really need it with -d cpu as well?

>

> The -d cpu can be called many millions of times more than -d in_asm, and

> the

> two are relatively easy to correlate.

>


Ah I missed that. This is fine then!

Thanks,

Phil.


>

> r~

>
<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 1 sept. 2020 00:16, Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>&gt; a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 8/31/20 2:08 PM, Philippe Mathieu-Daudé wrote:<br>
&gt; Hi Richard, <br>
&gt; <br>
&gt; Le ven. 28 août 2020 16:46, Richard Henderson &lt;<a href="mailto:richard.henderson@linaro.org" target="_blank" rel="noreferrer">richard.henderson@linaro.org</a><br>
&gt; &lt;mailto:<a href="mailto:richard.henderson@linaro.org" target="_blank" rel="noreferrer">richard.henderson@linaro.org</a>&gt;&gt; a écrit :<br>
&gt; <br>
&gt;     Using lookup_symbol is quite slow; remove that.  Decode the<br>
&gt; <br>
&gt; <br>
&gt; Can we add some runtime option to enable its use instead?<br>
<br>
We do the lookup with -d in_asm.<br>
Do we really need it with -d cpu as well?<br>
<br>
The -d cpu can be called many millions of times more than -d in_asm, and the<br>
two are relatively easy to correlate.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Ah I missed that. This is fine then!</div><div dir="auto"><br></div><div dir="auto">Thanks, </div><div dir="auto"><br></div><div dir="auto">Phil.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
r~<br>
</blockquote></div></div></div>
diff mbox series

Patch

diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 811c92d23b..3b63fd79e5 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -1818,41 +1818,56 @@  void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags)
 {
     MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
     CPUMBState *env = &cpu->env;
+    uint32_t iflags;
     int i;
 
-    if (!env) {
-        return;
-    }
-
-    qemu_fprintf(f, "IN: PC=%x %s\n",
-                 env->pc, lookup_symbol(env->pc));
-    qemu_fprintf(f, "rmsr=%x resr=%x rear=%" PRIx64 " "
-                 "imm=%x iflags=%x fsr=%x rbtr=%x\n",
-                 env->msr, env->esr, env->ear,
-                 env->imm, env->iflags, env->fsr, env->btr);
-    qemu_fprintf(f, "btaken=%d btarget=%x mode=%s(saved=%s) eip=%d ie=%d\n",
-                 env->btaken, env->btarget,
+    qemu_fprintf(f, "pc=0x%08x msr=0x%05x mode=%s(saved=%s) eip=%d ie=%d\n",
+                 env->pc, env->msr,
                  (env->msr & MSR_UM) ? "user" : "kernel",
                  (env->msr & MSR_UMS) ? "user" : "kernel",
                  (bool)(env->msr & MSR_EIP),
                  (bool)(env->msr & MSR_IE));
-    for (i = 0; i < 12; i++) {
-        qemu_fprintf(f, "rpvr%2.2d=%8.8x ", i, env->pvr.regs[i]);
-        if ((i + 1) % 4 == 0) {
-            qemu_fprintf(f, "\n");
-        }
+
+    iflags = env->iflags;
+    qemu_fprintf(f, "iflags: 0x%08x", iflags);
+    if (iflags & IMM_FLAG) {
+        qemu_fprintf(f, " IMM(0x%08x)", env->imm);
+    }
+    if (iflags & BIMM_FLAG) {
+        qemu_fprintf(f, " BIMM");
+    }
+    if (iflags & D_FLAG) {
+        qemu_fprintf(f, " D(btaken=%d btarget=0x%08x)",
+                     env->btaken, env->btarget);
+    }
+    if (iflags & DRTI_FLAG) {
+        qemu_fprintf(f, " DRTI");
+    }
+    if (iflags & DRTE_FLAG) {
+        qemu_fprintf(f, " DRTE");
+    }
+    if (iflags & DRTB_FLAG) {
+        qemu_fprintf(f, " DRTB");
+    }
+    if (iflags & ESR_ESS_FLAG) {
+        qemu_fprintf(f, " ESR_ESS(0x%04x)", iflags & ESR_ESS_MASK);
+    }
+
+    qemu_fprintf(f, "\nesr=0x%04x fsr=0x%02x btr=0x%08x edr=0x%x\n"
+                 "ear=0x%016" PRIx64 " slr=0x%x shr=0x%x\n",
+                 env->esr, env->fsr, env->btr, env->edr,
+                 env->ear, env->slr, env->shr);
+
+    for (i = 0; i < 12; i++) {
+        qemu_fprintf(f, "rpvr%-2d=%08x%c",
+                     i, env->pvr.regs[i], i % 4 == 3 ? '\n' : ' ');
     }
 
-    /* Registers that aren't modeled are reported as 0 */
-    qemu_fprintf(f, "redr=%x rpid=0 rzpr=0 rtlbx=0 rtlbsx=0 "
-                    "rtlblo=0 rtlbhi=0\n", env->edr);
-    qemu_fprintf(f, "slr=%x shr=%x\n", env->slr, env->shr);
     for (i = 0; i < 32; i++) {
-        qemu_fprintf(f, "r%2.2d=%8.8x ", i, env->regs[i]);
-        if ((i + 1) % 4 == 0)
-            qemu_fprintf(f, "\n");
-        }
-    qemu_fprintf(f, "\n\n");
+        qemu_fprintf(f, "r%2.2d=%08x%c",
+                     i, env->regs[i], i % 4 == 3 ? '\n' : ' ');
+    }
+    qemu_fprintf(f, "\n");
 }
 
 void mb_tcg_init(void)