[Pdbg] [PATCH 08/10] pdbg: Add getcr and putcr options

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


Thanks!

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

On Thursday, 31 May 2018 3:29:13 PM AEST Rashmica Gupta wrote:
> Signed-off-by: Rashmica Gupta <rashmica.g at gmail.com>
> ---
>  src/main.c |  2 ++
>  src/reg.c  | 34 ++++++++++++++++++++++++++++++++++
>  src/reg.h  |  1 +
>  3 files changed, 37 insertions(+)
> 
> diff --git a/src/main.c b/src/main.c
> index 90fb729..e714377 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -96,6 +96,8 @@ static struct action expert_actions[] = {
>  	{ "putspr",  "<spr> <value>", "Write Special Purpose Register (SPR)", &handle_spr },
>  	{ "getmsr",  "", "Get Machine State Register (MSR)", &handle_msr },
>  	{ "putmsr",  "<value>", "Write Machine State Register (MSR)", &handle_msr },
> +	{ "getcr",  "", "Get Condition Register (CR)", &handle_cr },
> +	{ "putcr",  "<value>", "Write Condition Register (CR)", &handle_cr },
>  	{ "getxer",  "", "Get Fixed Point Exception Register (XER)", &handle_xer },
>  	{ "putxer",  "<value>", "Write Fixed Point Exception Register (XER)", &handle_xer },
>  	{ "getring", "<addr> <len>", "Read a ring. Length must be correct", &handle_getring },
> diff --git a/src/reg.c b/src/reg.c
> index e252ab8..0a87006 100644
> --- a/src/reg.c
> +++ b/src/reg.c
> @@ -24,6 +24,7 @@
>  
>  #include "main.h"
>  
> +#define REG_CR -5
>  #define REG_XER -4
>  #define REG_MEM -3
>  #define REG_MSR -2
> @@ -45,6 +46,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va
>  		printf("nia: ");
>  	else if (reg == REG_XER)
>  		printf("xer: ");
> +	else if (reg == REG_CR)
> +		printf("cr: ");
>  	else if (reg > REG_R31)
>  		printf("spr%03" PRIu64 ": ", reg - REG_R31);
>  	else if (reg >= 0 && reg <= 31)
> @@ -68,6 +71,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg,
>  		rc = ram_putnia(target, *value);
>  	else if (*reg == REG_XER)
>  		rc = ram_putxer(target, *value);
> +	else if (*reg == REG_CR)
> +		rc = ram_putcr(target, *value);
>  	else if (*reg > REG_R31)
>  		rc = ram_putspr(target, *reg - REG_R31, *value);
>  	else if (*reg >= 0 && *reg <= 31)
> @@ -89,6 +94,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg,
>  		rc = ram_getnia(target, &value);
>  	else if (*reg == REG_XER)
>  		rc = ram_getxer(target, &value);
> +	else if (*reg == REG_CR)
> +		rc = ram_getcr(target, &value);
>  	else if (*reg > REG_R31)
>  		rc = ram_getspr(target, *reg - REG_R31, &value);
>  	else if (*reg >= 0 && *reg <= 31)
> @@ -268,3 +275,30 @@ int handle_xer(int optind, int argc, char *argv[])
>  	PR_WARNING("We can only get part of the XER register.\n");
>  	return for_each_target("thread", getprocreg, &xer, NULL);
>  }
> +
> +int handle_cr(int optind, int argc, char *argv[])
> +{
> +	uint64_t cr = REG_CR;
> +	char *endptr;
> +
> +	if (strcmp(argv[optind], "putcr") == 0) {
> +		uint64_t data;
> +
> +		if (optind + 1 >= argc) {
> +			printf("%s: command '%s' requires data\n", argv[0], argv[optind]);
> +			return -1;
> +		}
> +
> +		errno = 0;
> +		data = strtoull(argv[optind + 1], &endptr, 0);
> +		if (errno || *endptr != '\0') {
> +			printf("%s: command '%s' couldn't parse data '%s'\n",
> +				argv[0], argv[optind], argv[optind + 1]);
> +			return -1;
> +		}
> +
> +		return for_each_target("thread", putprocreg, &cr, &data);
> +	}
> +
> +	return for_each_target("thread", getprocreg, &cr, NULL);
> +}
> diff --git a/src/reg.h b/src/reg.h
> index ca548a6..96d3f73 100644
> --- a/src/reg.h
> +++ b/src/reg.h
> @@ -19,3 +19,4 @@ int handle_nia(int optind, int argc, char *argv[]);
>  int handle_spr(int optind, int argc, char *argv[]);
>  int handle_msr(int optind, int argc, char *argv[]);
>  int handle_xer(int optind, int argc, char *argv[]);
> +int handle_cr(int optind, int argc, char *argv[]);
> 




More information about the Pdbg mailing list