From patchwork Mon Jun 22 00:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1314031 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 49qrL90FXqz9sRR for ; Mon, 22 Jun 2020 10:45:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=AEuoNfoG; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49qrL86KF8zDqbg for ; Mon, 22 Jun 2020 10:45:36 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (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 49qrKg4wwqzDqbX for ; Mon, 22 Jun 2020 10:45:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=AEuoNfoG; dkim-atps=neutral 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 X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 49qrKg2XdCz9sSS; Mon, 22 Jun 2020 10:45:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1592786711; bh=oY4AihgsfmtaQ0vNQhnQ4cXPcRneXm4Gx8mOD/z/kN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEuoNfoGqKn2xGtGbRX5eRvRIfdo0eQ3HPC2jNICHr786QU+K+keUJEIEq3oJhwyA ub8BYtSu420n/WByoJRL0KvihEXTxppucE5xjwrWH0IZj1k3pOsULMXfB9VGIaRJyb g5RZZfoHvUW5lqWSstwpwPJQN53D7VtT1RFqoTdiZMQdeVyRo9q6FBNECm+KO68LrB qE2gQQvFnM5nsLd2Ujk6U8BKJ2cp1ksod3oD+0zQYuHXSBX3B9vlVQihy8KRjBNRPS xXk4dBDRWXvlaOcbFkA2VEN5HvcTQ7vvo8jKGbGkEv0MW8sNIkrHHiUFf22/9i038V nyKSYzxa2PuAw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 22 Jun 2020 10:44:54 +1000 Message-Id: <20200622004501.12889-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200622004501.12889-1-amitay@ozlabs.org> References: <20200622004501.12889-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/9] libpdbg: Avoid direct access of class in pdbg_target 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 Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- libpdbg/chip.c | 114 ++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index f9f184b..f0dd6bf 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -110,7 +110,7 @@ struct thread_state thread_status(struct pdbg_target *target) { struct thread *thread; - assert(!strcmp(target->class, "thread")); + assert(pdbg_target_is_class(target, "thread")); thread = target_to_thread(target); return thread->status; } @@ -118,39 +118,39 @@ struct thread_state thread_status(struct pdbg_target *target) /* * Single step the thread count instructions. */ -int thread_step(struct pdbg_target *thread_target, int count) +int thread_step(struct pdbg_target *target, int count) { struct thread *thread; - assert(!strcmp(thread_target->class, "thread")); - thread = target_to_thread(thread_target); + assert(pdbg_target_is_class(target, "thread")); + thread = target_to_thread(target); return thread->step(thread, count); } -int thread_start(struct pdbg_target *thread_target) +int thread_start(struct pdbg_target *target) { struct thread *thread; - assert(!strcmp(thread_target->class, "thread")); - thread = target_to_thread(thread_target); + assert(pdbg_target_is_class(target, "thread")); + thread = target_to_thread(target); return thread->start(thread); } -int thread_stop(struct pdbg_target *thread_target) +int thread_stop(struct pdbg_target *target) { struct thread *thread; - assert(!strcmp(thread_target->class, "thread")); - thread = target_to_thread(thread_target); + assert(pdbg_target_is_class(target, "thread")); + thread = target_to_thread(target); return thread->stop(thread); } -int thread_sreset(struct pdbg_target *thread_target) +int thread_sreset(struct pdbg_target *target) { struct thread *thread; - assert(!strcmp(thread_target->class, "thread")); - thread = target_to_thread(thread_target); + assert(pdbg_target_is_class(target, "thread")); + thread = target_to_thread(target); return thread->sreset(thread); } @@ -526,29 +526,29 @@ int thread_putxer(struct pdbg_target *target, uint64_t value) /* * Read the given ring from the given chiplet. Result must be large enough to hold ring_len bits. */ -int getring(struct pdbg_target *chiplet_target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[]) +int getring(struct pdbg_target *target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[]) { struct chiplet *chiplet; - assert(!strcmp(chiplet_target->class, "chiplet")); - chiplet = target_to_chiplet(chiplet_target); + assert(pdbg_target_is_class(target, "chiplet")); + chiplet = target_to_chiplet(target); return chiplet->getring(chiplet, ring_addr, ring_len, result); } -int thread_getregs(struct pdbg_target *thread, struct thread_regs *regs) +int thread_getregs(struct pdbg_target *target, struct thread_regs *regs) { + struct thread *thread; struct thread_regs _regs; - struct thread *t; uint64_t value = 0; int i; if (!regs) regs = &_regs; - assert(!strcmp(thread->class, "thread")); - t = target_to_thread(thread); + assert(pdbg_target_is_class(target, "thread")); + thread = target_to_thread(target); - CHECK_ERR(t->ram_setup(t)); + CHECK_ERR(thread->ram_setup(thread)); /* * It would be neat to do all the ramming up front, then go through @@ -556,120 +556,120 @@ int thread_getregs(struct pdbg_target *thread, struct thread_regs *regs) * can help to diagnose checkstop issues with ramming to print as * we go. Once it's more robust and tested, maybe. */ - thread_getnia(thread, ®s->nia); + thread_getnia(target, ®s->nia); printf("NIA : 0x%016" PRIx64 "\n", regs->nia); - thread_getspr(thread, 28, ®s->cfar); + thread_getspr(target, 28, ®s->cfar); printf("CFAR : 0x%016" PRIx64 "\n", regs->cfar); - thread_getmsr(thread, ®s->msr); + thread_getmsr(target, ®s->msr); printf("MSR : 0x%016" PRIx64 "\n", regs->msr); - thread_getspr(thread, 8, ®s->lr); + thread_getspr(target, 8, ®s->lr); printf("LR : 0x%016" PRIx64 "\n", regs->lr); - thread_getspr(thread, 9, ®s->ctr); + thread_getspr(target, 9, ®s->ctr); printf("CTR : 0x%016" PRIx64 "\n", regs->ctr); - thread_getspr(thread, 815, ®s->tar); + thread_getspr(target, 815, ®s->tar); printf("TAR : 0x%016" PRIx64 "\n", regs->tar); - thread_getcr(thread, ®s->cr); + thread_getcr(target, ®s->cr); printf("CR : 0x%08" PRIx32 "\n", regs->cr); - thread_getxer(thread, ®s->xer); + thread_getxer(target, ®s->xer); printf("XER : 0x%08" PRIx64 "\n", regs->xer); printf("GPRS :\n"); for (i = 0; i < 32; i++) { - thread_getgpr(thread, i, ®s->gprs[i]); + thread_getgpr(target, i, ®s->gprs[i]); printf(" 0x%016" PRIx64 "", regs->gprs[i]); if (i % 4 == 3) printf("\n"); } - thread_getspr(thread, 318, ®s->lpcr); + thread_getspr(target, 318, ®s->lpcr); printf("LPCR : 0x%016" PRIx64 "\n", regs->lpcr); - thread_getspr(thread, 464, ®s->ptcr); + thread_getspr(target, 464, ®s->ptcr); printf("PTCR : 0x%016" PRIx64 "\n", regs->ptcr); - thread_getspr(thread, 319, ®s->lpidr); + thread_getspr(target, 319, ®s->lpidr); printf("LPIDR : 0x%016" PRIx64 "\n", regs->lpidr); - thread_getspr(thread, 48, ®s->pidr); + thread_getspr(target, 48, ®s->pidr); printf("PIDR : 0x%016" PRIx64 "\n", regs->pidr); - thread_getspr(thread, 190, ®s->hfscr); + thread_getspr(target, 190, ®s->hfscr); printf("HFSCR : 0x%016" PRIx64 "\n", regs->hfscr); - thread_getspr(thread, 306, &value); + thread_getspr(target, 306, &value); regs->hdsisr = value; printf("HDSISR: 0x%08" PRIx32 "\n", regs->hdsisr); - thread_getspr(thread, 307, ®s->hdar); + thread_getspr(target, 307, ®s->hdar); printf("HDAR : 0x%016" PRIx64 "\n", regs->hdar); - thread_getspr(thread, 339, &value); + thread_getspr(target, 339, &value); regs->heir = value; printf("HEIR : 0x%016" PRIx32 "\n", regs->heir); - thread_getspr(thread, 1008, ®s->hid); + thread_getspr(target, 1008, ®s->hid); printf("HID0 : 0x%016" PRIx64 "\n", regs->hid); - thread_getspr(thread, 314, ®s->hsrr0); + thread_getspr(target, 314, ®s->hsrr0); printf("HSRR0 : 0x%016" PRIx64 "\n", regs->hsrr0); - thread_getspr(thread, 315, ®s->hsrr1); + thread_getspr(target, 315, ®s->hsrr1); printf("HSRR1 : 0x%016" PRIx64 "\n", regs->hsrr1); - thread_getspr(thread, 310, ®s->hdec); + thread_getspr(target, 310, ®s->hdec); printf("HDEC : 0x%016" PRIx64 "\n", regs->hdec); - thread_getspr(thread, 304, ®s->hsprg0); + thread_getspr(target, 304, ®s->hsprg0); printf("HSPRG0: 0x%016" PRIx64 "\n", regs->hsprg0); - thread_getspr(thread, 305, ®s->hsprg1); + thread_getspr(target, 305, ®s->hsprg1); printf("HSPRG1: 0x%016" PRIx64 "\n", regs->hsprg1); - thread_getspr(thread, 153, ®s->fscr); + thread_getspr(target, 153, ®s->fscr); printf("FSCR : 0x%016" PRIx64 "\n", regs->fscr); - thread_getspr(thread, 18, &value); + thread_getspr(target, 18, &value); regs->dsisr = value; printf("DSISR : 0x%08" PRIx32 "\n", regs->dsisr); - thread_getspr(thread, 19, ®s->dar); + thread_getspr(target, 19, ®s->dar); printf("DAR : 0x%016" PRIx64 "\n", regs->dar); - thread_getspr(thread, 26, ®s->srr0); + thread_getspr(target, 26, ®s->srr0); printf("SRR0 : 0x%016" PRIx64 "\n", regs->srr0); - thread_getspr(thread, 27, ®s->srr1); + thread_getspr(target, 27, ®s->srr1); printf("SRR1 : 0x%016" PRIx64 "\n", regs->srr1); - thread_getspr(thread, 22, ®s->dec); + thread_getspr(target, 22, ®s->dec); printf("DEC : 0x%016" PRIx64 "\n", regs->dec); - thread_getspr(thread, 268, ®s->tb); + thread_getspr(target, 268, ®s->tb); printf("TB : 0x%016" PRIx64 "\n", regs->tb); - thread_getspr(thread, 272, ®s->sprg0); + thread_getspr(target, 272, ®s->sprg0); printf("SPRG0 : 0x%016" PRIx64 "\n", regs->sprg0); - thread_getspr(thread, 273, ®s->sprg1); + thread_getspr(target, 273, ®s->sprg1); printf("SPRG1 : 0x%016" PRIx64 "\n", regs->sprg1); - thread_getspr(thread, 274, ®s->sprg2); + thread_getspr(target, 274, ®s->sprg2); printf("SPRG2 : 0x%016" PRIx64 "\n", regs->sprg2); - thread_getspr(thread, 275, ®s->sprg3); + thread_getspr(target, 275, ®s->sprg3); printf("SPRG3 : 0x%016" PRIx64 "\n", regs->sprg3); - thread_getspr(thread, 896, ®s->ppr); + thread_getspr(target, 896, ®s->ppr); printf("PPR : 0x%016" PRIx64 "\n", regs->ppr); - CHECK_ERR(t->ram_destroy(t)); + CHECK_ERR(thread->ram_destroy(thread)); return 0; }