From patchwork Thu May 31 05:29:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 923190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xGHg5R41z9s08 for ; Thu, 31 May 2018 15:29:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WKcyHtK/"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xGHg3GvkzDrcN for ; Thu, 31 May 2018 15:29:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WKcyHtK/"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::234; helo=mail-pl0-x234.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WKcyHtK/"; dkim-atps=neutral Received: from mail-pl0-x234.google.com (mail-pl0-x234.google.com [IPv6:2607:f8b0:400e:c01::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xGHY5HnjzDrcN for ; Thu, 31 May 2018 15:29:45 +1000 (AEST) Received: by mail-pl0-x234.google.com with SMTP id f1-v6so12071353plt.6 for ; Wed, 30 May 2018 22:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xSofXovpckEAbQ1T83jKVpLHENXlSVdLXOYCfdpCLM4=; b=WKcyHtK/OAWVQg+l9sMJ3sjWQWkgvt+8R/H2qsA8O86JB60GSrGsxg42K0XZ3jefmE m80YZx9mOUjJF9lwBEX1bNgZ6WyiPzGURbGC3mjoZAbbCGYu9QloOZsbVmyCaWPJ7Cbl ZlMr1zIFavybJYZA0CoxUc6qSCth8t/jeu9TDk3Y7z9tDKqAzI0YDjtHXNxWE0IAEh17 b92qmx6NmNRDGlYWbijUHUzvhKtSp5FuOIcEpGe5Jfj47r4lNOgk4mf2KPGmNF1orZ5m qoMVS74oaVBb68UjXh3NSgEyx/Q5JDXLBWqXH9y5SI3JXxForysSB9b8dzfi2QP7iWUp 6Qng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xSofXovpckEAbQ1T83jKVpLHENXlSVdLXOYCfdpCLM4=; b=Prafq6a/cAP1RWwmMZHRFCK8S7eNt7cGJ6uqDDsjbnyBqWPUDMAmFTOsKX3u0YbXIA PxnL+LlE26KefmBwBjWvA58yLYLDyfYnPGk8P3hdRHnA7z7yW92w5p7hL69CgLoqx7b/ BbVg66kZ32ZbVHXIkWHrNVYuWPSQwDhg3PjZ2q5QUbWKafq9EQb1cNVKVkjnd+d0+IqW +lfApaKGZLE/AYEugeONc3G0BMbTA8EmwSK/PWtBymZgo3JlpZfajRxoo1BKasWdvkhB KBsOq5fNeTaVCF3NX50SBOYYAtnoyvC7LT1XdNSY1XzpndF78aeNuHDcPfU3EzI9jLHl Z4EA== X-Gm-Message-State: ALKqPwcqHWboeQzs/em3kv5MRpy8jvM17KdTTJSo2M/BCFyV5wxdqTSw +Th9jcjtMi3Ga8Dj1TMsyD6tjQ== X-Google-Smtp-Source: ADUXVKJW5IsIsRC8QiVRjhXEXpXSgVnzI2gmXbWLRHgNKijnH36oLjCoq65icDqnP4zyUyA4UKzLTw== X-Received: by 2002:a17:902:7c83:: with SMTP id y3-v6mr5623483pll.51.1527744583488; Wed, 30 May 2018 22:29:43 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id h10-v6sm4500515pgc.28.2018.05.30.22.29.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 22:29:42 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Thu, 31 May 2018 15:29:09 +1000 Message-Id: <20180531052915.31171-4-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180531052915.31171-1-rashmica.g@gmail.com> References: <20180531052915.31171-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 04/10] libpdbg: Make getcr actually get all of the Condition Register X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta Reviewed-by: Alistair Popple --- libpdbg/chip.c | 25 ++++++++++++++++++------- libpdbg/libpdbg.h | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index e91d775..f478526 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -318,7 +318,7 @@ int ram_getmsr(struct pdbg_target *thread, uint64_t *value) return 0; } -int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value) +int ram_getcr_field(struct pdbg_target *thread, int cr, uint64_t *value) { uint64_t opcodes[] = {mfocrf(0, cr), mtspr(277, 0)}; uint64_t results[] = {0, 0}; @@ -328,6 +328,22 @@ int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value) return 0; } +int ram_getcr(struct pdbg_target *thread, uint64_t *value) +{ + uint64_t cr_field, cr = 0; + int i; + + for (i = 0; i < 8; i++){ + cr_field = 0; + ram_getcr_field(thread, i, &cr_field); + /* We are not guarenteed that the other bits will be zeroed out */ + cr |= cr_field & (0xf << 4*i); + } + + *value = cr; + return 0; +} + int ram_putmsr(struct pdbg_target *thread, uint64_t value) { uint64_t opcodes[] = {mfspr(0, 277), mtmsr(0)}; @@ -472,12 +488,7 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs) ram_getspr(thread, 815, ®s->tar); printf("TAR : 0x%016" PRIx64 "\n", regs->tar); - regs->cr = 0; - for (i = 0; i < 8; i++) { - uint64_t cr; - ram_getcr(thread, i, &cr); - regs->cr |= cr; - } + ram_getcr(thread, (uint64_t *)®s->cr); printf("CR : 0x%08" PRIx32 "\n", regs->cr); ram_getxer(thread, (uint64_t *)®s->xer); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 2a3a337..7f09caa 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -140,6 +140,7 @@ int ram_putnia(struct pdbg_target *target, uint64_t val); int ram_putspr(struct pdbg_target *target, int spr, uint64_t val); int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val); int ram_getmsr(struct pdbg_target *target, uint64_t *val); +int ram_getcr(struct pdbg_target *thread, uint64_t *value); int ram_getnia(struct pdbg_target *target, uint64_t *val); int ram_getspr(struct pdbg_target *target, int spr, uint64_t *val); int ram_getgpr(struct pdbg_target *target, int gpr, uint64_t *val);