[Pdbg] [PATCH 04/10] libpdbg: Make getcr actually get all of the Condition Register

Alistair Popple alistair at popple.id.au
Fri Jun 15 11:17:58 AEST 2018


Reviewed-by: Alistair Popple <alistair at popple.id.au>

On Thursday, 31 May 2018 3:29:09 PM AEST Rashmica Gupta wrote:
> Signed-off-by: Rashmica Gupta <rashmica.g at gmail.com>
> ---
>  libpdbg/chip.c    | 25 ++++++++++++++++++-------
>  libpdbg/libpdbg.h |  1 +
>  2 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/libpdbg/chip.c b/libpdbg/chip.c
> index e91d775..f478526 100644
> --- a/libpdbg/chip.c
> +++ b/libpdbg/chip.c
> @@ -318,7 +318,7 @@ int ram_getmsr(struct pdbg_target *thread, uint64_t *value)
>  	return 0;
>  }
>  
> -int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value)
> +int ram_getcr_field(struct pdbg_target *thread, int cr, uint64_t *value)
>  {
>  	uint64_t opcodes[] = {mfocrf(0, cr), mtspr(277, 0)};
>  	uint64_t results[] = {0, 0};
> @@ -328,6 +328,22 @@ int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value)
>  	return 0;
>  }
>  
> +int ram_getcr(struct pdbg_target *thread, uint64_t *value)
> +{
> +	uint64_t cr_field, cr = 0;
> +	int i;
> +
> +	for (i = 0; i < 8; i++){
> +		cr_field = 0;
> +		ram_getcr_field(thread, i, &cr_field);
> +		/* We are not guarenteed that the other bits will be zeroed out */
> +		cr |= cr_field & (0xf << 4*i);
> +	}
> +
> +	*value = cr;
> +	return 0;
> +}
> +
>  int ram_putmsr(struct pdbg_target *thread, uint64_t value)
>  {
>  	uint64_t opcodes[] = {mfspr(0, 277), mtmsr(0)};
> @@ -472,12 +488,7 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs)
>  	ram_getspr(thread, 815, &regs->tar);
>  	printf("TAR   : 0x%016" PRIx64 "\n", regs->tar);
>  
> -	regs->cr = 0;
> -	for (i = 0; i < 8; i++) {
> -		uint64_t cr;
> -		ram_getcr(thread, i, &cr);
> -		regs->cr |= cr;
> -	}
> +	ram_getcr(thread, (uint64_t *)&regs->cr);
>  	printf("CR    : 0x%08" PRIx32 "\n", regs->cr);
>  
>  	ram_getxer(thread, (uint64_t *)&regs->xer);
> diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> index 2a3a337..7f09caa 100644
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -140,6 +140,7 @@ int ram_putnia(struct pdbg_target *target, uint64_t val);
>  int ram_putspr(struct pdbg_target *target, int spr, uint64_t val);
>  int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val);
>  int ram_getmsr(struct pdbg_target *target, uint64_t *val);
> +int ram_getcr(struct pdbg_target *thread,  uint64_t *value);
>  int ram_getnia(struct pdbg_target *target, uint64_t *val);
>  int ram_getspr(struct pdbg_target *target, int spr, uint64_t *val);
>  int ram_getgpr(struct pdbg_target *target, int gpr, uint64_t *val);
> 




More information about the Pdbg mailing list