[Pdbg] [PATCH 14/14] pdbg: add 'regs' command

Alistair Popple alistair at popple.id.au
Thu Apr 12 14:58:30 AEST 2018


> +	printf("NIA : 0x%016lx\n", value);

This will break on 32-bit (ie. ARM/BMC) builds. We need to use PRIx64 here
inplace of the "lx". Thanks!

- Alistair

> +	ram_getspr(thread, 0x8, &value);
> +	printf("LR : 0x%016lx\n", value);
> +
> +	ram_getspr(thread, 0x9, &value);
> +	printf("CTR: 0x%016lx\n", value);
> +
> +//	ram_getcr(thread, 0x9, &value);
> +//	printf("CR: 0x%08lx\n", value);
> +
> +	ram_getmsr(thread, &value);
> +	printf("MSR : 0x%016lx\n", value);
> +
> +	printf("GPRS:\n");
> +	for (i = 0; i < 32; i++) {
> +		ram_getgpr(thread, i, &value);
> +		printf(" 0x%016lx", value);
> +		if (i % 2 == 1)
> +			printf("\n");
> +	}
> +
> +	CHECK_ERR(t->ram_destroy(t));
> +
> +	return 0;
> +}
> diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> index e57058a..be01218 100644
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -65,6 +65,7 @@ int ram_start_thread(struct pdbg_target *target);
>  int ram_step_thread(struct pdbg_target *target, int steps);
>  int ram_stop_thread(struct pdbg_target *target);
>  int ram_sreset_thread(struct pdbg_target *target);
> +int ram_state_thread(struct pdbg_target *target);
>  uint64_t thread_status(struct pdbg_target *target);
>  
>  #define THREAD_STATUS_DISABLED  PPC_BIT(0)
> diff --git a/src/main.c b/src/main.c
> index 368bc4e..7a522b9 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -104,6 +104,7 @@ static struct action expert_actions[] = {
>  };
>  
>  static struct action actions[] = {
> +	{ "regs",  "", "State", &thread_state },
>  	{ "sreset",  "", "Reset", &thread_sreset },
>  	{ "probe", "", "", &handle_probe },
>  };
> diff --git a/src/thread.c b/src/thread.c
> index 6001bb3..0e1ff0b 100644
> --- a/src/thread.c
> +++ b/src/thread.c
> @@ -102,6 +102,11 @@ static int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint
>  	return ram_sreset_thread(thread_target) ? 0 : 1;
>  }
>  
> +static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
> +{
> +	return ram_state_thread(thread_target) ? 0 : 1;
> +}
> +
>  int thread_start(int optind, int argc, char *argv[])
>  {
>  	int err;
> @@ -154,3 +159,14 @@ int thread_sreset(int optind, int argc, char *argv[])
>  
>  	return err;
>  }
> +
> +int thread_state(int optind, int argc, char *argv[])
> +{
> +	int err;
> +
> +	err = for_each_target("thread", state_thread, NULL, NULL);
> +
> +	pdbg_target_release();
> +
> +	return err;
> +}
> diff --git a/src/thread.h b/src/thread.h
> index 01a8034..5fc2a80 100644
> --- a/src/thread.h
> +++ b/src/thread.h
> @@ -22,3 +22,4 @@ int thread_step(int optind, int argc, char *argv[]);
>  int thread_stop(int optind, int argc, char *argv[]);
>  int thread_status_print(int optind, int argc, char *argv[]);
>  int thread_sreset(int optind, int argc, char *argv[]);
> +int thread_state(int optind, int argc, char *argv[]);
> 




More information about the Pdbg mailing list