[Pdbg] [PATCH] libsbefifo: print regs
Joel Stanley
joel at jms.id.au
Mon Jan 11 15:51:25 AEDT 2021
On Fri, 18 Dec 2020 at 10:45, Nicholas Piggin <npiggin at gmail.com> wrote:
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
Reviewed-by: Joel Stanley <joel at jms.id.au>
I assume this is more robust and tested now, hence the change :)
> ---
> libpdbg/chip.c | 74 ++---------------------------------------------
> libpdbg/libpdbg.h | 6 ++++
> libpdbg/thread.c | 54 +++++++++++++++++++++++++++++++++-
> 3 files changed, 62 insertions(+), 72 deletions(-)
>
> diff --git a/libpdbg/chip.c b/libpdbg/chip.c
> index a5afe5c..79aeb35 100644
> --- a/libpdbg/chip.c
> +++ b/libpdbg/chip.c
> @@ -329,127 +329,59 @@ int ram_getregs(struct thread *thread, struct thread_regs *regs)
>
> CHECK_ERR(thread->ram_setup(thread));
>
> - /*
> - * It would be neat to do all the ramming up front, then go through
> - * and print everything out somewhere else. In practice so far it
> - * can help to diagnose checkstop issues with ramming to print as
> - * we go. Once it's more robust and tested, maybe.
> - */
> ram_getnia(thread, ®s->nia);
> - printf("NIA : 0x%016" PRIx64 "\n", regs->nia);
> -
> ram_getspr(thread, SPR_CFAR, ®s->cfar);
> - printf("CFAR : 0x%016" PRIx64 "\n", regs->cfar);
> -
> ram_getmsr(thread, ®s->msr);
> - printf("MSR : 0x%016" PRIx64 "\n", regs->msr);
> -
> ram_getspr(thread, SPR_LR, ®s->lr);
> - printf("LR : 0x%016" PRIx64 "\n", regs->lr);
> -
> ram_getspr(thread, SPR_CTR, ®s->ctr);
> - printf("CTR : 0x%016" PRIx64 "\n", regs->ctr);
> -
> ram_getspr(thread, 815, ®s->tar);
> - printf("TAR : 0x%016" PRIx64 "\n", regs->tar);
> -
> ram_getcr(thread, ®s->cr);
> - printf("CR : 0x%08" PRIx32 "\n", regs->cr);
>
> thread->getxer(thread, ®s->xer);
> - printf("XER : 0x%08" PRIx64 "\n", regs->xer);
>
> - printf("GPRS :\n");
> - for (i = 0; i < 32; i++) {
> + for (i = 0; i < 32; i++)
> ram_getgpr(thread, i, ®s->gprs[i]);
> - printf(" 0x%016" PRIx64 "", regs->gprs[i]);
> - if (i % 4 == 3)
> - printf("\n");
> - }
>
> ram_getspr(thread, SPR_LPCR, ®s->lpcr);
> - printf("LPCR : 0x%016" PRIx64 "\n", regs->lpcr);
> -
> ram_getspr(thread, SPR_PTCR, ®s->ptcr);
> - printf("PTCR : 0x%016" PRIx64 "\n", regs->ptcr);
> -
> ram_getspr(thread, SPR_LPIDR, ®s->lpidr);
> - printf("LPIDR : 0x%016" PRIx64 "\n", regs->lpidr);
> -
> ram_getspr(thread, SPR_PIDR, ®s->pidr);
> - printf("PIDR : 0x%016" PRIx64 "\n", regs->pidr);
> -
> ram_getspr(thread, SPR_HFSCR, ®s->hfscr);
> - printf("HFSCR : 0x%016" PRIx64 "\n", regs->hfscr);
>
> ram_getspr(thread, SPR_HDSISR, &value);
> regs->hdsisr = value;
> - printf("HDSISR: 0x%08" PRIx32 "\n", regs->hdsisr);
>
> ram_getspr(thread, SPR_HDAR, ®s->hdar);
> - printf("HDAR : 0x%016" PRIx64 "\n", regs->hdar);
>
> ram_getspr(thread, SPR_HEIR, &value);
> regs->heir = value;
> - printf("HEIR : 0x%016" PRIx32 "\n", regs->heir);
>
> ram_getspr(thread, SPR_HID, ®s->hid);
> - printf("HID0 : 0x%016" PRIx64 "\n", regs->hid);
> -
> ram_getspr(thread, SPR_HSRR0, ®s->hsrr0);
> - printf("HSRR0 : 0x%016" PRIx64 "\n", regs->hsrr0);
> -
> ram_getspr(thread, SPR_HSRR1, ®s->hsrr1);
> - printf("HSRR1 : 0x%016" PRIx64 "\n", regs->hsrr1);
> -
> ram_getspr(thread, SPR_HDEC, ®s->hdec);
> - printf("HDEC : 0x%016" PRIx64 "\n", regs->hdec);
> -
> ram_getspr(thread, SPR_HSPRG0, ®s->hsprg0);
> - printf("HSPRG0: 0x%016" PRIx64 "\n", regs->hsprg0);
> -
> ram_getspr(thread, SPR_HSPRG1, ®s->hsprg1);
> - printf("HSPRG1: 0x%016" PRIx64 "\n", regs->hsprg1);
> -
> ram_getspr(thread, SPR_FSCR, ®s->fscr);
> - printf("FSCR : 0x%016" PRIx64 "\n", regs->fscr);
>
> ram_getspr(thread, SPR_DSISR, &value);
> regs->dsisr = value;
> - printf("DSISR : 0x%08" PRIx32 "\n", regs->dsisr);
>
> ram_getspr(thread, SPR_DAR, ®s->dar);
> - printf("DAR : 0x%016" PRIx64 "\n", regs->dar);
> -
> ram_getspr(thread, SPR_SRR0, ®s->srr0);
> - printf("SRR0 : 0x%016" PRIx64 "\n", regs->srr0);
> -
> ram_getspr(thread, SPR_SRR1, ®s->srr1);
> - printf("SRR1 : 0x%016" PRIx64 "\n", regs->srr1);
> -
> ram_getspr(thread, SPR_DEC, ®s->dec);
> - printf("DEC : 0x%016" PRIx64 "\n", regs->dec);
> -
> ram_getspr(thread, SPR_TB, ®s->tb);
> - printf("TB : 0x%016" PRIx64 "\n", regs->tb);
> -
> ram_getspr(thread, SPR_SPRG0, ®s->sprg0);
> - printf("SPRG0 : 0x%016" PRIx64 "\n", regs->sprg0);
> -
> ram_getspr(thread, SPR_SPRG1, ®s->sprg1);
> - printf("SPRG1 : 0x%016" PRIx64 "\n", regs->sprg1);
> -
> ram_getspr(thread, SPR_SPRG2, ®s->sprg2);
> - printf("SPRG2 : 0x%016" PRIx64 "\n", regs->sprg2);
> -
> ram_getspr(thread, SPR_SPRG3, ®s->sprg3);
> - printf("SPRG3 : 0x%016" PRIx64 "\n", regs->sprg3);
> -
> ram_getspr(thread, SPR_PPR, ®s->ppr);
> - printf("PPR : 0x%016" PRIx64 "\n", regs->ppr);
>
> CHECK_ERR(thread->ram_destroy(thread));
>
> + thread_print_regs(regs);
> +
> return 0;
> }
>
> diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> index 93c9e8b..046cd13 100644
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -839,6 +839,12 @@ struct thread_regs {
> uint64_t ppr;
> };
>
> +/**
> + * @brief Print thread regs to stdout
> + * @param[in] regs the regs to print
> + */
> +void thread_print_regs(struct thread_regs *regs);
> +
> /**
> * @brief Set the MSR on a thread
> * @param[in] target the thread target to operate on
> diff --git a/libpdbg/thread.c b/libpdbg/thread.c
> index 7ef0bf8..9a50ec1 100644
> --- a/libpdbg/thread.c
> +++ b/libpdbg/thread.c
> @@ -14,6 +14,7 @@
> * limitations under the License.
> */
> #include <stdio.h>
> +#include <inttypes.h>
>
> #include "libpdbg.h"
> #include "hwunit.h"
> @@ -267,9 +268,56 @@ int thread_getmem(struct pdbg_target *target, uint64_t addr, uint64_t *value)
> return thread->getmem(thread, addr, value);
> }
>
> +void thread_print_regs(struct thread_regs *regs)
> +{
> + int i;
> +
> + printf("NIA : 0x%016" PRIx64 "\n", regs->nia);
> + printf("CFAR : 0x%016" PRIx64 "\n", regs->cfar);
> + printf("MSR : 0x%016" PRIx64 "\n", regs->msr);
> + printf("LR : 0x%016" PRIx64 "\n", regs->lr);
> + printf("CTR : 0x%016" PRIx64 "\n", regs->ctr);
> + printf("TAR : 0x%016" PRIx64 "\n", regs->tar);
> + printf("CR : 0x%08" PRIx32 "\n", regs->cr);
> + printf("XER : 0x%08" PRIx64 "\n", regs->xer);
> + printf("GPRS :\n");
> + for (i = 0; i < 32; i++) {
> + printf(" 0x%016" PRIx64 "", regs->gprs[i]);
> + if (i % 4 == 3)
> + printf("\n");
> + }
> + printf("LPCR : 0x%016" PRIx64 "\n", regs->lpcr);
> + printf("PTCR : 0x%016" PRIx64 "\n", regs->ptcr);
> + printf("LPIDR : 0x%016" PRIx64 "\n", regs->lpidr);
> + printf("PIDR : 0x%016" PRIx64 "\n", regs->pidr);
> + printf("HFSCR : 0x%016" PRIx64 "\n", regs->hfscr);
> + printf("HDSISR: 0x%08" PRIx32 "\n", regs->hdsisr);
> + printf("HDAR : 0x%016" PRIx64 "\n", regs->hdar);
> + printf("HEIR : 0x%016" PRIx32 "\n", regs->heir);
> + printf("HID0 : 0x%016" PRIx64 "\n", regs->hid);
> + printf("HSRR0 : 0x%016" PRIx64 "\n", regs->hsrr0);
> + printf("HSRR1 : 0x%016" PRIx64 "\n", regs->hsrr1);
> + printf("HDEC : 0x%016" PRIx64 "\n", regs->hdec);
> + printf("HSPRG0: 0x%016" PRIx64 "\n", regs->hsprg0);
> + printf("HSPRG1: 0x%016" PRIx64 "\n", regs->hsprg1);
> + printf("FSCR : 0x%016" PRIx64 "\n", regs->fscr);
> + printf("DSISR : 0x%08" PRIx32 "\n", regs->dsisr);
> + printf("DAR : 0x%016" PRIx64 "\n", regs->dar);
> + printf("SRR0 : 0x%016" PRIx64 "\n", regs->srr0);
> + printf("SRR1 : 0x%016" PRIx64 "\n", regs->srr1);
> + printf("DEC : 0x%016" PRIx64 "\n", regs->dec);
> + printf("TB : 0x%016" PRIx64 "\n", regs->tb);
> + printf("SPRG0 : 0x%016" PRIx64 "\n", regs->sprg0);
> + printf("SPRG1 : 0x%016" PRIx64 "\n", regs->sprg1);
> + printf("SPRG2 : 0x%016" PRIx64 "\n", regs->sprg2);
> + printf("SPRG3 : 0x%016" PRIx64 "\n", regs->sprg3);
> + printf("PPR : 0x%016" PRIx64 "\n", regs->ppr);
> +}
> +
> int thread_getregs(struct pdbg_target *target, struct thread_regs *regs)
> {
> struct thread *thread;
> + int err;
>
> assert(pdbg_target_is_class(target, "thread"));
>
> @@ -283,7 +331,11 @@ int thread_getregs(struct pdbg_target *target, struct thread_regs *regs)
> return -1;
> }
>
> - return thread->getregs(thread, regs);
> + err = thread->getregs(thread, regs);
> + if (!err)
> + thread_print_regs(regs);
> +
> + return err;
> }
>
> int thread_getgpr(struct pdbg_target *target, int gpr, uint64_t *value)
> --
> 2.23.0
>
> --
> Pdbg mailing list
> Pdbg at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
More information about the Pdbg
mailing list