From patchwork Thu May 31 05:29:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 923189 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xGHd0P7wz9s0x for ; Thu, 31 May 2018 15:29:49 +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="ovNov8c3"; 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 40xGHc59bdzDrbn for ; Thu, 31 May 2018 15:29:48 +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="ovNov8c3"; 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::231; helo=mail-pl0-x231.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="ovNov8c3"; dkim-atps=neutral Received: from mail-pl0-x231.google.com (mail-pl0-x231.google.com [IPv6:2607:f8b0:400e:c01::231]) (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 40xGHV49WwzDrbK for ; Thu, 31 May 2018 15:29:42 +1000 (AEST) Received: by mail-pl0-x231.google.com with SMTP id c41-v6so12496300plj.10 for ; Wed, 30 May 2018 22:29:42 -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=g3+aOn7iAG1tmyDmOR65jHWEcnU3Oz/FDtCcB6Z7k48=; b=ovNov8c3XVkz1rVVFfOavBGA/4SN/kNG1KuLssXPABXQvj5hjMjvGsjLC0QzcybVGS X27Whhmg1S0qzznk8nuEHXb48Z1Fo/siPqMf9oIwuOHwbPzsasMK+DOHgY1N9dmehxX6 SCC6gtDOLISp/KJQmFyfT+6CI/Jk5Ukh0dzkdkFNzWzrRGDj7mllxOGR3beKueSYQevK KVBVEVp35xBvv1VPqXia7QfWm0dggv1T08U5Y9wfoKz1+JOP6padfhjousaUvOTWRGMb rPdJH1dQoDhu2jGv1A+aHwVnDCNWapdPhJiPCUNal+iMFxc5DZiNlq5YPFxRzIffVlgr KFCg== 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=g3+aOn7iAG1tmyDmOR65jHWEcnU3Oz/FDtCcB6Z7k48=; b=kZRC8c6BBikA6yDiKwhWdQBnNMEVovIARDRSh3nn/NnzDsFoC2LHsMQM/2qmV00cRS kdcJ74kyhZuhVHEaLkeLAFriRb+XAEaYZ4EhyRSeHoNxczEUO36/F6iP5VGUflsPdUm4 hP9+JMxP3japqXdT0btzi0nNXrfTRBTZsjWTJycGtqeVD5Okx5D1ghPaQv+BhPZZUr6i l6X3LG7Mq+ImzkoyAwLGgHozhZGtXMCWofUip3+EEHEMjGP679F/0TNNlAy2u2VJo6S6 AC7Mgp8rqRShZcR42vqmllNsx9+NIqzR2s9jR1hJqiq0XTAC8OvXksQEDqJEXfiIjdE5 bJsA== X-Gm-Message-State: ALKqPwd9LziwQ7Z74Jp08n1x43L6gXy7XBgDkrMaGdRjZK1fnlthe8cL NLAIyIQEt9lXstwdGKhG89UcZw== X-Google-Smtp-Source: ADUXVKJuMyKNp661OPSK3jx7eSi5mFPoBF2CAsVVenRDHrl82phVXke3Bcd5waABy0IU1EWMjMfhYQ== X-Received: by 2002:a17:902:a4:: with SMTP id a33-v6mr5536917pla.346.1527744580551; Wed, 30 May 2018 22:29:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 22:29:40 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Thu, 31 May 2018 15:29:08 +1000 Message-Id: <20180531052915.31171-3-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 03/10] pdbg: Add getxer & putxer commands 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 --- src/main.c | 2 ++ src/reg.c | 37 +++++++++++++++++++++++++++++++++++++ src/reg.h | 1 + 3 files changed, 40 insertions(+) diff --git a/src/main.c b/src/main.c index 07c3677..90fb729 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,8 @@ static struct action expert_actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)", &handle_spr }, { "getmsr", "", "Get Machine State Register (MSR)", &handle_msr }, { "putmsr", "", "Write Machine State Register (MSR)", &handle_msr }, + { "getxer", "", "Get Fixed Point Exception Register (XER)", &handle_xer }, + { "putxer", "", "Write Fixed Point Exception Register (XER)", &handle_xer }, { "getring", " ", "Read a ring. Length must be correct", &handle_getring }, { "start", "", "Start thread", &thread_start }, { "step", "", "Set a thread instructions", &thread_step }, diff --git a/src/reg.c b/src/reg.c index 002cfe9..416236b 100644 --- a/src/reg.c +++ b/src/reg.c @@ -18,11 +18,13 @@ #include #include #include +#include #include #include "main.h" +#define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 #define REG_NIA -1 @@ -41,6 +43,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("msr: "); else if (reg == REG_NIA) printf("nia: "); + else if (reg == REG_XER) + printf("xer: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -62,6 +66,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putmsr(target, *value); else if (*reg == REG_NIA) rc = ram_putnia(target, *value); + else if (*reg == REG_XER) + rc = ram_putxer(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -81,6 +87,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getmsr(target, &value); else if (*reg == REG_NIA) rc = ram_getnia(target, &value); + else if (*reg == REG_XER) + rc = ram_getxer(target, &value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -231,3 +239,32 @@ int handle_msr(int optind, int argc, char *argv[]) return for_each_target("thread", getprocreg, &msr, NULL); } + +int handle_xer(int optind, int argc, char *argv[]) +{ + uint64_t xer = REG_XER; + char *endptr; + + if (strcmp(argv[optind], "putxer") == 0) { + uint64_t data; + + if (optind + 1 >= argc) { + printf("%s: command '%s' requires data\n", argv[0], argv[optind]); + return -1; + } + + errno = 0; + data = strtoull(argv[optind + 1], &endptr, 0); + if (errno || *endptr != '\0') { + printf("%s: command '%s' couldn't parse data '%s'\n", + argv[0], argv[optind], argv[optind + 1]); + return -1; + } + + PR_WARNING("We can only set part of the XER register.\n"); + return for_each_target("thread", putprocreg, &xer, &data); + } + + PR_WARNING("We can only get part of the XER register.\n"); + return for_each_target("thread", getprocreg, &xer, NULL); +} diff --git a/src/reg.h b/src/reg.h index ad41d9d..ca548a6 100644 --- a/src/reg.h +++ b/src/reg.h @@ -18,3 +18,4 @@ int handle_gpr(int optind, int argc, char *argv[]); int handle_nia(int optind, int argc, char *argv[]); int handle_spr(int optind, int argc, char *argv[]); int handle_msr(int optind, int argc, char *argv[]); +int handle_xer(int optind, int argc, char *argv[]);