[Pdbg] [PATCH v4 09/30] libpdbg: Add a function to map real target to virtual

Alistair Popple alistair at popple.id.au
Wed Oct 9 13:33:14 AEDT 2019


Just a quick question. Can we assume:

target_is_virtual(target_to_virtual(target)) will always be true?

And that:

target_is_virtual(target_to_real(target)) will always be false?

Do you think it be would be worthwhile adding some asserts to check this or 
does the probing code (which I'm yet to read) somehow guarantee those 
assertions are always correct?

- Alistair

On Thursday, 3 October 2019 2:18:48 PM AEDT Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
> ---
>  libpdbg/target.c | 8 ++++++++
>  libpdbg/target.h | 1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/libpdbg/target.c b/libpdbg/target.c
> index 20f292f..f3d4db8 100644
> --- a/libpdbg/target.c
> +++ b/libpdbg/target.c
> @@ -481,3 +481,11 @@ struct pdbg_target *target_to_real(struct pdbg_target 
*target)
>  
>  	return target;
>  }
> +
> +struct pdbg_target *target_to_virtual(struct pdbg_target *target)
> +{
> +	if (target->compatible && target->vnode)
> +		return target->vnode;
> +
> +	return target;
> +}
> diff --git a/libpdbg/target.h b/libpdbg/target.h
> index 5d04117..8148f83 100644
> --- a/libpdbg/target.h
> +++ b/libpdbg/target.h
> @@ -66,5 +66,6 @@ const char *pdbg_get_backend_option(void);
>  struct sbefifo *pib_to_sbefifo(struct pdbg_target *target);
>  bool target_is_virtual(struct pdbg_target *target);
>  struct pdbg_target *target_to_real(struct pdbg_target *target);
> +struct pdbg_target *target_to_virtual(struct pdbg_target *target);
>  
>  #endif
> 






More information about the Pdbg mailing list