[Pdbg] [RFC 10/12] libpdbg: Make probe result matches the backend status

Alistair Popple alistair at popple.id.au
Tue Aug 6 11:37:21 AEST 2019


If a target has a backend assigned make sure the status reflects the
status of the selected backend.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 libpdbg/target.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libpdbg/target.c b/libpdbg/target.c
index 73ad98f..d6604c2 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -402,15 +402,16 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target)
 	}
 
 	/* At this point any parents must exist and have already been probed */
-	if (target->probe && target->probe(target)) {
-		/* Could not find the target */
-		assert(pdbg_target_status(target) != PDBG_TARGET_MUSTEXIST);
+	if (target->backend && target->backend->probe && target->backend->probe(target->backend))
+		target->backend->status = target->status = PDBG_TARGET_NONEXISTENT;
+	else if (target->probe && target->probe(target))
 		target->status = PDBG_TARGET_NONEXISTENT;
-		return PDBG_TARGET_NONEXISTENT;
-	}
+	else
+		target->status = PDBG_TARGET_ENABLED;
+
+	assert(target->status != PDBG_TARGET_NONEXISTENT && target->status != PDBG_TARGET_MUSTEXIST);
 
-	target->status = PDBG_TARGET_ENABLED;
-	return PDBG_TARGET_ENABLED;
+	return target->status;
 }
 
 /* Releases a target by first recursively releasing all its children */
-- 
2.20.1



More information about the Pdbg mailing list