diff mbox series

[v5,09/30] libpdbg: Add a function to map real target to virtual

Message ID 20191014051748.20190-10-amitay@ozlabs.org
State Accepted
Headers show
Series Add system device tree to libpdbg | expand

Commit Message

Amitay Isaacs Oct. 14, 2019, 5:17 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/target.c | 12 ++++++++++++
 libpdbg/target.h |  1 +
 2 files changed, 13 insertions(+)

Comments

Alistair Popple Oct. 15, 2019, 3:56 a.m. UTC | #1
Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Monday, 14 October 2019 4:17:27 PM AEDT Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  libpdbg/target.c | 12 ++++++++++++
>  libpdbg/target.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/libpdbg/target.c b/libpdbg/target.c
> index 61deb57..7b8de03 100644
> --- a/libpdbg/target.c
> +++ b/libpdbg/target.c
> @@ -485,3 +485,15 @@ struct pdbg_target *target_to_real(struct pdbg_target *target, bool strict)
>  
>  	return target;
>  }
> +
> +/* Map real target to virtual target */
> +struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict)
> +{
> +	if (target->compatible && target->vnode)
> +		return target->vnode;
> +
> +	if (strict)
> +		return NULL;
> +
> +	return target;
> +}
> diff --git a/libpdbg/target.h b/libpdbg/target.h
> index 44d319e..cbc5698 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, bool strict);
> +struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict);
>  
>  #endif
>
diff mbox series

Patch

diff --git a/libpdbg/target.c b/libpdbg/target.c
index 61deb57..7b8de03 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -485,3 +485,15 @@  struct pdbg_target *target_to_real(struct pdbg_target *target, bool strict)
 
 	return target;
 }
+
+/* Map real target to virtual target */
+struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict)
+{
+	if (target->compatible && target->vnode)
+		return target->vnode;
+
+	if (strict)
+		return NULL;
+
+	return target;
+}
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 44d319e..cbc5698 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, bool strict);
+struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict);
 
 #endif