qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stuart Brady <sdb@zubnet.me.uk>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	Fabien Chouteau <chouteau@adacore.com>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2] target-ppc: improve "info registers" by printing SPRs
Date: Sat, 22 Mar 2014 14:43:03 +0000	[thread overview]
Message-ID: <20140322144303.GA31470@zubnet.me.uk> (raw)
In-Reply-To: <1395491149-21432-1-git-send-email-aik@ozlabs.ru>

On Sat, Mar 22, 2014 at 11:25:49PM +1100, Alexey Kardashevskiy wrote:
> This adds printing of all SPR registers registered for a CPU.
> 
> This removes "SPR_" prefix from SPR name to reduce the output.
> 
> Cc: Fabien Chouteau <chouteau@adacore.com>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> Changes:
> v2:
> * removed "switch (env->mmu_model)"
> * added "\n" if the last line has less than 4 registers
> ---
>  target-ppc/translate.c      | 96 +++++++--------------------------------------
>  target-ppc/translate_init.c | 40 +++++++++----------
>  2 files changed, 35 insertions(+), 101 deletions(-)
> 
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index e3fcb03..06f195a 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -11116,7 +11116,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>  
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>      CPUPPCState *env = &cpu->env;
> -    int i;
> +    int i, j;
>  
>      cpu_fprintf(f, "NIP " TARGET_FMT_lx "   LR " TARGET_FMT_lx " CTR "
>                  TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
> @@ -11167,54 +11167,22 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>              cpu_fprintf(f, "\n");
>      }
>      cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
> -#if !defined(CONFIG_USER_ONLY)
> -    cpu_fprintf(f, " SRR0 " TARGET_FMT_lx "  SRR1 " TARGET_FMT_lx
> -                   "    PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
> -                env->spr[SPR_SRR0], env->spr[SPR_SRR1],
> -                env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
>  
> -    cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
> -                   "  SPRG2 " TARGET_FMT_lx "  SPRG3 " TARGET_FMT_lx "\n",
> -                env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
> -                env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
> -
> -    cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
> -                   "  SPRG6 " TARGET_FMT_lx "  SPRG7 " TARGET_FMT_lx "\n",
> -                env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
> -                env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
> -
> -    if (env->excp_model == POWERPC_EXCP_BOOKE) {
> -        cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
> -                       " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
> -                    env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
> -                    env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
> -
> -        cpu_fprintf(f, "  TCR " TARGET_FMT_lx "   TSR " TARGET_FMT_lx
> -                       "    ESR " TARGET_FMT_lx "   DEAR " TARGET_FMT_lx "\n",
> -                    env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
> -                    env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
> -
> -        cpu_fprintf(f, "  PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
> -                       "   IVPR " TARGET_FMT_lx "   EPCR " TARGET_FMT_lx "\n",
> -                    env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
> -                    env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
> -
> -        cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
> -                       "    EPR " TARGET_FMT_lx "\n",
> -                    env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
> -                    env->spr[SPR_BOOKE_EPR]);
> -
> -        /* FSL-specific */
> -        cpu_fprintf(f, " MCAR " TARGET_FMT_lx "  PID1 " TARGET_FMT_lx
> -                       "   PID2 " TARGET_FMT_lx "    SVR " TARGET_FMT_lx "\n",
> -                    env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
> -                    env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
> -
> -        /*
> -         * IVORs are left out as they are large and do not change often --
> -         * they can be read with "p $ivor0", "p $ivor1", etc.
> -         */
> +    for (i = 0, j = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
> +        ppc_spr_t *spr = &env->spr_cb[i];
> +
> +        if (!spr->name) {
> +            continue;
> +        }

This would leave the output without a trailing newline if the last spr
doesn't have a name registered.  Is it necessary to handle unnamed sprs
at all (maybe add an assert to the registration function)? ... or would
we just want to warn about them here?

FWIW, my approach is often to write an outer loop that process one item
of output at a time, with an inner loop to obtain the next item of data,
and with prefixing of separators, as you then have a far simpler special
case for 'j == 0' instead of 'i == ARRAY_SIZE(env->spr_cb) - 1'.  You can
then unconditionally finish on a '\n'.

Cheers,
Stuart

  reply	other threads:[~2014-03-22 14:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-22 12:25 [Qemu-devel] [PATCH v2] target-ppc: improve "info registers" by printing SPRs Alexey Kardashevskiy
2014-03-22 14:43 ` Stuart Brady [this message]
2014-03-24  6:24   ` Alexey Kardashevskiy
2014-03-31  1:25     ` Alexey Kardashevskiy
2014-03-31  8:24       ` Andreas Färber
2014-03-31  8:50         ` Alexey Kardashevskiy
2014-03-31 10:07           ` Peter Maydell
2014-03-31 10:48             ` Alexey Kardashevskiy
2014-03-31 13:27     ` Alexander Graf
2014-03-31 19:59     ` Stuart Brady

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=20140322144303.GA31470@zubnet.me.uk \
    --to=sdb@zubnet.me.uk \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=chouteau@adacore.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).