[Pdbg] [PATCH 10/10] pdbg: Make return codes consistent for get/put registers

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


On Thursday, 31 May 2018 3:29:15 PM AEST Rashmica Gupta wrote:
> ---
>  src/main.c | 2 +-
>  src/reg.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/main.c b/src/main.c
> index e714377..3df9a4e 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -739,7 +739,7 @@ int main(int argc, char *argv[])
>  	return 1;
>  
>  found_action:
> -	if (rc <= 0) {
> +	if (rc != 0) {

Sadly this isn't so straight forward. Currently a lot of the actions (eg.
getscom) return the number of targets they were able to successfully execute an
action on. The idea being that the below message could be printed in cases when
rc == 0 which indicates nothing was actually executed. Admitedly the message
might not be very useful, but it is better than exiting without printing
anything.

However I agree our inconsistent return codes are a pretty nasty hack that
should die, just that it will require changes to all the actions.

- Alistair

>                  printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n");
>                  printf("Alternatively run '%s -a probe' to get a list of all valid targets\n",
>  		       basename(argv[0]));
> diff --git a/src/reg.c b/src/reg.c
> index 0a87006..e58275f 100644
> --- a/src/reg.c
> +++ b/src/reg.c
> @@ -103,7 +103,7 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg,
>  
>  	print_proc_reg(target, *reg, value, rc);
>  
> -	return !rc;
> +	return rc;
>  }
>  
>  int handle_gpr(int optind, int argc, char *argv[])
> 




More information about the Pdbg mailing list