From patchwork Tue Aug 6 01:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chd5WbPz9sN1 for ; Tue, 6 Aug 2019 11:37:53 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chd3V2JzDqWd for ; Tue, 6 Aug 2019 11:37:53 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chF44ltzDqWT for ; Tue, 6 Aug 2019 11:37:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chF1kgXz9sDB; Tue, 6 Aug 2019 11:37:33 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:15 +1000 Message-Id: <20190806013723.4047-5-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 04/12] libpdbg: Introduce a backend field X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" It is useful to be able to override a particular targets access methods with methods specific to a specific runtime environment. This patch introduces a field to every target which can be used for this purpose without affecting the current behaviour. Signed-off-by: Alistair Popple --- libpdbg/target.c | 12 +++++++++--- libpdbg/target.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index 61353bc..e822d70 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -14,8 +14,8 @@ struct list_head empty_list = LIST_HEAD_INIT(empty_list); struct list_head target_classes = LIST_HEAD_INIT(target_classes); -/* Work out the address to access based on the current target and - * final class name */ +/* Work out the target and address to call call access methods on + * based on the current target and final class name */ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, const char *name, uint64_t *addr) { /* Check class */ @@ -34,7 +34,13 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con assert(target != pdbg_target_root()); } - return target; + if (target->backend) { + /* The backend must implement the same interfaces */ + assert(!strcmp(target->class, target->backend->class)); + return target->backend; + } else { + return target; + } } struct pdbg_target *pdbg_address_absolute(struct pdbg_target *target, uint64_t *addr) diff --git a/libpdbg/target.h b/libpdbg/target.h index 9394447..2c76bf9 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -46,6 +46,7 @@ struct pdbg_target { struct list_head properties; struct list_head children; struct pdbg_target *parent; + struct pdbg_target *backend; u32 phandle; bool probed; struct list_node class_link;