From patchwork Wed Aug 29 01:50:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963193 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 420T9x3ddWz9s4s for ; Wed, 29 Aug 2018 11:51:17 +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="fUotXPOP"; 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 420T9x0sk8zF13F for ; Wed, 29 Aug 2018 11:51:17 +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="fUotXPOP"; 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:4864:20::42f; helo=mail-pf1-x42f.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="fUotXPOP"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 420T9g6PxqzDrRN for ; Wed, 29 Aug 2018 11:51:03 +1000 (AEST) Received: by mail-pf1-x42f.google.com with SMTP id k19-v6so1516138pfi.1 for ; Tue, 28 Aug 2018 18:51:03 -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=c3LfDcAOKahkHzN5UfQ8CSD/XyNvt9gW+aoR5oppW+g=; b=fUotXPOP4lQEKzZS3xKNKAGbR1S0B/0Fs+VVr0oWgXAcFfC7zfGCFj+S8sISfgM3Aq izW8gMTSrB9NcLL9bcHZkb2oJkPDXNZrx7ftiXJOKZ198XEgfvwOTp+EDEblhKhg+pqX O2093oTBiwNrzgGTStG3Qj00nGdv7k0q8j3h8X2hmB6X/huUeoMDEmWlKyHSvGQ1i8aD gsyy9tyb6WPC10yFATM21C+c5VZB+pdB78z9Lhf7rUXk6/m7jWx2/PlPPfp+h1O/YXSH 0RuCnxudnSScr/11h8L4u8zZxgT3YKMjwZA+6Uj4es7b1SJxnILKojYfWOxAX+Hi6W4s 2ZjQ== 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=c3LfDcAOKahkHzN5UfQ8CSD/XyNvt9gW+aoR5oppW+g=; b=jrAgLzGBdn6tAyNBraqU9VlkfxfQtnaZUA9vrjDqzYdpG6zt/U3k48S7hq9K24VrLr mChkD/McuJQvSQPOs6jfutElNQRKUGVolzkp59Q72MNahVNzYc7GjSnUSOYGiumRivXg pM2JCKcj8jI6XA+w23TMrD6usl4UZopEU6mRaXz9j0FJeljkfWcOoTkWa9iHuHBhV1k6 9ZmSg7C8b1Ke+3TTUEP9KIzPi8vGo8l6mOAC4nvJok+RzuBlYe5j8yFxwKaaSHgynqez B/+arOMQW7ItaaxjKYdHodd6w+yXNShXv9fAZj1N975NswZWv1AiTjCREt0IVLebgBvf uSMQ== X-Gm-Message-State: APzg51CnUaG9m0mNd0e5uVM1AF9Bhxc7rJt78vFUDsf91aTa0Hx5jfWJ REsYnwh06C9SM5dEW5TVZGKy5Xdf X-Google-Smtp-Source: ANB0VdZefvB++im5KbnkgbTByHfKOwEEUOZdl+3knbH/9nogmK55A5TZz1CPXm9/Hr//M+EoariuAA== X-Received: by 2002:a62:7983:: with SMTP id u125-v6mr3733527pfc.177.1535507461614; Tue, 28 Aug 2018 18:51:01 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.50.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:01 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:29 +1000 Message-Id: <20180829015047.7355-2-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 01/19] pdbg: Fix function call for putnia command X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reg.c b/src/reg.c index aa77a8a..c63f6da 100644 --- a/src/reg.c +++ b/src/reg.c @@ -116,7 +116,7 @@ OPTCMD_DEFINE_CMD(getnia, getnia); static int putnia(uint64_t nia) { uint64_t reg = REG_NIA; - return for_each_target("thread", getprocreg, ®, &nia); + return for_each_target("thread", putprocreg, ®, &nia); } OPTCMD_DEFINE_CMD_WITH_ARGS(putnia, putnia, (DATA)); From patchwork Wed Aug 29 01:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963194 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 420TB03qv3z9s7X for ; Wed, 29 Aug 2018 11:51:20 +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="g5vvO1u+"; 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 420TB01k9JzF1nQ for ; Wed, 29 Aug 2018 11:51:20 +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="g5vvO1u+"; 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:4864:20::529; helo=mail-pg1-x529.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="g5vvO1u+"; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 420T9j6TqbzDrRN for ; Wed, 29 Aug 2018 11:51:05 +1000 (AEST) Received: by mail-pg1-x529.google.com with SMTP id g20-v6so1584966pgv.6 for ; Tue, 28 Aug 2018 18:51:05 -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=eRjNLdpug2qunr2gOzXBwNeAXD29v55+TfYcYT1Hfgg=; b=g5vvO1u+5rN9/wYIvKLPSbJ6G2S2ieKq62h1fYWKBQi4eqrmjoL4dhAFzIXSBShgCK OqSw+yDUZQ+yUnAP8TYOnc+zsvbdYM3iJEPSCCtIvWZabsFcNQvCwtqYPeeLal0D1Uio Z/LYN1kZeTdjZ4CFISJIVZf1uG4MwlzWUI+6NmhEoa0HSbTDUhg8wtTR8ZPXadRm+3cW rBQMYAiAPOOtfQ6D3wnWUzFVsBjIkG4RXTVRNT3iY91Gnl5T58GuQGtdeZVivSGFJFMi rXFibUA4Th0/4evpcv+rLQvMhQJL29xJeBaXveZO8zjRZWw+lwKTppocnOe+PsjllSLG 3SMQ== 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=eRjNLdpug2qunr2gOzXBwNeAXD29v55+TfYcYT1Hfgg=; b=jLlQu61ErMD6sObFKZOt9aXzyZd16dyr6qV4Tc1AEIKBpRZ3cVjbemLloCmR+NnMwh UkNgPzDQi1tnkWUVOSD9lW5RObzJUIKb9TqG5P0yW8QhL6aonaZV/BNXaif/r3qaZGjY tXjq5IJgpFhxWEQNC497DxXRVSRMfatQjJ/bxTQMOCA4u+m+LRNqgTrbcl1xhXeegxwT rVLG/tdP+W7zbd1NHCrx1l7iZM1NXXVntWbqFtsTiywaQodcwE9dTMJgF3YXBfJ5crok I+Yt34OtaFIlTHUP+cjGe9rAnVLj3YCiB01XNm/1Jc52dBeoHp+tHMPEZCeWVgRbu2s0 238Q== X-Gm-Message-State: APzg51AMtSFCM6avzfeEzuW/y7IM+Lgv6AzVDdxzszFCse48dYARnNdn D03bs6vi/E6oDyiRAZLoOFIBki4F X-Google-Smtp-Source: ANB0VdadforRIj7598Y8wIQ/AH0mMqyHyIR4oFn99R+laEr6oaxeOUbn4oYEEFYL1cOwrEwD6s6o8A== X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr3755943pfh.141.1535507464013; Tue, 28 Aug 2018 18:51:04 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:03 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:30 +1000 Message-Id: <20180829015047.7355-3-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 02/19] libpdbg: Print the name of the instruction when erroring X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 80a2261..1c5080e 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -29,7 +29,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfspr\n"); return MFSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } @@ -37,7 +37,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) static uint64_t mtspr(uint64_t spr, uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtspr\n"); return MTSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } @@ -45,9 +45,9 @@ static uint64_t mtspr(uint64_t spr, uint64_t reg) static uint64_t mfocrf(uint64_t reg, uint64_t cr) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfocrf\n"); if (cr > 7) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid CR field specified\n"); return MFOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); } @@ -55,7 +55,7 @@ static uint64_t mfocrf(uint64_t reg, uint64_t cr) static uint64_t mfnia(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfnia\n"); return MFNIA_OPCODE | (reg << 21); } @@ -63,7 +63,7 @@ static uint64_t mfnia(uint64_t reg) static uint64_t mtnia(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtnia\n"); return MTNIA_OPCODE | (reg << 21); } @@ -71,7 +71,7 @@ static uint64_t mtnia(uint64_t reg) static uint64_t mfmsr(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfmsr\n"); return MFMSR_OPCODE | (reg << 21); } @@ -79,7 +79,7 @@ static uint64_t mfmsr(uint64_t reg) static uint64_t mtmsr(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtmsr\n"); return MTMSR_OPCODE | (reg << 21); } From patchwork Wed Aug 29 01:50:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963195 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 420TB40z6fz9s4Z for ; Wed, 29 Aug 2018 11:51:24 +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="IB0V0CuE"; 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 420TB36WfLzF1Zs for ; Wed, 29 Aug 2018 11:51:23 +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="IB0V0CuE"; 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:4864:20::442; helo=mail-pf1-x442.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="IB0V0CuE"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 420T9m6bDqzDrRN for ; Wed, 29 Aug 2018 11:51:08 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id i26-v6so1488671pfo.12 for ; Tue, 28 Aug 2018 18:51:08 -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=ZbaZUxibd4ei78ROk7le7m7suS7V8iYW9FpRWU9bqYU=; b=IB0V0CuExsDWpdyBh5/+suDXSuto033mH8BWCGJvbhtjgkmOSwWEE+QxoXFdYExTgU VWeHr97rEqXGZwhnwt6HCs9sJiSFz5PqyXrq4PWo89qXCnnVmEJ9BHCT3tKaES8FVOAZ F0iudEGXoa8U3AjvtX+10ccndkFMYnfzk39MBl0asPPJIZp8rTh0/XOVVUkxXXDRPm4B DaVOa/ufv+0V4yJPSx31s6YNRw5ocWfnXCPz+Y0Z8F1BbNmRibk+ELLDfXOnMTtbwTF1 OZUttzWJAm5OjALyURR+sK3lDeaclnzDSbuqzMdPUCgXohBxr4pCkAqSfsTJtqHDsZLw RoOg== 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=ZbaZUxibd4ei78ROk7le7m7suS7V8iYW9FpRWU9bqYU=; b=bnkmu5KDw4nfG9qiRDSPi75/U6pSN1USTauY0L2MaRVxJsZaPNA/elVJNvM4VlyIUM TKU0iDt0ErBRH9Uof2Xh7q9vKQDFIfpBIQtZzmfW5KthxfKpAa4FswlMypHJqFZkPwrd J3PrgZa+NBSHdI38YLV9nhvRFH4oJh/ff+h+GIBP7YO1v1XP6cLsk+7p9Teduqu2xWo5 apwcG0BgQj0TOunNTA9jSFM8cIW89bLl3HhhYFrnsd0wQmFLYCgpQ/JJQdaaxr4G7YAG 4JhcOJAkJFiTSWB+1P0oE6t5zNIJW5q4o0vIwvbqcJI9qW+D2vRuTxOa6Rd2JGQROnfm dGFQ== X-Gm-Message-State: APzg51D9KHYEEKHZLsgKVp0W9ZiZ/6uLMNiiB4+x8mMg19kaLxxhAoe5 2gvCGpgWnLDsDUBLeIlfS6TN8HXu X-Google-Smtp-Source: ANB0VdZ4hqY6ZplDMRqvm+Lwu8sYPaCQKgE/xI6xO5Pq0VuWM7Te+xCfhTrnZWAmVdbORc9aVmq1Aw== X-Received: by 2002:a63:990a:: with SMTP id d10-v6mr3823554pge.80.1535507466553; Tue, 28 Aug 2018 18:51:06 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:06 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:31 +1000 Message-Id: <20180829015047.7355-4-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 03/19] libpdbg: Add in getxer and putxer functions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 40 ++++++++++++++++++------ libpdbg/chip.h | 24 +++++++++++++++ libpdbg/libpdbg.h | 4 ++- libpdbg/operations.h | 3 +- libpdbg/p8chip.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libpdbg/p9chip.c | 31 +++++++++++++++++-- libpdbg/target.h | 2 ++ 7 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 libpdbg/chip.h diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 1c5080e..01c9b58 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -26,7 +26,7 @@ #include "bitutils.h" #include "debug.h" -static uint64_t mfspr(uint64_t reg, uint64_t spr) +uint64_t mfspr(uint64_t reg, uint64_t spr) { if (reg > 31) PR_ERROR("Invalid register specified for mfspr\n"); @@ -34,7 +34,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) return MFSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } -static uint64_t mtspr(uint64_t spr, uint64_t reg) +uint64_t mtspr(uint64_t spr, uint64_t reg) { if (reg > 31) PR_ERROR("Invalid register specified for mtspr\n"); @@ -148,7 +148,7 @@ int ram_sreset_thread(struct pdbg_target *thread_target) * data. Note that only register r0 is saved and restored so opcodes * must not touch other registers. */ -static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, +int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, uint64_t *results, int len, unsigned int lpar) { uint64_t opcode = 0, r0 = 0, r1 = 0, scratch = 0; @@ -168,6 +168,7 @@ static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes /* RAM instructions */ for (i = -2; i < len + 2; i++) { if (i == -2) + /* Save r1 (assumes opcodes don't touch other registers) */ opcode = mtspr(277, 1); else if (i == -1) /* Save r0 (assumes opcodes don't touch other registers) */ @@ -309,6 +310,31 @@ int ram_getmem(struct pdbg_target *thread, uint64_t addr, uint64_t *value) return 0; } +int ram_getxer(struct pdbg_target *thread_target, uint64_t *value) +{ + + struct thread *thread; + + assert(!strcmp(thread_target->class, "thread")); + thread = target_to_thread(thread_target); + + CHECK_ERR(thread->ram_getxer(thread_target, value)); + + return 0; +} + +int ram_putxer(struct pdbg_target *thread_target, uint64_t value) +{ + struct thread *thread; + + assert(!strcmp(thread_target->class, "thread")); + thread = target_to_thread(thread_target); + + CHECK_ERR(thread->ram_putxer(thread_target, value)); + + return 0; +} + /* * Read the given ring from the given chiplet. Result must be large enough to hold ring_len bits. */ @@ -368,12 +394,8 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs) } printf("CR : 0x%08" PRIx32 "\n", regs->cr); -#if 0 - /* TODO: Disabling because reading SPR 0x1 reliably checkstops a P8 */ - ram_getspr(thread, 0x1, &value); - regs->xer = value; - printf("XER : 0x%08" PRIx32 "\n", regs->xer); -#endif + ram_getxer(thread, ®s->xer); + printf("XER : 0x%08" PRIx64 "\n", regs->xer); printf("GPRS :\n"); for (i = 0; i < 32; i++) { diff --git a/libpdbg/chip.h b/libpdbg/chip.h new file mode 100644 index 0000000..52f3486 --- /dev/null +++ b/libpdbg/chip.h @@ -0,0 +1,24 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __LIBPDBG_CHIP_H +#define __LIBPDBG_CHIP_H + +uint64_t mfspr(uint64_t reg, uint64_t spr) __attribute__ ((visibility("hidden"))); +uint64_t mtspr(uint64_t spr, uint64_t reg) __attribute__ ((visibility("hidden"))); +int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, + uint64_t *results, int len, unsigned int lpar) __attribute__ + ((visibility("hidden"))); +#endif diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index e626786..2e55060 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -108,7 +108,7 @@ struct thread_regs { uint64_t ctr; uint64_t tar; uint32_t cr; - uint32_t xer; + uint64_t xer; uint64_t gprs[32]; uint64_t lpcr; @@ -151,6 +151,8 @@ int ram_stop_thread(struct pdbg_target *target); int ram_sreset_thread(struct pdbg_target *target); int ram_state_thread(struct pdbg_target *target, struct thread_regs *regs); struct thread_state thread_status(struct pdbg_target *target); +int ram_getxer(struct pdbg_target *thread, uint64_t *value); +int ram_putxer(struct pdbg_target *thread, uint64_t value); int getring(struct pdbg_target *chiplet_target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[]); enum pdbg_sleep_state {PDBG_THREAD_STATE_RUN, PDBG_THREAD_STATE_DOZE, diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 52bfe7e..4735c55 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -67,9 +67,10 @@ #define MFOCRF_OPCODE 0x7c100026UL #define MFSPR_MASK (MFSPR_OPCODE | ((0x1f) << 16) | ((0x3e0) << 6)) #define MFXER_OPCODE (MFSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) +#define MTXER_OPCODE (MTSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) #define LD_OPCODE 0xe8000000UL -#define MFSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) +#define MXSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) /* GDB server functionality */ int gdbserver_start(uint16_t port); diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index cb5a46b..89ecfd6 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -83,9 +83,61 @@ #define EX_PM_GP0_REG 0xf0100 #define SPECIAL_WKUP_DONE PPC_BIT(31) +/* p8 specific opcodes for instruction ramming*/ +#define MTXERF0_OPCODE 0x00000008UL +#define MTXERF1_OPCODE 0x00000108UL +#define MTXERF2_OPCODE 0x00000208UL +#define MTXERF3_OPCODE 0x00000308UL +#define MFXERF0_OPCODE 0x00000010UL +#define MFXERF1_OPCODE 0x00000110UL +#define MFXERF2_OPCODE 0x00000210UL +#define MFXERF3_OPCODE 0x00000310UL + /* How long (in us) to wait for a special wakeup to complete */ #define SPECIAL_WKUP_TIMEOUT 10 +#include "chip.h" + +static uint64_t mfxerf(uint64_t reg, uint64_t field) +{ + if (reg > 31) + PR_ERROR("Invalid register specified for mfxerf\n"); + + switch (field) { + case 0: + return MFXERF0_OPCODE | (reg << 21); + case 1: + return MFXERF1_OPCODE | (reg << 21); + case 2: + return MFXERF2_OPCODE | (reg << 21); + case 3: + return MFXERF3_OPCODE | (reg << 21); + default: + PR_ERROR("Invalid XER field specified\n"); + } + return 0; +} + +static uint64_t mtxerf(uint64_t reg, uint64_t field) +{ + if (reg > 31) + PR_ERROR("Invalid register specified for mtxerf\n"); + + switch (field) { + case 0: + return MTXERF0_OPCODE | (reg << 21); + case 1: + return MTXERF1_OPCODE | (reg << 21); + case 2: + return MTXERF2_OPCODE | (reg << 21); + case 3: + return MTXERF3_OPCODE | (reg << 21); + default: + PR_ERROR("Invalid XER field specified\n"); + } + return 0; +} + static int assert_special_wakeup(struct core *chip) { int i = 0; @@ -386,6 +438,38 @@ static int p8_ram_destroy(struct thread *thread) return 0; } +static int p8_ram_getxer(struct pdbg_target *thread, uint64_t *value) +{ + uint64_t opcodes[] = {mfxerf(0, 0), mtspr(277, 0), mfxerf(0, 1), + mtspr(277, 0), mfxerf(0, 2), mtspr(277, 0), + mfxerf(0, 3), mtspr(277, 0)}; + uint64_t results[] = {0, 0, 0, 0, 0, 0, 0, 0}; + + /* On POWER8 we can't get xer with getspr. We seem to only be able to + * get and set IBM bits 32-34 and 44-56. + */ + PR_WARNING("Can only get/set IBM bits 32-34 and 44-56 of the XER register\n"); + + + CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); + + *value = results[1] | results[3] | results[5] | results[7]; + return 0; +} + +static int p8_ram_putxer(struct pdbg_target *thread, uint64_t value) +{ + uint64_t fields[] = {value, value, value, value, 0}; + uint64_t opcodes[] = {mfspr(0, 277), mtxerf(0, 0), mtxerf(0, 1), mtxerf(0, 2), mtxerf(0, 3)}; + + /* We seem to only be able to get and set IBM bits 32-34 and 44-56.*/ + PR_WARNING("Can only set IBM bits 32-34 and 44-56 of the XER register\n"); + + CHECK_ERR(ram_instructions(thread, opcodes, fields, ARRAY_SIZE(opcodes), 0)); + + return 0; +} + /* * Initialise all viable threads for ramming on the given core. */ @@ -413,6 +497,8 @@ static struct thread p8_thread = { .ram_setup = p8_ram_setup, .ram_instruction = p8_ram_instruction, .ram_destroy = p8_ram_destroy, + .ram_getxer = p8_ram_getxer, + .ram_putxer = p8_ram_putxer, }; DECLARE_HW_UNIT(p8_thread); diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index 189d80a..f126968 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -292,7 +292,6 @@ static int __p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t switch(opcode & OPCODE_MASK) { case MTNIA_OPCODE: predecode = 8; - /* Not currently supported as we can only MTNIA from LR */ PR_ERROR("MTNIA is not currently supported\n"); break; @@ -307,7 +306,18 @@ static int __p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t break; case MFSPR_OPCODE: - switch(MFSPR_SPR(opcode)) { + switch(MXSPR_SPR(opcode)) { + case 1: /* XER */ + predecode = 4; + break; + default: + predecode = 0; + break; + } + break; + + case MTSPR_OPCODE: + switch(MXSPR_SPR(opcode)) { case 1: /* XER */ predecode = 4; break; @@ -395,6 +405,21 @@ static int p9_ram_destroy(struct thread *thread) return 0; } +static int p9_ram_getxer(struct pdbg_target *thread, uint64_t *value) +{ + CHECK_ERR(ram_getspr(thread, 1, value)); + + return 0; +} + +static int p9_ram_putxer(struct pdbg_target *thread, uint64_t value) +{ + CHECK_ERR(ram_putspr(thread, 1, value)); + + return 0; + +} + static struct thread p9_thread = { .target = { .name = "POWER9 Thread", @@ -410,6 +435,8 @@ static struct thread p9_thread = { .ram_setup = p9_ram_setup, .ram_instruction = p9_ram_instruction, .ram_destroy = p9_ram_destroy, + .ram_getxer = p9_ram_getxer, + .ram_putxer = p9_ram_putxer, }; DECLARE_HW_UNIT(p9_thread); diff --git a/libpdbg/target.h b/libpdbg/target.h index 9f055ac..8bad405 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -153,6 +153,8 @@ struct thread { int (*ram_setup)(struct thread *); int (*ram_instruction)(struct thread *, uint64_t opcode, uint64_t *scratch); int (*ram_destroy)(struct thread *); + int (*ram_getxer)(struct pdbg_target *, uint64_t *value); + int (*ram_putxer)(struct pdbg_target *, uint64_t value); }; #define target_to_thread(x) container_of(x, struct thread, target) From patchwork Wed Aug 29 01:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963196 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 420TB84vMGz9s4Z for ; Wed, 29 Aug 2018 11:51:28 +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="DU1aDCyB"; 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 420TB80QmfzDrRN for ; Wed, 29 Aug 2018 11:51:28 +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="DU1aDCyB"; 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:4864:20::534; helo=mail-pg1-x534.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="DU1aDCyB"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 420T9q0S6bzF13P for ; Wed, 29 Aug 2018 11:51:10 +1000 (AEST) Received: by mail-pg1-x534.google.com with SMTP id s15-v6so1579429pgv.8 for ; Tue, 28 Aug 2018 18:51:10 -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=MbrgPr1UiNhc0GGZ8mH51D9ort2FktSm0Lvm7YGh7PM=; b=DU1aDCyBR8s3IwJk9GyDzSgP7s/4VUN2P2MfKP3MmT4rlEvlOcXbI1HOK4vTVtHeWR ullcND//yIeUCYzCWICd+VV2IyNwRGJuLt22YMI8vFA86TZ6MxfQ7i4EJYp17G27lGJd nHsij522OiHV5+FpDRYDlkT/VYZW7oVJ3oUmYbf31PC0/CvFZD7hIdMVrZwQWCqe86pW Z09ChhfS5E/+ZRTFYBbdTQRR+OmLyLPizGJ3zlu6pEGy52h1iHeVT8FjIWtVDNWMiwcf 3flBSChA0XEl2SzztFEl3voDty0V74ZKXectKbxGuZLDGM1SoT7QaDudoZidBibEAoFS jWzw== 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=MbrgPr1UiNhc0GGZ8mH51D9ort2FktSm0Lvm7YGh7PM=; b=FmLJVYw294xGvD1qLxGMCUR/NM214IDyk6+F5BcC6NkPfhS737XyOMoKTdO+dPOLJq qnIAX87qF2jsSUwiIT4agju1ejho8+C8V/EViJW5JcNFA4k7qC5J5bHDOmcCpQDxWuFJ FZzsZvIgC/TTuikbISXxG1OooergFy2bBDHutIgCW4DXSYZHkPcPsQ+GzzZayoSNGPBA 0+Hkxk6n6OVov4pJBwteFLJYK0WBlkOJe2Y+w1JA8BLqzk74Aub6CjPGLhKXKT19ShcG N39dOqi7/kzX6GDnXs+472W/BgOm8uPxDddDy/ug5upuKhxSTAj34XfkJ7F6hTV57luB KLwQ== X-Gm-Message-State: APzg51DaY8/UBaHhMRonvA774AWaSTdwH98MPIpA+gqWog/YJv62i2lS cXe/Q39C8VJH8vCEMFZxHC0zAG4/ X-Google-Smtp-Source: ANB0VdY1QL6Y0uTrxqFMXTUIjSexYoaMMQsX0jsJL3oCIXJheCUNP/K751c3aNyrCbqm5Lk7gNamVw== X-Received: by 2002:a63:da04:: with SMTP id c4-v6mr3832159pgh.398.1535507468914; Tue, 28 Aug 2018 18:51:08 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:08 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:32 +1000 Message-Id: <20180829015047.7355-5-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 04/19] pdbg: Add getxer & putxer commands X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com 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 | 6 ++++-- src/reg.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index b48c201..5d840ef 100644 --- a/src/main.c +++ b/src/main.c @@ -86,7 +86,7 @@ extern struct optcmd_cmd optcmd_getnia, optcmd_putnia, optcmd_getmsr, optcmd_putmsr, optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, - optcmd_getmem, optcmd_putmem; + optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -94,7 +94,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getnia, &optcmd_putnia, &optcmd_getmsr, &optcmd_putmsr, &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, - &optcmd_getmem, &optcmd_putmem, + &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -114,6 +114,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getxer", "", "Get Fixed Point Exception Register (XER)" }, + { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, { "start", "", "Start thread" }, { "step", "", "Set a thread instructions" }, diff --git a/src/reg.c b/src/reg.c index c63f6da..3864316 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,6 +24,7 @@ #include "main.h" #include "optcmd.h" +#define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 #define REG_NIA -1 @@ -42,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) @@ -63,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) @@ -82,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) @@ -147,3 +154,18 @@ static int putmsr(uint64_t data) return for_each_target("thread", putprocreg, ®, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putmsr, putmsr, (DATA)); + +static int getxer(void) +{ + uint64_t reg = REG_XER; + return for_each_target("thread", getprocreg, ®, NULL); +} +OPTCMD_DEFINE_CMD(getxer, getxer); + +static int putxer(uint64_t data) +{ + uint64_t reg = REG_XER; + uint64_t d = data; + return for_each_target("thread", putprocreg, ®, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); From patchwork Wed Aug 29 01:50:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963197 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 420TBC4ttzz9s4v for ; Wed, 29 Aug 2018 11:51:31 +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="ni1BwMsA"; 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 420TBC1fdyzF13F for ; Wed, 29 Aug 2018 11:51:31 +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="ni1BwMsA"; 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:4864:20::52c; helo=mail-pg1-x52c.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="ni1BwMsA"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (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 420T9s3FZWzF1nQ for ; Wed, 29 Aug 2018 11:51:13 +1000 (AEST) Received: by mail-pg1-x52c.google.com with SMTP id d1-v6so1587611pgo.3 for ; Tue, 28 Aug 2018 18:51:13 -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=E3cKt9tLCful+rKYdmoD2EphjivjQWofr/xMdNfLwVk=; b=ni1BwMsA7lejko+4cfCikPsYh0OgI+udYUOWICMH+gGLeuj1MowSJw19OFGZE+3Jyd ntz01Xdne0n1a1Yf1Co9g9Co+R+SfI809fvBsf7rHKVX5MnZrZkVOU+5MdpSavZ2xXU4 m38z32y/xhfueG+kd4Tf+qGiN8vzsUAdTMN+YvyHTSRbZJgLArGagZV1+BY8zpChk4wV Tpc8GoqImk0l8BJRUsO5kpI3MD74y4AUQVJ+Exur3o2alLQUK9Ak2Hvx59dhHQRrOK1N uGFXE4sC/2xwmPhT0pjTIosBt26b0p9/gXMxnJmPrVYfOKlflhmZaVOxvBYRN6buo5fS dSfw== 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=E3cKt9tLCful+rKYdmoD2EphjivjQWofr/xMdNfLwVk=; b=a0fJwIWf7fPqaeZIHe9BMlYFfAQTxsnMOQsGfbx2vH1fDFm9fWo+rYTen7sm+t1UGO SeOCAq9uwgMWN0Jk/xEBvMh1tUCDolrmmn9TmIcv703LnKzLb+yLiReiT+a1DsxuWjs/ LfCfSjKNQzd8z92p/Kx2gdFxZsYMY2ryqgcJkH6nRz87rI8nEWGpPxTUDTnJB7Temux4 sgRygfB94cQUYq4LlZJIejxdN03IKsUKGKCZl4eaiGNolXO/USQ0GjYQth3bgNK4qkNJ T9Q93p+d1Ly5btvKcW0dKzo7LXXphRrxRJvtfShzhf/wbElfzEmSlipo+u6dOI/rBcn0 3FLQ== X-Gm-Message-State: APzg51AyT7tk1ccrlU8PeVvkrw4rZsZCdd8FghqQXlh7EHooX8hDqMR0 Y91MFFW4KKe4L97uKMxTJKntSEIb X-Google-Smtp-Source: ANB0Vdb6LtMQQeqpTHAPefzt4q1onHK4DsMj8+CNAflFdsRJlBvSv3VCCb5Y64tNboP0ykglEZ0NAQ== X-Received: by 2002:a63:d90b:: with SMTP id r11-v6mr3807464pgg.315.1535507471269; Tue, 28 Aug 2018 18:51:11 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:10 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:33 +1000 Message-Id: <20180829015047.7355-6-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 05/19] libpdbg: Make getcr actually get all of the Condition Register X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 27 +++++++++++++++++---------- libpdbg/libpdbg.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 01c9b58..31c8c80 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -281,13 +281,25 @@ 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(struct pdbg_target *thread, uint32_t *value) { - uint64_t opcodes[] = {mfocrf(0, cr), mtspr(277, 0)}; - uint64_t results[] = {0, 0}; + + uint64_t opcodes[] = {mfocrf(0, 0), mtspr(277, 0), mfocrf(0, 1), mtspr(277, 0), + mfocrf(0, 2), mtspr(277, 0), mfocrf(0, 3), mtspr(277, 0), + mfocrf(0, 4), mtspr(277, 0), mfocrf(0, 5), mtspr(277, 0), + mfocrf(0, 6), mtspr(277, 0), mfocrf(0, 7), mtspr(277, 0)}; + uint64_t results[16] = {0}; + uint32_t cr_field, cr = 0; + int i; CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); - *value = results[1]; + for (i = 1; i < 16; i += 2) { + cr_field = results[i]; + /* We are not guaranteed that the other bits will be zeroed out */ + cr |= cr_field & (0xf << 2*(i-1)); + } + + *value = cr; return 0; } @@ -386,12 +398,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 = 0; - ram_getcr(thread, i, &cr); - regs->cr |= cr; - } + ram_getcr(thread, ®s->cr); printf("CR : 0x%08" PRIx32 "\n", regs->cr); ram_getxer(thread, ®s->xer); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 2e55060..1239bba 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -142,6 +142,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, uint32_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); From patchwork Wed Aug 29 01:50:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963198 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 420TBG6DSfz9s4Z for ; Wed, 29 Aug 2018 11:51:34 +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="oKpmv8cL"; 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 420TBG4LhSzF1Rl for ; Wed, 29 Aug 2018 11:51:34 +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="oKpmv8cL"; 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:4864:20::643; helo=mail-pl1-x643.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="oKpmv8cL"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 420T9w1hpwzDrRN for ; Wed, 29 Aug 2018 11:51:16 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id u11-v6so1552254plq.5 for ; Tue, 28 Aug 2018 18:51:16 -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=tEh64l76SZVsLCeq6dKtJB2y/96EaXp+NjV8AkyiVis=; b=oKpmv8cLUgyBRb6vkZmkbLXwtVgyXTTQN9nggxO1NkUCo9mwH2ZV4mlceyFdS4et7a PsL4fQyydnIC/mFPvjcCxYwlu+JrU2oR2edstlgq65Ej/yDOJJTBNeJ2uUbG0gYDVUzO ZX9FN3RSWFUrdmlJE9Ueebp+g13qvOZuz8Qt1m+A05DD2keLSyQ3w1IAUoRkS+9TqsUA ehXowaoWdJYA2FePT9+bYo5sj6D+uG2q+m552NDN2ohBBejeSWjlkDPELO3w5PJHwBgN /74wOIXHzqrWueG9fmmyb77BjDJmHnvmTClrbupTgTPSdAXJiRW2IQtWDjJFrqRoIunL yfjQ== 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=tEh64l76SZVsLCeq6dKtJB2y/96EaXp+NjV8AkyiVis=; b=SHPvzgwRniOBvStTNTw9A1UL0ghsnGM1LmGAKfmiFRX2lfeEDGPr0UgOcYMy21Wab5 dc8YWwDHEhogzZjdyTKkutNPjlTptsCvZcwMHS2oyczUWRyWsOl0mGMMfV2qL+2i3ES0 X4Oo2LdFi2ixo5wKuznOky53zkIwxGohKKhCT/+paYlgzF73KrDyXZQDM3QCggXUrpsx V9cs0vcjYtfWl8IY5H9V9zcv865h4iPAZ/tCQRY38fv1fB1BI8CKxgODjS0AEKWkB82H wQWx5lSkktJtFSjxpWkKGT6qOK6Ahw57+Xo34WrOPQLygWc0od9phrtBss7UWyc5JVLd jxQw== X-Gm-Message-State: APzg51Caxqpla2Eka0XZMsHw2jPDsnu8nnmJJy77nyOI/iu+JWbmJsAM 8lOsA0D1Zsiesz6wACCt4q0Vm4Gr X-Google-Smtp-Source: ANB0VdYRA7GC+a14GO97oQ7l7HIDA9rYF0/cdhLPfAmyIUOJFEYj5efBYPJjOJTN7YlJLDu3BTFvqA== X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr3943015plk.127.1535507473666; Tue, 28 Aug 2018 18:51:13 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:13 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:34 +1000 Message-Id: <20180829015047.7355-7-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 06/19] libpdbg: Add in mtocrf and putcr function X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 26 ++++++++++++++++++++++++++ libpdbg/libpdbg.h | 1 + libpdbg/operations.h | 1 + 3 files changed, 28 insertions(+) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 31c8c80..7a93ab6 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -52,6 +52,20 @@ static uint64_t mfocrf(uint64_t reg, uint64_t cr) return MFOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); } +static uint64_t mtocrf(uint64_t cr, uint64_t reg) +{ + if (reg > 31) { + PR_ERROR("Invalid register specified for mfocrf\n"); + exit(1); + } + if (cr > 7) { + PR_ERROR("Invalid CR field specified\n"); + exit(1); + } + + return MTOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); +} + static uint64_t mfnia(uint64_t reg) { if (reg > 31) @@ -303,6 +317,18 @@ int ram_getcr(struct pdbg_target *thread, uint32_t *value) return 0; } +int ram_putcr(struct pdbg_target *thread, uint32_t value) +{ + uint64_t opcodes[] = {mfspr(0, 277), mtocrf(0, 0), mtocrf(1, 0), + mtocrf(2, 0), mtocrf(3, 0), mtocrf(4, 0), + mtocrf(5, 0), mtocrf(6, 0), mtocrf(7, 0)}; + uint64_t results[] = {value}; + + CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); + + return 0; +} + int ram_putmsr(struct pdbg_target *thread, uint64_t value) { uint64_t opcodes[] = {mfspr(0, 277), mtmsr(0)}; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 1239bba..25b2afd 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -143,6 +143,7 @@ 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, uint32_t *value); +int ram_putcr(struct pdbg_target *thread, uint32_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); diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 4735c55..a0ed2cd 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -65,6 +65,7 @@ #define MFSPR_OPCODE 0x7c0002a6UL #define MTSPR_OPCODE 0x7c0003a6UL #define MFOCRF_OPCODE 0x7c100026UL +#define MTOCRF_OPCODE 0x7C100120UL #define MFSPR_MASK (MFSPR_OPCODE | ((0x1f) << 16) | ((0x3e0) << 6)) #define MFXER_OPCODE (MFSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) #define MTXER_OPCODE (MTSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) From patchwork Wed Aug 29 01:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963199 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 420TBL0grbz9s4Z for ; Wed, 29 Aug 2018 11:51:38 +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="ILp8sLdK"; 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 420TBK42LlzF1p8 for ; Wed, 29 Aug 2018 11:51:37 +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="ILp8sLdK"; 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:4864:20::633; helo=mail-pl1-x633.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="ILp8sLdK"; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (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 420T9y1nl2zF1RN for ; Wed, 29 Aug 2018 11:51:18 +1000 (AEST) Received: by mail-pl1-x633.google.com with SMTP id ba4-v6so1542444plb.11 for ; Tue, 28 Aug 2018 18:51:18 -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=q8BWP/WhERPFHoyqsXLybbU/6D/ZCuaoFQG5Pfd1UZA=; b=ILp8sLdKylWiLSKVHS4lljZMsIRpcQsWnfkLh+DZDyV0Xx4APGrGmdTP6xLBWIhilb HhjJxuADbRRYePbLLnHNrRcoN2ipq/fXKkhEDyayIjzg4bWpF3ko0UElH2WlL/MJqugs FW0Zg3lrIQDD8fC2oHALVtqCf13wPXP9Iq4uxGivNmtAfawFhdj4BcirUh4dCmGW9atU HYjnreSb3kc48NkSjtQirxBHV9dSktHVxFQOqF2ygxGcspW3hetaH1t8Q4qXFaNPbxi3 A045HLQ+vKW5jOND5aXjvayK1wEA8cjnM0qrdER5maYiF999bOk3rhjtpeoMSuoKPXhj N/bQ== 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=q8BWP/WhERPFHoyqsXLybbU/6D/ZCuaoFQG5Pfd1UZA=; b=BO+drDbtN1od41JzeckhuP6GmE5/219qMQ0yGDuYpjAthxa57KoyEVlYer0jC6nxEg gaTgaIMGHurnjPISuP0YSqPA3y4lzFqwFdSb/VuM+8ffaPT2ZKKqREOt+J+Zd47LFI05 bNkrvjPwyUr/LU8dn2Z16Sh9z18i7cKkxnFRnRS1cdNBeNosszCQklu8CdtJSrBydK5U JaAI5Kx17FCIf8XpeQCoiXPYgN2tjIDJNPCkmOo1Ph0ukHGxwDlC8TofulZmbVKziBQ7 U5dwV2D+TW4sHMez3nIcUaBZAbM2VW8Qcf2lbIH1CVjvBzPICxzHS+EY/SlrGGqrmZmA xAZQ== X-Gm-Message-State: APzg51CfyqcQunpIqLYXLyKoAjdAfrJLCyzm6EXFPvavSa/Nqi6Hk8LF vvNAuxm2mppASlHicLGsqB3D/QLc X-Google-Smtp-Source: ANB0VdZdLgv3Gb5+GyskLPNsEpsfs7GaIuwaVL5syQ/mnL0y+FAEJHNJ7zaQJQ2ndUnVrlaUXbMQNw== X-Received: by 2002:a17:902:a716:: with SMTP id w22-v6mr3930003plq.334.1535507476098; Tue, 28 Aug 2018 18:51:16 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:15 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:35 +1000 Message-Id: <20180829015047.7355-8-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 07/19] pdbg: Add getcr and putcr options X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com 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 | 6 +++++- src/reg.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 5d840ef..ff3ee2b 100644 --- a/src/main.c +++ b/src/main.c @@ -86,7 +86,8 @@ extern struct optcmd_cmd optcmd_getnia, optcmd_putnia, optcmd_getmsr, optcmd_putmsr, optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, - optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; + optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer, + optcmd_getcr, optcmd_putcr; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -95,6 +96,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, + &optcmd_getcr, &optcmd_putcr, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -114,6 +116,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getcr", "", "Get Condition Register (CR)" }, + { "putcr", "", "Write Condition Register (CR)" }, { "getxer", "", "Get Fixed Point Exception Register (XER)" }, { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, diff --git a/src/reg.c b/src/reg.c index 3864316..fcf6f4c 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,6 +24,7 @@ #include "main.h" #include "optcmd.h" +#define REG_CR -5 #define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 @@ -45,6 +46,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("nia: "); else if (reg == REG_XER) printf("xer: "); + else if (reg == REG_CR) + printf("cr: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -68,6 +71,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putnia(target, *value); else if (*reg == REG_XER) rc = ram_putxer(target, *value); + else if (*reg == REG_CR) + rc = ram_putcr(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -89,6 +94,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getnia(target, &value); else if (*reg == REG_XER) rc = ram_getxer(target, &value); + else if (*reg == REG_CR) + rc = ram_getcr(target, (uint32_t *)&value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -169,3 +176,18 @@ static int putxer(uint64_t data) return for_each_target("thread", putprocreg, ®, &d); } OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); + +static int getcr(void) +{ + uint64_t cr = REG_CR; + return for_each_target("thread", getprocreg, &cr, NULL); +} +OPTCMD_DEFINE_CMD(getcr, getcr); + +static int putcr(uint32_t data) +{ + uint64_t cr = REG_CR; + uint64_t d = data; + return for_each_target("thread", putprocreg, &cr, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putcr, putcr, (DATA32)); From patchwork Wed Aug 29 01:50:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963200 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 420TBN5qjWz9s4Z for ; Wed, 29 Aug 2018 11:51:40 +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="Q2nRAatE"; 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 420TBN3gPlzF1Zs for ; Wed, 29 Aug 2018 11:51:40 +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="Q2nRAatE"; 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:4864:20::534; helo=mail-pg1-x534.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="Q2nRAatE"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 420TB02cDjzDrRN for ; Wed, 29 Aug 2018 11:51:20 +1000 (AEST) Received: by mail-pg1-x534.google.com with SMTP id y3-v6so363955pgv.0 for ; Tue, 28 Aug 2018 18:51:20 -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=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=Q2nRAatEW/UY/M3MqGsdRyr6vWNeBXN20Ytmz3JSPRxUeTjnVa3NHEH0hCVaHNnJw/ H9ZNwS6gFFG5m0aINZGTQSUFtzhQX67bXw12cwfNytpX9cztlbiDam1bje7IFB7UK5/j 4ouCG46FspC460xNBVBk0E1+BclanWgjKsVp11F7P/dUuPKeadTMpEfuexJAwuMX542/ BIpsTnf2MYbFekB7DoqvtkN3VuNSqPT2DtsRL9f73kDrgyGZeMXWei9pP5a9YHCTApYr Nd49iS/Ea7GMfBH74Z9qsAY067LleORC23ZP1aQz4UpWugid12wrP/VZKqjIufz1eHeQ N44A== 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=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=LC1Ohf5ULxD5EPi5WhTIzSgAfUA96QxgULs4r5GOA2mdtghN1Gw1PfpsN5PKx3XSCq ayK3u71mT+h23x8bAuPmNPbi+gfTnDPt1XNu2JYTrFQ+ihz28nndUD9Wrndoo9mnlyT/ 6bw9iGnH+kU4TythUf1hklP+9mxa3ZO0UKeLNo0fCUmZzcduw+AcAoy3iFjHffFsvrOr BMjZtxRx2ANtatA3eUb0y3CXlDW33MQbjyMEQLy0qGa+5x7sWKZBn6y+EPajlKkyBODL imp68x6u0wzSIX06HOWfmbaKr/R9KAxM6Re83+WlBGkhcqqpgYt6gV2OBJAyeGxamhOn +kvQ== X-Gm-Message-State: APzg51CPtC1kSobVuwXSuBYtICHkak1orrsVnubjy//uADEG0+iIaC12 8AKtC1hQ5nrP89sbqWEzCZ9liU6F X-Google-Smtp-Source: ANB0VdYq8LMuUVouQXw/OqdxoMZE4l/zO1n3lOXpAJnJZbSku6VCa3a44NyIGrUYkJwgbHoF7x8zDw== X-Received: by 2002:a62:5ec3:: with SMTP id s186-v6mr3800043pfb.146.1535507478493; Tue, 28 Aug 2018 18:51:18 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:18 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:36 +1000 Message-Id: <20180829015047.7355-9-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 08/19] libpdbg: Check if scom controllers are exposed X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If CONFIG_SCOM_DEBUGFS is not set in the running kernel then the scom controllers are not exposed and so using getscom won't work. Add check for /sys/kernel/debug/powerpc/scom to give a more useful error message. Signed-off-by: Rashmica Gupta --- libpdbg/host.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libpdbg/host.c b/libpdbg/host.c index 483e048..eb627be 100644 --- a/libpdbg/host.c +++ b/libpdbg/host.c @@ -95,7 +95,15 @@ static int host_pib_probe(struct pdbg_target *target) if (chip_id == -1) goto out; - if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip_id) < 0) + /* This check should probably be done earlier */ + if (access(XSCOM_BASE_PATH, F_OK) == -1) + { + PR_ERROR("Can not access %s. ", XSCOM_BASE_PATH); + PR_ERROR("Is CONFIG_SCOM_DEBUGFS set? "); + PR_ERROR("You may need to re-run the command as root.\n"); + } + + if (asprintf(&access_fn, "%s/%08d/access", XSCOM_BASE_PATH, chip_id) < 0) goto out; *fd = open(access_fn, O_RDWR); From patchwork Wed Aug 29 01:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963201 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 420TBR6dHhz9s55 for ; Wed, 29 Aug 2018 11:51:43 +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="JJ2/imcO"; 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 420TBR44HtzF0ph for ; Wed, 29 Aug 2018 11:51:43 +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="JJ2/imcO"; 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:4864:20::630; helo=mail-pl1-x630.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="JJ2/imcO"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 420TB311xFzF1Zs for ; Wed, 29 Aug 2018 11:51:22 +1000 (AEST) Received: by mail-pl1-x630.google.com with SMTP id x6-v6so1544155plv.10 for ; Tue, 28 Aug 2018 18:51:22 -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=THaqbly1EFkncv0LtlEAZ0RuBbLEC8BssUbbp0ZZUww=; b=JJ2/imcO1imHRKAzT3g0dpVs/2BNgwwlqA5lVnYRjB7X02V4GZqU4ERZmeEvITmKlE O3c6P/m0uv6u0ykCB2By3drqk+aoafPqU3f6BnEwmKNOr6rQlxNaI9gr6sveiGXhnSKC penN2SXOup2mkLe81T0G1vsitZ25MSYtpITVuvkoeUTsuBCILS8F9efyvLwF81u4phQI h/i+vJ3t5IydpTlTxk7yfLIC0bhddA3v7J6imw7HehLPBuFt4kPs014Z7F8Uo79U8LBO KdUSMP1KsbvV60ST2EqciyKV3fNgLslpa40Egx95/uHQMgIGINRiMSZtWISFpSiffbuj +7Ng== 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=THaqbly1EFkncv0LtlEAZ0RuBbLEC8BssUbbp0ZZUww=; b=JMhY3fDVsX/lsUwYsakSKGvy0b8ZIZ4uOxJbd+KDBezLbtbTPsa2uY7mnncueY8y1u NLVB4fHaOEGgGnyBFUXQ/OFN1Nde5YRQLcqgtcde4QoZOmS6fURNr2sSNKL0AcqfIfw+ FzCyhKIGH1v6tKSXM4xN2LCV4ovr2ps1CtQeE04zkaeE01YNQ1rvqNXMZgeCftXiz4jJ ngcP58AUM05DFZon6lK61x+S20Mv9iiKk+zh4ms+lSIfTZiWX7+zz2lcka6wUyDdLSSg c20KSBsolFWJN21y7dWdi2lQ6/IJpoXfKcj9F4PDVMRuUG7sb8JVaSg2lzXFiYWmdRbE qaag== X-Gm-Message-State: APzg51A2NljEq5+1qNCiaFcNHlMNKTiqxcwh+t8CXGO7GGnDmVZSqezs 0x6FkDfeeRxyCJ2VELxRtH+NVLNd X-Google-Smtp-Source: ANB0Vdaolfa/ocDI1COJU6bRHBnR0Yv6IH2UIZilKilggkoJOjwo7YKjipQGOt7oQUd2lGIF+CI/vA== X-Received: by 2002:a17:902:528a:: with SMTP id a10-v6mr3835612pli.199.1535507480881; Tue, 28 Aug 2018 18:51:20 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:20 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:37 +1000 Message-Id: <20180829015047.7355-10-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 09/19] pdbg: Make return codes consistent for get/put registers X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" --- src/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reg.c b/src/reg.c index fcf6f4c..1daa7b6 100644 --- a/src/reg.c +++ b/src/reg.c @@ -103,7 +103,7 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, print_proc_reg(target, *reg, value, rc); - return !rc; + return rc; } static int getgpr(int gpr) From patchwork Wed Aug 29 01:50:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963202 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 420TBX1VBgz9s1x for ; Wed, 29 Aug 2018 11:51:48 +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="awNGYVYH"; 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 420TBW6c1kzF13F for ; Wed, 29 Aug 2018 11:51:47 +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="awNGYVYH"; 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:4864:20::635; helo=mail-pl1-x635.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="awNGYVYH"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 420TB523YkzF1nb for ; Wed, 29 Aug 2018 11:51:25 +1000 (AEST) Received: by mail-pl1-x635.google.com with SMTP id 60-v6so1565491ple.0 for ; Tue, 28 Aug 2018 18:51:25 -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=kwP1xDuLC2kMpxqUngPXl4vC9B2wJYxtuqOUtBt1Y3Y=; b=awNGYVYH7wq99E+7LP7+75COY3e1u60m6Apn3D9d3GzOEXM4r/MLj1mVxO+88mFM+e zh6Mibcyym2a2H8SBaruH6sdNhBKQQaOwqXqwT07Ae6fuJZAjYCzp29WjsSLOXV6ciPz RU98/1FiODTG3LKtdWVgAUW2ETrnrDH8+XpVWvvuksWp5ycluFXgflHCOs5IyED1X7++ DAiMJtwM8b+bSxrkCPsPvXaYzaUs75lMwVOQuqOABkuKwKwaFuRgbGyBV6AMc8rzL0Z1 cfsKPsV3CLDJ+YCY8sbY5VbD36bX+4sLb04Sthdf3i7LbF4HQj8kBlsesuC5nO0Bf9El UxnQ== 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=kwP1xDuLC2kMpxqUngPXl4vC9B2wJYxtuqOUtBt1Y3Y=; b=JB0GtwHaTKUutFO4opq7nhxSAY1aRFhUXAIOrBJaZCcKz8Ltc0FN4xClRwfJP7suMn IUFZzPpsB0a/6UXagMks93OazilZOlgEv8GoL0N1tkoiExz+2clsX6/ku+u5x+G1iRba 4MWGEFVvEo5GcLtF8GxQKfYb5Qejw8wKACNFZwl3Fdu2EzZJaK3z/gMl2iCTImOdlZM5 Tf5iuu6Ae/EmkPsqSaF/JXudr5viEZfpzkVidV4hRViGBv3V6r2IvYnuA1rzfxcnJWVp a5PzgaihG7FWU6gJXyxJGZx/NQT2R6Q1hW8A4Q0HTEDumfBvGi16W+UF2rVY2dgfP0Xh Ap4A== X-Gm-Message-State: APzg51CUOokqZW3JiX5mrI5cffKaY7LcVFVmpnEIApAvsraJp8My485T kEC6GRC6tmm2jLTB+ltrJz6vYnbb X-Google-Smtp-Source: ANB0VdZht9/fsx3ljsC+JAQa6oCxWGJ1WAzKvHaantZrhdydrbfrOGYl7Gm1cr9So2iA4WH13mj4Ug== X-Received: by 2002:a17:902:934c:: with SMTP id g12-v6mr3875466plp.67.1535507483243; Tue, 28 Aug 2018 18:51:23 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:22 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:38 +1000 Message-Id: <20180829015047.7355-11-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 10/19] libpdbg: Remove unused error code X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" --- libpdbg/operations.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libpdbg/operations.h b/libpdbg/operations.h index a0ed2cd..93e5df5 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -20,9 +20,6 @@ #include "target.h" #include "debug.h" -/* Error codes */ -#define EFSI 1 - #define PRINT_ERR PR_DEBUG("failed\n"); #define CHECK_ERR(x) do { \ if (x) { \ From patchwork Wed Aug 29 01:50:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963203 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 420TBb1MP5z9s1x for ; Wed, 29 Aug 2018 11:51: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="VxzZJ+AZ"; 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 420TBZ6FT1zF1RN for ; Wed, 29 Aug 2018 11:51:50 +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="VxzZJ+AZ"; 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:4864:20::62e; helo=mail-pl1-x62e.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="VxzZJ+AZ"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 420TB73j32zF0ph for ; Wed, 29 Aug 2018 11:51:27 +1000 (AEST) Received: by mail-pl1-x62e.google.com with SMTP id e11-v6so1559159plb.3 for ; Tue, 28 Aug 2018 18:51:27 -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=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=VxzZJ+AZMeBsqz/jAm6pF26unmSpULfrXn40QNd0EkEpgATFKvdWXDKzXQzoumW/p8 2MFx+DeoqxxE/r9sV40OiudH/+T8xdmIirZVTe11ToOS56VV9enENDjvSPJAQmPbUklI MH7wCnx3L0tvypqmbRGrFFimMQA3atSrwRHAZSRGdOJRuuF9GHNUavTZ3De73UqsYR54 zdmMdh0d0CuLQeotgekxECvC2M1+ihXFxNETuIDlUPBzAwtjKSmaccBVIw0J4QRuASfo c4SMwDl6OhkaCx4WrJwhOkVJLI6nS6kZua4ZoWcQ1pdETOLi8f8IzcwDH4JQp3QEz7B+ aGaw== 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=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=tIa7d4s1jNjMoW0M5ABvq4aeZoybHwWis068L8iR0A9vf++e8zWYktGBQN2vdDrH++ a3aL7P3ZDx6vPpttQNM9wMyUi2yH+lAQ4P5zKPZO5fzhYIdyEH/fYCtrp0fft0IgthbA 01kFlLWFhnweSK8FI/rAWMDWrpX3mXws4CDkgujY45QQAut4hxbdiauxGFVLrAOlZeqs cmLsfh9wHf0II3K0NlTNIN3MKAov47+TtPEbtzzEwDRi0VTjDbfbwCEWrmkumYbyShc6 DY/SjfnUu7DO/5v4WYVqAEyN6OopDJsesxOnMZIqcP8e+hIUGPok9WVburjE6RyTshux 1TWg== X-Gm-Message-State: APzg51C9e70h4MPsfvywLMBa09EjeYtSrNpaaZgBBSEApDjCLS1u2yWa DYx4V/afTeOhtS/fbZV9GVWMOeYj X-Google-Smtp-Source: ANB0VdYUk7+1MmKzTpoCXywj6bY1IETJf5+bObEl8PFXhgmrNrL0cAgpx6w2Li3t9YBFM0m1WrUMiA== X-Received: by 2002:a17:902:187:: with SMTP id b7-v6mr3886856plb.269.1535507485615; Tue, 28 Aug 2018 18:51:25 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:25 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:39 +1000 Message-Id: <20180829015047.7355-12-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 11/19] pdbg: Add in parser for uint16_t X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/parsers.c | 18 ++++++++++++++++++ src/parsers.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/parsers.c b/src/parsers.c index 6cbe06d..868c383 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -37,6 +37,24 @@ uint32_t *parse_number32(const char *argv) return n; } +uint16_t *parse_number16(const char *argv) +{ + unsigned long long tmp; + uint16_t *n = malloc(sizeof(*n)); + char *endptr; + + if (!argv) + return NULL; + + errno = 0; + tmp = strtoul(argv, &endptr, 0); + if (errno || *endptr != '\0' || tmp > UINT16_MAX) + return NULL; + + *n = tmp; + return n; +} + /* Parse a GPR number, returning an error if it's greater than 32 */ int *parse_gpr(const char *argv) { diff --git a/src/parsers.h b/src/parsers.h index b5f23cf..935c242 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -8,12 +8,14 @@ #define ADDRESS32 (parse_number32, NULL) #define DATA (parse_number64, NULL) #define DATA32 (parse_number32, NULL) +#define DATA16 (parse_number16, NULL) #define DEFAULT_DATA(default) (parse_number64, default) #define GPR (parse_gpr, NULL) #define SPR (parse_spr, NULL) uint64_t *parse_number64(const char *argv); uint32_t *parse_number32(const char *argv); +uint16_t *parse_number16(const char *argv); int *parse_gpr(const char *argv); int *parse_spr(const char *argv); bool *parse_flag_noarg(const char *argv); From patchwork Wed Aug 29 01:50:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963205 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 420TBf0HSJz9s4Z for ; Wed, 29 Aug 2018 11:51:54 +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="d0TjRFEr"; 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 420TBd5XbkzF1Rl for ; Wed, 29 Aug 2018 11:51:53 +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="d0TjRFEr"; 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:4864:20::52f; helo=mail-pg1-x52f.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="d0TjRFEr"; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 420TB95CNLzF1PV for ; Wed, 29 Aug 2018 11:51:29 +1000 (AEST) Received: by mail-pg1-x52f.google.com with SMTP id d1-v6so1587883pgo.3 for ; Tue, 28 Aug 2018 18:51:29 -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=Yj2CJv4PWueqyvXH1GRb3wfH66Ch/jam4mCS2lGSZvE=; b=d0TjRFErefGEutxPsHg3Y/wKMSzO2dgmpvG0WkqehdyIlU6n7qsVe12Hc6xVzHntKA 4Yy9RK4tXh6RiaPc0wQM3G1ui5ENEy00ukqzfWdOBFGnk2N8a0ffdXfprMVXYWumlklc 1eTm6Gj0sEuAr7NxES+a8iHuSeYSrIZUzG9rqXvhXGeIJuPYLA9eH+TllZu8R1epjmPX blI3ZQ50vi2VP8Se8IS7p+r/inZjJWUos05J0xrTW2aKI+n3mLyY4xPcnaAajk+1Ys9+ jR2dLAu7wakK4oOnEzjBuXhPpV+VkYZ1EEXoGhAjGae21XxwB55rbET4q+9K4vlRQG01 u2yA== 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=Yj2CJv4PWueqyvXH1GRb3wfH66Ch/jam4mCS2lGSZvE=; b=uSGumHQd8OFiCUDfMgmPMBXpksNou88fvkSWkbCGpRIXSu5hTLtOpKUyoZmcaNnM+h t5R4vxPwAZsU7hQZzFU+l3RPHFbAOtJWiB91YOBHbxASyXVUcpGo6iyLfbR6S/7nvero hfm3sGGlJi98E22yhHJKpsmRgseYSuUHbre1FxrxRWUZ5syL4egp0ZzAL1GUFzaoDNwF /XymU/l3Kxb5HIp+4iqD22KqHmyyfDZ/FRQ1QQnNPUNkq2vg3cgr6KjcCytd7Trv7PI6 hJZATB9q1otUv8CbAJtdVVcIV4vnDBW1ZqgTWCm5hn+K/vtsPQW0lCiOmHRravKQ9gg2 X7tw== X-Gm-Message-State: APzg51DfU0x8fMm12tPIQs7csifT7+mjNZdsSOiLRCtwTBYWSPMJwlOZ BUzVlIgE8aeeo1BtVHA+vUr7Seoj X-Google-Smtp-Source: ANB0VdYtq/y2UIt0tWRmsHIg9cx37BQz1MazlgiL8lPCNCyWlOL9Hx1n6PloJB8alrzL50sy0dIMaQ== X-Received: by 2002:a63:e355:: with SMTP id o21-v6mr3828532pgj.251.1535507488002; Tue, 28 Aug 2018 18:51:28 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:27 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:40 +1000 Message-Id: <20180829015047.7355-13-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 12/19] libpdbg: Add in enable_attn function for p8 X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/p8chip.c | 41 +++++++++++++++++++++++++++++++++++++++++ libpdbg/target.h | 1 + 2 files changed, 42 insertions(+) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 89ecfd6..2f1d599 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -82,6 +82,8 @@ #define FSP_SPECIAL_WAKEUP PPC_BIT(0) #define EX_PM_GP0_REG 0xf0100 #define SPECIAL_WKUP_DONE PPC_BIT(31) +#define HID0_REG 0x1329c +#define EN_ATTN PPC_BIT(31) /* p8 specific opcodes for instruction ramming*/ #define MTXERF0_OPCODE 0x00000008UL @@ -483,6 +485,44 @@ static int p8_thread_probe(struct pdbg_target *target) return 0; } +static int p8_get_hid0(struct pdbg_target *chip, uint64_t *value) +{ + CHECK_ERR(pib_read(chip, HID0_REG, value)); + return 0; +} + +static int p8_put_hid0(struct pdbg_target *chip, uint64_t value) +{ + CHECK_ERR(pib_write(chip, HID0_REG, value)); + return 0; +} + +static int p8_enable_attn(struct pdbg_target *target) +{ + struct pdbg_target *core; + uint64_t hid0; + + core = pdbg_target_parent("core", target); + if (core == NULL) + { + PR_ERROR("CORE NOT FOUND\n"); + return 1; + } + + /* Need to enable the attn instruction in HID0 */ + if (p8_get_hid0(core, &hid0)) { + PR_ERROR("Unable to get HID0\n"); + return 1; + } + hid0 |= EN_ATTN; + + if (p8_put_hid0(core, hid0)) { + PR_ERROR("Unable to set HID0\n"); + return 1; + } + return 0; +} + static struct thread p8_thread = { .target = { .name = "POWER8 Thread", @@ -499,6 +539,7 @@ static struct thread p8_thread = { .ram_destroy = p8_ram_destroy, .ram_getxer = p8_ram_getxer, .ram_putxer = p8_ram_putxer, + .enable_attn = p8_enable_attn, }; DECLARE_HW_UNIT(p8_thread); diff --git a/libpdbg/target.h b/libpdbg/target.h index 8bad405..c8da048 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -155,6 +155,7 @@ struct thread { int (*ram_destroy)(struct thread *); int (*ram_getxer)(struct pdbg_target *, uint64_t *value); int (*ram_putxer)(struct pdbg_target *, uint64_t value); + int (*enable_attn)(struct pdbg_target *); }; #define target_to_thread(x) container_of(x, struct thread, target) From patchwork Wed Aug 29 01:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963206 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 420TBh59YPz9s1x for ; Wed, 29 Aug 2018 11:51:56 +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="HOneSlX9"; 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 420TBh3T4dzF0kx for ; Wed, 29 Aug 2018 11:51:56 +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="HOneSlX9"; 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:4864:20::644; helo=mail-pl1-x644.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="HOneSlX9"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 420TBD46FSzF1RN for ; Wed, 29 Aug 2018 11:51:32 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id j8-v6so1536094pll.12 for ; Tue, 28 Aug 2018 18:51:32 -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=8YalD+mC3wq6MxKGNeFPSxZJKO2eGxa3dWILkZO3G0g=; b=HOneSlX9euLFhCi6JwLVqhYwUSs3yyB+6UTZBm3jybtKR33Ysfb+7WH01pluF8BzaK RWZF8tDpqPDkFUOukEvi46JQpMuxt69ru8W/ijSyELVVcQq5mFMEhSYD96h61X/6kRAn zyOeYU4eDDxDcq3odu0bV/LkDz3BvuwHnQySOktn1LCRLGHPyY5a+DDQYGtzxhtTygMd pS9ipQ1JJmhg+K9PCUhsCcdgNrrvc1qRWw2qfwhfZQJ4S/vJg9+Ma6MC6iM8r3DaXPu8 K19g2BjAWNklZjgNPePjiQN4NhvFvjrdjFTXD6Pb5zUN51cwJirVJbZcKlUIYMZZt7Q4 MmZA== 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=8YalD+mC3wq6MxKGNeFPSxZJKO2eGxa3dWILkZO3G0g=; b=Kz2yq69GE5KMspblhRuiKf0vo2UgEXTEfgXBrEakf4imCfNpGxQtdjbitHJyuuyj1X pi8OnFUf+5HVSHybOuzV0CDPEFVsEdx2ejgEPFr2/HVNZ3O3Dpq/3wpOj9iD8zClhaP1 SnaQUE3+EvcJMM6Jhogr2XH8DIoj+7JXK+Mi5CbRSYgDC8Cn3uR4iOeWBBG+WlH+Eljx 4BFUd7+YDLYxr11FN2be8kkVFgnXaqBkiQSm9GKE34BvieilbQUvdtulzz+M0GAkBXgx udA1qGakgsVVn7ReOcQHNQvxDUZkE8gYVXREB2tBjei8esVSFJzReZRrJGbKSuU3qF+4 m/tg== X-Gm-Message-State: APzg51ASPduG5P4QmI0Gujr6rPc1hqBvQmQfX+VNa734cFd//+m5dB0P 8hHtoCmfysvBf57NO3Qq3C6lzcny X-Google-Smtp-Source: ANB0VdYjrKBNiL+4CQ85/H+vAkndisJRK5UYIwyFL1cTh7iPFR6Ld0Y/1f04l5J252CaRuwVQHnTxw== X-Received: by 2002:a17:902:6b4c:: with SMTP id g12-v6mr3940723plt.159.1535507490567; Tue, 28 Aug 2018 18:51:30 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:30 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:41 +1000 Message-Id: <20180829015047.7355-14-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 13/19] pdbg/gdbserver: Add in basic skeleton for a gdbserver on p8 X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Alistair Popple I have changed a few bits here and there but this patch is largely authored by Alistair Popple. Signed-off-by: Rashmica Gupta --- .gitignore | 1 + Makefile.am | 13 +- configure.ac | 3 + libpdbg/libpdbg.h | 1 + libpdbg/operations.h | 3 - libpdbg/target.c | 16 ++ libpdbg/target.h | 3 + src/gdb_parser.rl | 143 ++++++++++++++++ src/main.c | 6 +- src/pdbgproxy.c | 476 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/pdbgproxy.h | 13 ++ 11 files changed, 671 insertions(+), 7 deletions(-) create mode 100644 src/gdb_parser.rl create mode 100644 src/pdbgproxy.c create mode 100644 src/pdbgproxy.h diff --git a/.gitignore b/.gitignore index c25b053..79f1ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ optcmd_test *.trs *.log test-driver +src/gdb_parser.c diff --git a/Makefile.am b/Makefile.am index 1397b0a..5b78624 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,7 +77,9 @@ pdbg_SOURCES = \ src/optcmd.h \ src/options.h \ src/parsers.h \ - src/progress.h + src/progress.h \ + src/pdbgproxy.c \ + src/gdb_parser.c pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \ -L.libs -lrt @@ -157,6 +159,10 @@ GEN_V = $(GEN_V_$(V)) GEN_V_ = $(GEN_V_$(AM_DEFAULT_VERBOSITY)) GEN_V_0 = @echo " GEN " $@; +RAGEL_V = $(RAGEL_V_$(V)) +RAGEL_V_ = $(RAGEL_V_$(AM_DEFAULT_VERBOSITY)) +RAGEL_V_0 = @echo " RAGEL " $@; + %.dts: %.dts.m4 $(M4_V)$(M4) -I$(dir $<) $< | $(DTC) -I dts -O dts > $@ @@ -177,4 +183,7 @@ p9z-fsi.dts: p9z-fsi.dts.m4 p9-fsi.dtsi %.dtb.o: %.dtb $(AM_V_CC)$(CC) -c $(srcdir)/template.S -DSYMBOL_PREFIX=$(shell echo $@ | tr '.-' '_') -DFILENAME=\"$<\" -o $@ -MOSTLYCLEANFILES = *.dtb *.dts *.dt.h p9-fsi.dtsi +%.c: %.rl + $(RAGEL_V)$(RAGEL) -o $@ $< + +MOSTLYCLEANFILES = *.dtb *.dts *.dt.h p9-fsi.dtsi src/gdb_parser.c diff --git a/configure.ac b/configure.ac index e48e80f..3486969 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,9 @@ if test x"$ac_cv_path_DTC" = x ; then fi AC_SUBST([DTC]) +AC_PATH_PROG([RAGEL], [ragel]) +AC_SUBST([RAGEL]) + AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 25b2afd..869d553 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -138,6 +138,7 @@ struct thread_regs { }; int ram_putmsr(struct pdbg_target *target, uint64_t val); +int ram_getmem(struct pdbg_target *thread, uint64_t addr, uint64_t *value); 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); diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 93e5df5..96a7c01 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -70,9 +70,6 @@ #define MXSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) -/* GDB server functionality */ -int gdbserver_start(uint16_t port); - enum fsi_system_type {FSI_SYSTEM_P8, FSI_SYSTEM_P9W, FSI_SYSTEM_P9R, FSI_SYSTEM_P9Z}; enum chip_type get_chip_type(uint64_t chip_id); diff --git a/libpdbg/target.c b/libpdbg/target.c index 88ae94a..997db3b 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -391,3 +391,19 @@ void pdbg_target_priv_set(struct pdbg_target *target, void *priv) { target->priv = priv; } + +int poll_target(struct pdbg_target *target, uint64_t addr, uint64_t mask, uint64_t *value) +{ + uint64_t val, val1; + int rc = 0; + + do { + pib_read(target, addr, &val); + rc = pib_read(target, addr, &val1); + if (val != val1) + continue; + } while ((val & mask) != *value); + + *value = val; + return rc; +} diff --git a/libpdbg/target.h b/libpdbg/target.h index c8da048..c6b715d 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -165,4 +165,7 @@ struct chiplet { int (*getring)(struct chiplet *, uint64_t, int64_t, uint32_t[]); }; #define target_to_chiplet(x) container_of(x, struct chiplet, target) + +int poll_target(struct pdbg_target *target, uint64_t addr, uint64_t mask, uint64_t *value); + #endif diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl new file mode 100644 index 0000000..18dfac7 --- /dev/null +++ b/src/gdb_parser.rl @@ -0,0 +1,143 @@ +#include +#include +#include +#include + +#include "src/pdbgproxy.h" + +%%{ + machine gdb; + + action reset { + cmd = 0; + rsp = NULL; + data = stack; + memset(stack, 0, sizeof(stack)); + crc = 0; + } + + action crc { + crc += *p; + } + + action push { + data++; + assert(data < &stack[10]); + } + + action hex_digit { + *data *= 16; + + if (*p >= '0' && *p <= '9') + *data += *p - '0'; + else if (*p >= 'a' && *p <= 'f') + *data += *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') + *data += *p - 'A' + 10; + } + + action end { + /* *data should point to the CRC */ + if (crc != *data) { + printf("CRC error\n"); + send_nack(priv); + } else { + printf("Cmd %d\n", cmd); + send_ack(priv); + + /* Push the response onto the stack */ + if (rsp) + *data = (uintptr_t)rsp; + else + *data = 0; + + command_callbacks[cmd](stack, priv); + } + } + + get_mem = ('m' @{cmd = GET_MEM;} + xdigit+ $hex_digit %push + ',' + xdigit+ $hex_digit %push); + + put_mem = ('M' any* @{cmd = PUT_MEM;} + xdigit+ $hex_digit %push + ',' + xdigit+ $hex_digit %push + ':' + xdigit+ $hex_digit %push); + + get_gprs = ('g' @{cmd = GET_GPRS;}); + + get_spr = ('p' @{cmd = GET_SPR;} + xdigit+ $hex_digit %push); + + stop_reason = ('?' @{cmd = STOP_REASON;}); + + set_thread = ('H' any* @{cmd = SET_THREAD;}); + + # TODO: We don't actually listen to what's supported + q_attached = ('qAttached:' xdigit* @{rsp = "1";}); + q_C = ('qC' @{rsp = "QC1";}); + q_supported = ('qSupported:' any* @{rsp = "multiprocess+;vContSupported+";}); + qf_threadinfo = ('qfThreadInfo' @{rsp = "m1l";}); + + # vCont packet parsing + v_contq = ('vCont?' @{rsp = "vCont;c;C;s;S";}); + v_contc = ('vCont;c' any* @{cmd = V_CONTC;}); + v_conts = ('vCont;s' any* @{cmd = V_CONTS;}); + + interrupt = (3 @{command_callbacks[INTERRUPT](stack, priv);}); + + commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread | + q_attached | q_C | q_supported | qf_threadinfo | q_C | + v_contq | v_contc | v_conts | put_mem ); + + cmd = ((commands & ^'#'*) | ^'#'*) $crc + ('#' xdigit{2} $hex_digit @end); + + # We ignore ACK/NACK for the moment + ack = ('+'); + nack = ('-'); + + main := (( ^('$' | interrupt)*('$' | interrupt) @reset) (cmd | ack | nack))*; + +}%% + +static enum gdb_command cmd = NONE; +static uint64_t stack[10], *data = stack; +static char *rsp; +static uint8_t crc; +static int cs; + +command_cb *command_callbacks; + +%%write data; + +void parser_init(command_cb *callbacks) +{ + %%write init; + + command_callbacks = callbacks; +} + +int parse_buffer(char *buf, size_t len, void *priv) +{ + char *p = buf; + char *pe = p + len + 1; + + %%write exec; + + return 0; +} + +#if 0 +int main(int argc, char **argv) +{ + parser_init(NULL); + + if (argc > 1) + parse_buffer(argv[1], strlen(argv[1]), NULL); + return 0; +} +#endif diff --git a/src/main.c b/src/main.c index ff3ee2b..82978d9 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "htm.h" #include "options.h" #include "optcmd.h" +#include "pdbgproxy.h" #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) @@ -87,7 +88,7 @@ extern struct optcmd_cmd optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer, - optcmd_getcr, optcmd_putcr; + optcmd_getcr, optcmd_putcr, optcmd_gdbserver; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -96,7 +97,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, - &optcmd_getcr, &optcmd_putcr, + &optcmd_getcr, &optcmd_putcr, &optcmd_gdbserver, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -135,6 +136,7 @@ static struct action actions[] = { { "threadstatus", "", "Print the status of a thread" }, { "sreset", "", "Reset" }, { "regs", "", "State" }, + { "gdbserver", "", "Start a gdb server" }, }; static void print_usage(char *pname) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c new file mode 100644 index 0000000..7a7da41 --- /dev/null +++ b/src/pdbgproxy.c @@ -0,0 +1,476 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "pdbgproxy.h" +#include "main.h" +#include "optcmd.h" + +/* Maximum packet size */ +#define BUFFER_SIZE 8192 + +#define PR_ERROR(x, args...) \ + pdbg_log(PDBG_ERROR, x, ##args) + +static struct pdbg_target *thread_target = NULL; +static struct timeval timeout; +static int poll_interval; +static int fd = -1; +enum client_state {IDLE, SIGNAL_WAIT}; +static enum client_state state = IDLE; + +static uint8_t gdbcrc(char *data) +{ + uint8_t crc = 0; + int i; + + for (i = 0; i < strlen(data); i++) + crc += data[i]; + + return crc; +} + +static void send_response(int fd, char *response) +{ + int len; + char *result; + + len = asprintf(&result, "$%s#%02x", response, gdbcrc(response)); + printf("Send: %s\n", result); + send(fd, result, len, 0); + free(result); +} + +void send_nack(void *priv) +{ + printf("Send: -\n"); + send(fd, "-", 1, 0); +} + +void send_ack(void *priv) +{ + printf("Send: +\n"); + send(fd, "+", 1, 0); +} + +static void set_thread(uint64_t *stack, void *priv) +{ + send_response(fd, "OK"); +} + +static void stop_reason(uint64_t *stack, void *priv) +{ + send_response(fd, "S05"); +} + +/* 32 registers represented as 16 char hex numbers with null-termination */ +#define REG_DATA_SIZE (32*16+1) +static void get_gprs(uint64_t *stack, void *priv) +{ + char data[REG_DATA_SIZE] = ""; + uint64_t regs[32]; + int i; + + for (i = 0; i < 32; i++) { + if (ram_getgpr(thread_target, i, ®s[i])) + PR_ERROR("Error reading register %d\n", i); + printf("r%d = 0x%016lx\n", i, regs[i]); + snprintf(data + i*16, 17, "%016lx", __builtin_bswap64(regs[i])); + } + + send_response(fd, data); +} + +static void get_spr(uint64_t *stack, void *priv) +{ + char data[REG_DATA_SIZE]; + uint64_t value; + + switch (stack[0]) { + case 0x40: + /* Get PC/NIA */ + if (ram_getnia(thread_target, &value)) + PR_ERROR("Error reading NIA\n"); + snprintf(data, REG_DATA_SIZE, "%016lx", __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x43: + /* Get LR */ + if (ram_getspr(thread_target, 8, &value)) + PR_ERROR("Error reading LR\n"); + snprintf(data, REG_DATA_SIZE, "%016lx", __builtin_bswap64(value)); + send_response(fd, data); + break; + + default: + send_response(fd, "xxxxxxxxxxxxxxxx"); + break; + } +} + +#define MAX_DATA 0x1000 + +/* Returns a real address to use with adu_getmem or -1UL if we + * couldn't determine a real address. At the moment we only deal with + * kernel linear mapping but in future we could walk that page + * tables. */ +static uint64_t get_addr(uint64_t addr) +{ + if (GETFIELD(PPC_BITMASK(0, 3), addr) == 0xc) + /* Assume all 0xc... addresses are part of the linux linear map */ + addr &= ~PPC_BITMASK(0, 1); + else + addr = -1UL; + + return addr; +} + +static void get_mem(uint64_t *stack, void *priv) +{ + struct pdbg_target *adu; + uint64_t addr, len, linear_map; + int i, err = 0; + uint64_t data[MAX_DATA/sizeof(uint64_t)]; + char result[2*MAX_DATA]; + + /* stack[0] is the address and stack[1] is the length */ + addr = stack[0]; + len = stack[1]; + + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) + break; + } + + if (adu == NULL) { + PR_ERROR("ADU NOT FOUND\n"); + err=3; + goto out; + } + + if (len > MAX_DATA) { + printf("Too much memory requested, truncating\n"); + len = MAX_DATA; + } + + if (!addr) { + err = 2; + goto out; + } + + linear_map = get_addr(addr); + if (linear_map != -1UL) { + if (adu_getmem(adu, addr, (uint8_t *) data, len)) { + PR_ERROR("Unable to read memory\n"); + err = 1; + } + } else { + /* Virtual address */ + for (i = 0; i < len; i += sizeof(uint64_t)) { + if (ram_getmem(thread_target, addr, &data[i/sizeof(uint64_t)])) { + PR_ERROR("Fault reading memory\n"); + err = 2; + break; + } + } + } + +out: + if (!err) + for (i = 0; i < len; i ++) { + sprintf(&result[i*2], "%02x", *(((uint8_t *) data) + i)); + } + else + sprintf(result, "E%02x", err); + + send_response(fd, result); +} + +static void put_mem(uint64_t *stack, void *priv) +{ + struct pdbg_target *adu; + uint64_t addr, len; + uint8_t *data; + uint8_t attn_opcode[] = {0x00, 0x02, 0x00, 0x00}; + int err = 0; + struct thread *thread = target_to_thread(thread_target); + + addr = stack[0]; + len = stack[1]; + data = (uint8_t *) &stack[2]; + + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) + break; + } + + if (adu == NULL) { + PR_ERROR("ADU NOT FOUND\n"); + err=3; + goto out; + } + + addr = get_addr(addr); + if (addr == -1UL) { + PR_ERROR("TODO: No virtual address support for putmem\n"); + err = 1; + goto out; + } + + if (len > 8) { + PR_ERROR("TODO: Only support writing at most 8 bytes of memory at a time\n"); + err = 2; + goto out; + } + + printf("put_mem 0x%016lx = 0x%016lx\n", addr, stack[2]); + + if (len == 4 && stack[2] == 0x0810827d) { + /* According to linux-ppc-low.c gdb only uses this + * op-code for sw break points so we replace it with + * the correct attn opcode which is what we need for + * breakpoints. + * + * TODO: Upstream a patch to gdb so that it uses the + * right opcode for baremetal debug. */ + PR_INFO("Breakpoint opcode detected, replacing with attn\n"); + data = attn_opcode; + + /* Need to enable the attn instruction in HID0 */ + if (thread->enable_attn(thread_target)) + goto out; + } else + stack[2] = __builtin_bswap64(stack[2]) >> 32; + + if (adu_putmem(adu, addr, data, len)) { + PR_ERROR("Unable to write memory\n"); + err = 3; + } + +out: + if (err) + send_response(fd, "E01"); + else + send_response(fd, "OK"); +} + +static void v_conts(uint64_t *stack, void *priv) +{ + ram_step_thread(thread_target, 1); + send_response(fd, "S05"); +} + +#define VCONT_POLL_DELAY 100000 +static void v_contc(uint64_t *stack, void *priv) +{ + ram_start_thread(thread_target); + state = SIGNAL_WAIT; +} + +static void interrupt(uint64_t *stack, void *priv) +{ + printf("Interrupt\n"); + ram_stop_thread(thread_target); + send_response(fd, "S05"); + + return; +} + +static void poll(void) +{ + uint64_t nia; + struct thread *thread = target_to_thread(thread_target); + + switch (state) { + case IDLE: + break; + + case SIGNAL_WAIT: + if (!(thread->status.quiesced)) + break; + + state = IDLE; + poll_interval = VCONT_POLL_DELAY; + if (!(thread->status.active)) { + PR_ERROR("Thread inactive after trap\n"); + send_response(fd, "E01\n"); + return; + } + + /* Restore NIA */ + if (ram_getnia(thread_target, &nia)) + PR_ERROR("Error during getnia\n"); + if (ram_putnia(thread_target, nia - 4)) + PR_ERROR("Error during putnia\n"); + send_response(fd, "S05"); + break; + } +} + +static void cmd_default(uint64_t *stack, void *priv) +{ + uintptr_t tmp = stack[0]; + if (stack[0]) { + send_response(fd, (char *) tmp); + } else + send_response(fd, ""); +} + +static void create_client(int new_fd) +{ + printf("Client connected\n"); + fd = new_fd; +} + +static void destroy_client(int dead_fd) +{ + printf("Client disconnected\n"); + close(dead_fd); + fd = -1; +} + +static int read_from_client(int fd) +{ + char buffer[BUFFER_SIZE + 1]; + int nbytes; + + nbytes = read(fd, buffer, sizeof(buffer)); + if (nbytes < 0) { + perror(__FUNCTION__); + return -1; + } else if (nbytes == 0) { + printf("0 bytes\n"); + return -1; + } else { + buffer[nbytes] = '\0'; + printf("%x\n", buffer[0]); + printf("Recv: %s\n", buffer); + parse_buffer(buffer, nbytes, &fd); + } + + return 0; +} + +command_cb callbacks[LAST_CMD + 1] = { + cmd_default, + get_gprs, + get_spr, + get_mem, + stop_reason, + set_thread, + v_contc, + v_conts, + put_mem, + interrupt, + NULL}; + +int gdbserver_start(struct pdbg_target *target, uint16_t port) +{ + int sock, i; + struct sockaddr_in name; + fd_set active_fd_set, read_fd_set; + + parser_init(callbacks); + thread_target = target; + + sock = socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror(__FUNCTION__); + return -1; + } + + name.sin_family = AF_INET; + name.sin_port = htons(port); + name.sin_addr.s_addr = htonl(INADDR_ANY); + if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { + perror(__FUNCTION__); + return -1; + } + + if (listen(sock, 1) < 0) { + perror(__FUNCTION__); + return -1; + } + + FD_ZERO(&active_fd_set); + FD_SET(sock, &active_fd_set); + + while (1) { + read_fd_set = active_fd_set; + timeout.tv_sec = 0; + timeout.tv_usec = poll_interval; + if (select(FD_SETSIZE, &read_fd_set, NULL, NULL, &timeout) < 0) { + perror(__FUNCTION__); + return -1; + } + + for (i = 0; i < FD_SETSIZE; i++) { + if (FD_ISSET(i, &read_fd_set)) { + if (i == sock) { + int new; + new = accept(sock, NULL, NULL); + if (new < 0) { + perror(__FUNCTION__); + return -1; + } + + if (fd > 0) + /* It only makes sense to accept a single client */ + close(new); + else { + create_client(new); + FD_SET(new, &active_fd_set); + } + } else { + if (read_from_client(i) < 0) { + destroy_client(i); + FD_CLR(i, &active_fd_set); + } + } + } + } + + poll(); + } + + return 1; +} + + +static int gdbserver(uint16_t port) +{ + struct pdbg_target *target; + + for_each_class_target("thread", target) { + if (!target_selected(target)) + continue; + if (pdbg_target_probe(target) == PDBG_TARGET_ENABLED) + break; + } + assert(!strcmp(target->class, "thread")); + // Temporary until I can get this working a bit smoother on p9 + if (strcmp(target->compatible, "ibm,power8-thread")) { + PR_ERROR("GDBSERVER is only tested on POWER8\n"); + return -1; + } + gdbserver_start(target, port); + return 0; +} +OPTCMD_DEFINE_CMD_WITH_ARGS(gdbserver, gdbserver, (DATA16)); diff --git a/src/pdbgproxy.h b/src/pdbgproxy.h new file mode 100644 index 0000000..bd12b5e --- /dev/null +++ b/src/pdbgproxy.h @@ -0,0 +1,13 @@ +#ifndef __PDBGPROXY_H +#define __PDBGPROXY_H + +enum gdb_command {NONE, GET_GPRS, GET_SPR, GET_MEM, + STOP_REASON, SET_THREAD, V_CONTC, V_CONTS, + PUT_MEM, INTERRUPT, LAST_CMD}; +typedef void (*command_cb)(uint64_t *stack, void *priv); + +void parser_init(command_cb *callbacks); +int parse_buffer(char *buf, size_t len, void *priv); +void send_nack(void *priv); +void send_ack(void *priv); +#endif From patchwork Wed Aug 29 01:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963207 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 420TBm4V4Fz9s1x for ; Wed, 29 Aug 2018 11:52:00 +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="lRwDfHHn"; 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 420TBm2DbSzF0ph for ; Wed, 29 Aug 2018 11:52:00 +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="lRwDfHHn"; 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:4864:20::42a; helo=mail-pf1-x42a.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="lRwDfHHn"; dkim-atps=neutral Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 420TBH1nB2zF1Rl for ; Wed, 29 Aug 2018 11:51:35 +1000 (AEST) Received: by mail-pf1-x42a.google.com with SMTP id d4-v6so1521427pfn.0 for ; Tue, 28 Aug 2018 18:51:34 -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=aS+NZ2vRiY3SJf7uuxdQcnQ9d7MlGAj5/tgEfmHM6AU=; b=lRwDfHHnDJNfYF6puIt8eUKbw8Cn8Za27ecE62uPQK5MAORScvoIcS0xaw0A6d9fLm 5F8jlyROPSZ6p1UGr8CY2qLboWorvhjIaNsbSSqOxL2N+d3p6sK2ISUICQseuJas8jpS dEBNyOB1yidZLcgfzjmZHzxy5n1SPKmYAxcATjSwO2mtCEidsVwCPmVgocFzIG3efJLL TxlNoyIiavLc7hbZ2TaPL2WGT3Ij5poTaqfspodQAVjwcWnlbLn68bT5Bcm78yy7MsTi tLZtPCbKqqBa+nPvotufes93Xkgo29r+PXqIGDm91/01eQks3ekEk7QrR1ApUk6OSv7c 6XCA== 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=aS+NZ2vRiY3SJf7uuxdQcnQ9d7MlGAj5/tgEfmHM6AU=; b=V/sSqCSJ6MJoYhFeokqBsB51yJCVBXELdb0KXK/X8FIcOaPBv2BGFb+32S0Cipu+qv z8bJtogl8WPgTv3jJGC8p65zmzrVyhRCGj+CGMJ6CIKx6yKrBtxE5CykvQSZAoHoqJAm y+Qh6/AYXkEVBO+JXMEeRZWyw8PQzOyoiCj1fqApKfZ5Az6RgvSkZec2Yl6kzC9djBIv 5QGxIJapL+jTBZH61rax5Nnx0xCiHvIHbEn/xqOZVGkgGZxtWd+w9UGOag+EaHJrPe1D ZgUkP6bZ2oi8axwkuAFuRygAS6B6Jrj3lumk/Rf/qPfeVE3jzVXx7Mu55Ldih03slGYk ai6w== X-Gm-Message-State: APzg51BICJUUq6C2spVYoXwPQ3IRzPSqepDspWJqORuClRfSIzocLh6t iu2T4w73fw7VNRQnyrRcVW+MWJlT X-Google-Smtp-Source: ANB0VdZCp3ySEFZ6ZnPms2G4s4uCZ16gmH8Hc8VzM7Gp/wRBhyyCFsLqf0LoYaeGcJj1wFsrwmEn5A== X-Received: by 2002:a63:9b09:: with SMTP id r9-v6mr3786593pgd.324.1535507493168; Tue, 28 Aug 2018 18:51:33 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:32 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:42 +1000 Message-Id: <20180829015047.7355-15-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 14/19] pdbg/gdbserver: Make ragel optional X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Alistair Popple Add in the generated c file so if the build system doesn't have ragel gdbserver can still be built. Signed-off-by: Rashmica Gupta --- Makefile.am | 6 + configure.ac | 1 + src/gdb_parser_precompile.c | 410 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 src/gdb_parser_precompile.c diff --git a/Makefile.am b/Makefile.am index 5b78624..4d193fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,6 +59,12 @@ BUILT_SOURCES = $(DT) $(DT_headers) optcmd_test_SOURCES = src/optcmd.c src/parsers.c src/tests/optcmd_test.c optcmd_test_CFLAGS = -Wall -g +if HAVE_RAGEL +extra_sources = src/gdb_parser.c +else +extra_sources = src/gdb_parser_precompile.c +endif + pdbg_SOURCES = \ src/main.c \ src/cfam.c \ diff --git a/configure.ac b/configure.ac index 3486969..7cfd2ea 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ AC_SUBST([DTC]) AC_PATH_PROG([RAGEL], [ragel]) AC_SUBST([RAGEL]) +AM_CONDITIONAL([HAVE_RAGEL], [test x"$ac_cv_path_RAGEL" != "x"]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c new file mode 100644 index 0000000..715cdd7 --- /dev/null +++ b/src/gdb_parser_precompile.c @@ -0,0 +1,410 @@ + +#line 1 "src/gdb_parser.rl" +#include +#include +#include +#include + +#include "pdbgproxy.h" + + +#line 105 "src/gdb_parser.rl" + + +static enum gdb_command cmd = NONE; +static uint64_t stack[10], *data = stack; +static char *rsp; +static uint8_t crc; +static int cs; + +command_cb *command_callbacks; + + +#line 24 "src/gdb_parser.c" +static const char _gdb_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 2, 1, 0, 2, 2, 1, 2, + 3, 1, 2, 3, 4, 2, 5, 1, + 2, 6, 1, 2, 7, 1, 2, 8, + 1, 2, 9, 1, 2, 10, 1, 2, + 11, 1, 2, 12, 1, 2, 13, 1, + 2, 14, 1, 2, 15, 1, 2, 16, + 1, 2, 17, 1, 2, 18, 0, 3, + 1, 18, 0, 3, 6, 2, 1, 3, + 6, 3, 1 +}; + +static const char _gdb_key_offsets[] = { + 0, 0, 2, 13, 14, 20, 26, 29, + 37, 45, 46, 53, 61, 68, 77, 84, + 92, 99, 107, 114, 121, 126, 128, 130, + 132, 134, 136, 138, 140, 142, 149, 151, + 153, 155, 157, 159, 161, 163, 165, 167, + 168, 170, 172, 174, 176, 178, 180, 182, + 184, 186, 188, 190, 192, 194, 196, 199, + 202, 203, 204, 206 +}; + +static const char _gdb_trans_keys[] = { + 3, 36, 35, 43, 45, 63, 72, 77, + 103, 109, 112, 113, 118, 35, 48, 57, + 65, 70, 97, 102, 48, 57, 65, 70, + 97, 102, 3, 35, 36, 3, 36, 48, + 57, 65, 70, 97, 102, 3, 36, 48, + 57, 65, 70, 97, 102, 35, 35, 48, + 57, 65, 70, 97, 102, 35, 44, 48, + 57, 65, 70, 97, 102, 35, 48, 57, + 65, 70, 97, 102, 35, 44, 58, 48, + 57, 65, 70, 97, 102, 35, 48, 57, + 65, 70, 97, 102, 35, 44, 48, 57, + 65, 70, 97, 102, 35, 48, 57, 65, + 70, 97, 102, 35, 44, 48, 57, 65, + 70, 97, 102, 35, 48, 57, 65, 70, + 97, 102, 35, 48, 57, 65, 70, 97, + 102, 35, 65, 67, 83, 102, 35, 116, + 35, 116, 35, 97, 35, 99, 35, 104, + 35, 101, 35, 100, 35, 58, 35, 48, + 57, 65, 70, 97, 102, 35, 117, 35, + 112, 35, 112, 35, 111, 35, 114, 35, + 116, 35, 101, 35, 100, 35, 58, 35, + 35, 84, 35, 104, 35, 114, 35, 101, + 35, 97, 35, 100, 35, 73, 35, 110, + 35, 102, 35, 111, 35, 67, 35, 111, + 35, 110, 35, 116, 35, 59, 63, 35, + 99, 115, 35, 35, 3, 36, 3, 35, + 36, 0 +}; + +static const char _gdb_single_lengths[] = { + 0, 2, 11, 1, 0, 0, 3, 2, + 2, 1, 1, 2, 1, 3, 1, 2, + 1, 2, 1, 1, 5, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, + 1, 1, 2, 3 +}; + +static const char _gdb_range_lengths[] = { + 0, 0, 0, 0, 3, 3, 0, 3, + 3, 0, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const short _gdb_index_offsets[] = { + 0, 0, 3, 15, 17, 21, 25, 29, + 35, 41, 43, 48, 54, 59, 66, 71, + 77, 82, 88, 93, 98, 104, 107, 110, + 113, 116, 119, 122, 125, 128, 133, 136, + 139, 142, 145, 148, 151, 154, 157, 160, + 162, 165, 168, 171, 174, 177, 180, 183, + 186, 189, 192, 195, 198, 201, 204, 208, + 212, 214, 216, 219 +}; + +static const char _gdb_indicies[] = { + 1, 2, 0, 4, 5, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 3, 4, + 3, 14, 14, 14, 15, 16, 16, 16, + 15, 18, 19, 20, 17, 1, 2, 21, + 21, 21, 0, 1, 2, 16, 16, 16, + 0, 4, 22, 4, 24, 24, 24, 23, + 4, 25, 24, 24, 24, 23, 4, 26, + 26, 26, 23, 4, 25, 27, 26, 26, + 26, 23, 4, 28, 28, 28, 23, 29, + 25, 28, 28, 28, 23, 4, 30, 30, + 30, 3, 4, 31, 30, 30, 30, 3, + 4, 32, 32, 32, 3, 29, 32, 32, + 32, 3, 4, 33, 34, 35, 36, 3, + 4, 37, 3, 4, 38, 3, 4, 39, + 3, 4, 40, 3, 4, 41, 3, 4, + 42, 3, 4, 43, 3, 4, 44, 3, + 4, 45, 45, 45, 3, 4, 46, 3, + 4, 47, 3, 4, 48, 3, 4, 49, + 3, 4, 50, 3, 4, 51, 3, 4, + 52, 3, 4, 53, 3, 4, 54, 3, + 4, 55, 4, 56, 3, 4, 57, 3, + 4, 58, 3, 4, 59, 3, 4, 60, + 3, 4, 61, 3, 4, 62, 3, 4, + 63, 3, 4, 64, 3, 4, 65, 3, + 4, 66, 3, 4, 67, 3, 4, 68, + 3, 4, 69, 3, 4, 70, 71, 3, + 4, 72, 73, 3, 4, 74, 4, 75, + 1, 2, 0, 18, 19, 20, 17, 0 +}; + +static const char _gdb_trans_targs[] = { + 1, 2, 2, 3, 4, 59, 3, 9, + 10, 3, 16, 18, 20, 50, 5, 0, + 58, 6, 2, 7, 2, 8, 9, 10, + 11, 12, 13, 14, 15, 4, 17, 18, + 19, 21, 3, 30, 40, 22, 23, 24, + 25, 26, 27, 28, 29, 29, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 39, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 3, 51, 52, 53, 54, 55, 3, + 56, 57, 56, 57 +}; + +static const char _gdb_trans_actions[] = { + 0, 60, 1, 3, 0, 3, 33, 3, + 3, 27, 21, 30, 3, 3, 7, 0, + 18, 3, 63, 0, 9, 7, 36, 24, + 71, 67, 71, 67, 71, 5, 15, 12, + 15, 3, 42, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 39, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 45, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 48, 3, 3, 3, 3, 3, 51, + 3, 3, 54, 57 +}; + +static const int gdb_start = 58; +static const int gdb_first_final = 58; +static const int gdb_error = 0; + +static const int gdb_en_main = 58; + + +#line 116 "src/gdb_parser.rl" + +void parser_init(command_cb *callbacks) +{ + +#line 181 "src/gdb_parser.c" + { + cs = gdb_start; + } + +#line 120 "src/gdb_parser.rl" + + command_callbacks = callbacks; +} + +int parse_buffer(char *buf, size_t len, void *priv) +{ + char *p = buf; + char *pe = p + len + 1; + + +#line 197 "src/gdb_parser.c" + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _gdb_trans_keys + _gdb_key_offsets[cs]; + _trans = _gdb_index_offsets[cs]; + + _klen = _gdb_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _gdb_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _gdb_indicies[_trans]; + cs = _gdb_trans_targs[_trans]; + + if ( _gdb_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _gdb_actions + _gdb_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +#line 11 "src/gdb_parser.rl" + { + cmd = 0; + rsp = NULL; + data = stack; + memset(stack, 0, sizeof(stack)); + crc = 0; + } + break; + case 1: +#line 19 "src/gdb_parser.rl" + { + crc += *p; + } + break; + case 2: +#line 23 "src/gdb_parser.rl" + { + data++; + assert(data < &stack[10]); + } + break; + case 3: +#line 28 "src/gdb_parser.rl" + { + *data *= 16; + + if (*p >= '0' && *p <= '9') + *data += *p - '0'; + else if (*p >= 'a' && *p <= 'f') + *data += *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') + *data += *p - 'A' + 10; + } + break; + case 4: +#line 39 "src/gdb_parser.rl" + { + /* *data should point to the CRC */ + if (crc != *data) { + printf("CRC error\n"); + send_nack(priv); + } else { + printf("Cmd %d\n", cmd); + send_ack(priv); + + /* Push the response onto the stack */ + if (rsp) + *data = (uintptr_t)rsp; + else + *data = 0; + + command_callbacks[cmd](stack, priv); + } + } + break; + case 5: +#line 58 "src/gdb_parser.rl" + {cmd = GET_MEM;} + break; + case 6: +#line 63 "src/gdb_parser.rl" + {cmd = PUT_MEM;} + break; + case 7: +#line 70 "src/gdb_parser.rl" + {cmd = GET_GPRS;} + break; + case 8: +#line 72 "src/gdb_parser.rl" + {cmd = GET_SPR;} + break; + case 9: +#line 75 "src/gdb_parser.rl" + {cmd = STOP_REASON;} + break; + case 10: +#line 77 "src/gdb_parser.rl" + {cmd = SET_THREAD;} + break; + case 11: +#line 80 "src/gdb_parser.rl" + {rsp = "1";} + break; + case 12: +#line 81 "src/gdb_parser.rl" + {rsp = "QC1";} + break; + case 13: +#line 82 "src/gdb_parser.rl" + {rsp = "multiprocess+;vContSupported+";} + break; + case 14: +#line 83 "src/gdb_parser.rl" + {rsp = "m1l";} + break; + case 15: +#line 86 "src/gdb_parser.rl" + {rsp = "vCont;c;C;s;S";} + break; + case 16: +#line 87 "src/gdb_parser.rl" + {cmd = V_CONTC;} + break; + case 17: +#line 88 "src/gdb_parser.rl" + {cmd = V_CONTS;} + break; + case 18: +#line 90 "src/gdb_parser.rl" + {command_callbacks[INTERRUPT](stack, priv);} + break; +#line 384 "src/gdb_parser.c" + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +#line 130 "src/gdb_parser.rl" + + return 0; +} + +#if 0 +int main(int argc, char **argv) +{ + parser_init(NULL); + + if (argc > 1) + parse_buffer(argv[1], strlen(argv[1]), NULL); + return 0; +} +#endif From patchwork Wed Aug 29 01:50:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963209 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 420TBq1ng3z9s1x for ; Wed, 29 Aug 2018 11:52:03 +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="ltEoodN7"; 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 420TBp6gHnzF1PV for ; Wed, 29 Aug 2018 11:52:02 +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="ltEoodN7"; 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:4864:20::435; helo=mail-pf1-x435.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="ltEoodN7"; dkim-atps=neutral Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (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 420TBK2R2PzF1PV for ; Wed, 29 Aug 2018 11:51:37 +1000 (AEST) Received: by mail-pf1-x435.google.com with SMTP id u24-v6so1485779pfn.13 for ; Tue, 28 Aug 2018 18:51:37 -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=SplGUOIs0QyJHhYSXKdLG+CbQZT7NpYzLGdGFgxyPII=; b=ltEoodN77LRlTJgiKFGmYMkwwYv7F6e643u6JVpx4wm/voM7qIx3sZi5id7y6cZiCS ohVXE10jEDgoV/uNiRT6B1F5sEqK5Ff4EnGuvQ+j4OWXrXnvyVSqyYGt41zEkzm7ZG4t YyAPdw0mNA3Ktb/n9RUQK1mx5CLXkcxiZzjyBd769fmqQCso74D2g9HXLuMFnWSKPEL2 0RSYJIdCLsSElp2qOxHbQ64ISxr/AYTpCGbo/wVrlZ36fAU2kAkaRMKrCDWrs36jsVwX FmIsG+3+ivRMBx8g2cUnUpNJUaMTqol3o3m6UQNpasBvNBX1KOhPUcGgSNsmTlgtURrv wXlA== 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=SplGUOIs0QyJHhYSXKdLG+CbQZT7NpYzLGdGFgxyPII=; b=T1445O/TxTc+IVFe/Sm3z0ZeXJHbeKAvlu+iBjGfYnFUVNytxaxJ/w64Hpwn/+fSvq mnXdHrqqlZVGEZrn8ZTusCAG/N8NVxKqxHsLfX+VQt9wwCBJ4IV3wmfxtbChJKdhKsfY 4QIwGxbahim4wLLBGzFc8T0RyrcLrYwEzH1tv/Ka4Oxi0OXj16rLnHEfysNi1HSNNA1M 9olDKtFwVvVuJRbseot46DKQogUxp5alb804H7loYY7yDwcWSGU3BkItf2IOnkRoxp+7 0DdZgtxZAQwMwsZL8EMclcM1XeNsrXEJWH6US9PhCeMLkPhPqh2ERb1fwbxBlZXyhSLo ypGA== X-Gm-Message-State: APzg51AI/cQPHwwpZYYIjUem0F1sXrk29Lqxc27SiyA1dsqBOoYChvzH kerrmSbwXq8xS8O7vN9Q/VdkUuwq X-Google-Smtp-Source: ANB0VdY7ZYoUUroHJtdfw102Ba9ajz9o+jhwjQOQ42xLq8a9awUGhPiKxZ9N1zK0HnS9OQIwD59B6A== X-Received: by 2002:a62:de04:: with SMTP id h4-v6mr182934pfg.258.1535507495570; Tue, 28 Aug 2018 18:51:35 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:35 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:43 +1000 Message-Id: <20180829015047.7355-16-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 15/19] pdbg/gdbserver: Make gdbserver optional X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- Makefile.am | 21 +++++++++++---------- configure.ac | 6 ++++++ src/pdbgproxy.c | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4d193fc..4e78c2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,21 +78,22 @@ pdbg_SOURCES = \ src/parsers.c \ src/optcmd.c \ src/options_@ARCH@.c \ - src/htm.h \ - src/main.h \ - src/optcmd.h \ - src/options.h \ - src/parsers.h \ - src/progress.h \ - src/pdbgproxy.c \ - src/gdb_parser.c + src/pdbgproxy.c + +pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ + $(ARCH_FLAGS) + +if GDBSERVER +pdbg_SOURCES += \ + $(extra_sources) +else +pdbg_CFLAGS += -DDISABLE_GDBSERVER +endif pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \ -L.libs -lrt pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive -pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ - $(ARCH_FLAGS) lib_LTLIBRARIES = libpdbg.la libfdt.la diff --git a/configure.ac b/configure.ac index 7cfd2ea..24440ac 100644 --- a/configure.ac +++ b/configure.ac @@ -36,4 +36,10 @@ AC_SUBST([ARCH]) AM_CONDITIONAL([TARGET_ARM], [test x"$ARCH" = "xarm"]) AM_CONDITIONAL([TARGET_PPC], [test x"$ARCH" = "xppc"]) +AC_ARG_ENABLE(gdbserver, +AC_HELP_STRING([--disable-gdbserver], [disables building the gdbserver]), +want_gdbserver=false, +want_gdbserver=true) +AM_CONDITIONAL([GDBSERVER], [test x$want_gdbserver = xtrue]) + AC_OUTPUT diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 7a7da41..1088aad 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -28,6 +28,7 @@ #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) +#ifndef DISABLE_GDBSERVER static struct pdbg_target *thread_target = NULL; static struct timeval timeout; static int poll_interval; @@ -452,7 +453,7 @@ int gdbserver_start(struct pdbg_target *target, uint16_t port) return 1; } - +#endif static int gdbserver(uint16_t port) { From patchwork Wed Aug 29 01:50:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963211 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 420TBt1HBDz9s4s for ; Wed, 29 Aug 2018 11:52:06 +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="ljAhgWKj"; 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 420TBs4JPVzDrRN for ; Wed, 29 Aug 2018 11:52:05 +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="ljAhgWKj"; 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:4864:20::542; helo=mail-pg1-x542.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="ljAhgWKj"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 420TBM6M9ZzF1nb for ; Wed, 29 Aug 2018 11:51:39 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id d19-v6so1593357pgv.1 for ; Tue, 28 Aug 2018 18:51:39 -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=uVaNpac96451M8TzYV9+qKf0/jfhpNL8xaiGV+hm1rk=; b=ljAhgWKjG/lkpD66Uxj4OP6d4IJPcTCT4qc5ateIevdLpBhEroM8dvLrg2WyPFkC0X XTeny4j0y8gZgZrJ/l16jooX5xzdM2PAIZOjWgF4DitA3oB4Lgh2xFRHUyhhcad/14gA UsSDAPLHawLZeJhOYfBIIlWqJp6VFzVm1FN8gK3aSTYoFRflzPfGj3Z/H/IhRhnhnPM7 PiT/vTi7Yfe/KhkPmYMgyFaYlv+eW5lP4tJozOt4vDaoAp0ZpIfOtq296QFkzZLl+eYD EfjOfQSZhZcRLczq4MnHOgptdVevfLLqX0GsVHoRj84GrttsdfCdjrX5K+e3MxP7u3Yn n8+g== 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=uVaNpac96451M8TzYV9+qKf0/jfhpNL8xaiGV+hm1rk=; b=snQeDNC70HZXV1OmZMaCiYQayBAnY8kq3+tHeW1+5v8SV1vX6t2zAK4HxbxS7cAiG4 NAawM9Sxo8+fD/2EIelAonjR1kHGJNVRBl4OGGS/b7aN8RyXjf/JNMpKMtSYRCpAkEOl 7w+7W9fp0Btqzmpsp/ZiUgs9SLwEKB9Dwa9TMlSVc3KcIOir6pNO6oT4isNzzUVmwCo9 RLIXQ8YV8HXHrq0UJTc15iJUleWR+lqR6rRpMPdAkAH4Yl/wkuIXI+cyFZQQ1DleTpTN NeUq+LhZdOeNrS3b0XMfs3JOcJ6+fkCi+Mg0mdPha7HxuduauhWV2Qw+UQDbAUtZAtNM KUJQ== X-Gm-Message-State: APzg51DmKkwZgdyaEDCeOsM+VzVuHLJBPs4BElkMHfAr5Xp6WVtHDDSQ LAiyEUFndl0tPprtsvs1isLVKpBq X-Google-Smtp-Source: ANB0VdbABYwkzuQeXLaNpWGugSRRY3yhlaDHRLYRmVTnTl3Vm8QBWYgwpPrIuTDWLBqa9M/JnsBjpA== X-Received: by 2002:a62:490e:: with SMTP id w14-v6mr3733267pfa.213.1535507497943; Tue, 28 Aug 2018 18:51:37 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:37 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:44 +1000 Message-Id: <20180829015047.7355-17-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 16/19] pdbg/gdbserver: Add in other functions for gdb info registers X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/pdbgproxy.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 1088aad..ac0b3ae 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -91,8 +91,8 @@ static void get_gprs(uint64_t *stack, void *priv) for (i = 0; i < 32; i++) { if (ram_getgpr(thread_target, i, ®s[i])) PR_ERROR("Error reading register %d\n", i); - printf("r%d = 0x%016lx\n", i, regs[i]); - snprintf(data + i*16, 17, "%016lx", __builtin_bswap64(regs[i])); + printf("r%d = 0x%016" PRIx64 "\n", i, regs[i]); + snprintf(data + i*16, 17, "%016" PRIx64 , __builtin_bswap64(regs[i])); } send_response(fd, data); @@ -108,7 +108,23 @@ static void get_spr(uint64_t *stack, void *priv) /* Get PC/NIA */ if (ram_getnia(thread_target, &value)) PR_ERROR("Error reading NIA\n"); - snprintf(data, REG_DATA_SIZE, "%016lx", __builtin_bswap64(value)); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x41: + /* Get MSR */ + if (ram_getmsr(thread_target, &value)) + PR_ERROR("Error reading MSR\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x42: + /* Get CR */ + if (ram_getcr(thread_target, (uint32_t *)&value)) + PR_ERROR("Error reading CR \n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); send_response(fd, data); break; @@ -116,10 +132,27 @@ static void get_spr(uint64_t *stack, void *priv) /* Get LR */ if (ram_getspr(thread_target, 8, &value)) PR_ERROR("Error reading LR\n"); - snprintf(data, REG_DATA_SIZE, "%016lx", __builtin_bswap64(value)); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); send_response(fd, data); break; + case 0x44: + /* Get CTR */ + if (ram_getspr(thread_target, 9, &value)) + PR_ERROR("Error reading CTR\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x45: + /* We can't get the whole XER register in RAM mode as part of it + * is in latches that we need to stop the clocks to get. Probably + * not helpful to only return part of a register in a debugger so + * return unavailable. */ + // TODO p8 only + send_response(fd, "xxxxxxxxxxxxxxxx"); + break; + default: send_response(fd, "xxxxxxxxxxxxxxxx"); break; @@ -241,7 +274,7 @@ static void put_mem(uint64_t *stack, void *priv) goto out; } - printf("put_mem 0x%016lx = 0x%016lx\n", addr, stack[2]); + printf("put_mem 0x%016" PRIx64 " = 0x%016" PRIx64 "\n", addr, stack[2]); if (len == 4 && stack[2] == 0x0810827d) { /* According to linux-ppc-low.c gdb only uses this From patchwork Wed Aug 29 01:50:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963212 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 420TBy1DKSz9s1x for ; Wed, 29 Aug 2018 11:52:10 +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="X7TOX9vt"; 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 420TBx61ZFzF1Zs for ; Wed, 29 Aug 2018 11:52:09 +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="X7TOX9vt"; 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:4864:20::62e; helo=mail-pl1-x62e.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="X7TOX9vt"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 420TBQ1VCxzF13P for ; Wed, 29 Aug 2018 11:51:42 +1000 (AEST) Received: by mail-pl1-x62e.google.com with SMTP id 60-v6so1565792ple.0 for ; Tue, 28 Aug 2018 18:51: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=Gq0M0pkRAcNtrkH0yiXQLpLoAabh6Wk6cV9b3RZbOF0=; b=X7TOX9vtPZGfIpJeH/XpijS22i8EuRziJSpGJ15/fvto7rYsNFUiYos9NhxvfrhJgf JNXTAr1fvvyexEelprMFiyWX6VSu0Cau3c/dHI7JE4ikJtW956/RTpaU5GNA0jEpxize 55n3ufiDvqlOyGLgP57EGn3iCy63eFoYTLk9zX2cbhkFdRUUxsbZ00Eqv+iPeKwzdwi2 fryUVWJ1PR5WDGHadAUcuMKdGRjNQfDH1uerpZW0UXQU/VbQJ4B+EyeYZkgKka4FkD/t i4b0NU5ib9E1ErFIELxRJquV1yVbKgHcdkLUPbVgfNau0JfPROvYHNbp8qdA8CU7wqZJ prHA== 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=Gq0M0pkRAcNtrkH0yiXQLpLoAabh6Wk6cV9b3RZbOF0=; b=eRQ1E8Fey/Vlv1jHkmvOSoL0eCa4iylx+M4lFy9UBfSnii6LVLdn81AjIWWvc+6sVN 8QdyxbYSUpbFl+cD5L9qSJNmCS+RlCdi5RGdBg7eUeXFBbMQzxR/2zWxL5TCYBAI1ONH XPJMa+sh8LHkRBCnpn8gSu6CODYp7Nh8r//27lPJlrQcGAvdzdLbVImXVCKTJk0YHr0M L5YO9qLVvl+oa1upHwVLLlgiceewol64rkyKH395Pf6NGkd9Z/gG23PvnP90wbAsN0bO DZioqijibUta7kZWR+w1JvuqRezIqYX3uezoJsPBNUZlUDb1Bw+TSnZpyX3xmPCpWjL5 nBSA== X-Gm-Message-State: APzg51DZnbLVb1W1plz1WjHWGVc5AlcGKJ6QJBLdIjeDQ7+iIP/MyYhV zqCwslN29l27ArfHnRRt6PmOkMAU X-Google-Smtp-Source: ANB0VdbIRLoEgvVH6fEP60VZ7ViI711M19klJZzplecJZno/9LPTHrhT4vtiQdYJJ8UEdy0nGnEgWA== X-Received: by 2002:a17:902:7587:: with SMTP id j7-v6mr3947962pll.256.1535507500341; Tue, 28 Aug 2018 18:51:40 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:39 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:45 +1000 Message-Id: <20180829015047.7355-18-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 17/19] pdbg/gdbserver: Detach from client X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/gdb_parser.rl | 5 ++++- src/pdbgproxy.c | 9 +++++++++ src/pdbgproxy.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl index 18dfac7..6259b96 100644 --- a/src/gdb_parser.rl +++ b/src/gdb_parser.rl @@ -76,6 +76,9 @@ set_thread = ('H' any* @{cmd = SET_THREAD;}); + disconnect = ('D' @{cmd = DISCONNECT;} + xdigit+ $hex_digit %push); + # TODO: We don't actually listen to what's supported q_attached = ('qAttached:' xdigit* @{rsp = "1";}); q_C = ('qC' @{rsp = "QC1";}); @@ -91,7 +94,7 @@ commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread | q_attached | q_C | q_supported | qf_threadinfo | q_C | - v_contq | v_contc | v_conts | put_mem ); + v_contq | v_contc | v_conts | put_mem | disconnect ); cmd = ((commands & ^'#'*) | ^'#'*) $crc ('#' xdigit{2} $hex_digit @end); diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index ac0b3ae..eb7c0ae 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -36,6 +36,8 @@ static int fd = -1; enum client_state {IDLE, SIGNAL_WAIT}; static enum client_state state = IDLE; +static void destroy_client(int dead_fd); + static uint8_t gdbcrc(char *data) { uint8_t crc = 0; @@ -80,6 +82,12 @@ static void stop_reason(uint64_t *stack, void *priv) send_response(fd, "S05"); } +static void disconnect(uint64_t *stack, void *priv) +{ + printf("Terminating connection with client. pid %16" PRIi64 "\n", stack[0]); + send_response(fd, "OK"); +} + /* 32 registers represented as 16 char hex numbers with null-termination */ #define REG_DATA_SIZE (32*16+1) static void get_gprs(uint64_t *stack, void *priv) @@ -413,6 +421,7 @@ command_cb callbacks[LAST_CMD + 1] = { v_conts, put_mem, interrupt, + disconnect, NULL}; int gdbserver_start(struct pdbg_target *target, uint16_t port) diff --git a/src/pdbgproxy.h b/src/pdbgproxy.h index bd12b5e..1fe67f2 100644 --- a/src/pdbgproxy.h +++ b/src/pdbgproxy.h @@ -3,7 +3,7 @@ enum gdb_command {NONE, GET_GPRS, GET_SPR, GET_MEM, STOP_REASON, SET_THREAD, V_CONTC, V_CONTS, - PUT_MEM, INTERRUPT, LAST_CMD}; + PUT_MEM, INTERRUPT, DISCONNECT, LAST_CMD}; typedef void (*command_cb)(uint64_t *stack, void *priv); void parser_init(command_cb *callbacks); From patchwork Wed Aug 29 01:50:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963213 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 420TC13gGvz9s4Z for ; Wed, 29 Aug 2018 11:52:13 +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="XGBdUvsG"; 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 420TC11TdXzF13P for ; Wed, 29 Aug 2018 11:52:13 +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="XGBdUvsG"; 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:4864:20::541; helo=mail-pg1-x541.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="XGBdUvsG"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (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 420TBS5wBdzF0ph for ; Wed, 29 Aug 2018 11:51:44 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id d1-v6so1588113pgo.3 for ; Tue, 28 Aug 2018 18:51:44 -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=/Ri0McFdAiFdK3z33BgAIf4h3/kZ/kTx8SJXHE/pN/Q=; b=XGBdUvsGCK6gXz2nEivYLdlm3YMnt8tt5EMW69yvP4Tp14KsUtZ1g8wxYFdcFRltH+ BVD1auGOZD+VWx/6lW/P2LKXB9Pxcn7MeINvs7ItUobGDMi5itF5TPMgF61BeA50o/sP eCJ3taLOPygp9ENRUbKG/1rbVV/UL7hCmlVdRWNZKg4wE+3LWpQilFXMlBSmjsnbMC5C 4UU7YinJc87o6JKWWgBnuLHCmRzmkBn8EuyUHHyBWuN1MDfoPvfe4xz5MigpvIfv8TDs DccjlIAauGD+bhtc+TeK7226C6SnJlLAJebz3im1m2tPtm3pNTcZUIQliON6enEz43P8 nzYw== 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=/Ri0McFdAiFdK3z33BgAIf4h3/kZ/kTx8SJXHE/pN/Q=; b=JV4UCe9sCxMYACXfRVnyAPscNI/7cX5RsM4c+CewepMyVvGLVJyA/9fTB11N1JmtDk hrznjA5Xq0uZfqr6Btj2ZZH8cRGWXiF3m4BXGVYHK37ZxuUQXk6rdOLXFQ6lprcVHe2/ WCAKranmqtRcK1V1d3M4oNA260LNt2PBs649H1kdLn7wpOpWf8WZW50QZIcr4MNtsC6s eiKVbAmJwXq+7L3FRYZ8iX8gVPtDSFGZAHttBai4nyiJrUfi61nWJRNheZye2CnkTq9F Q7sdxJ0eI74xUjD21sK8/viP4kYqQCFtYMw01b1UE1jWc9/eXocFiDmWGVNTnb1XDVNH r/Tg== X-Gm-Message-State: APzg51DxyHEdO7Kh48r7jEQ1MSb8VrQ3EqMwoTNKdjPMgJlNqLbR4FW5 9Ezk3LHgRd5Sf6RJ2w+mwbJ+mafX X-Google-Smtp-Source: ANB0VdaMTTMbqEJsi1QNUwdIvztbS32+ODLq9sD3bGO/IVqIZSJCSQjuCVc6hGMjZsyBLvhlYaBC3Q== X-Received: by 2002:a63:a40a:: with SMTP id c10-v6mr3754454pgf.346.1535507502731; Tue, 28 Aug 2018 18:51:42 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:42 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:46 +1000 Message-Id: <20180829015047.7355-19-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 18/19] libpdbg: Release adu lock when erroring out X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/adu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libpdbg/adu.c b/libpdbg/adu.c index 9f175f8..f38f2a0 100644 --- a/libpdbg/adu.c +++ b/libpdbg/adu.c @@ -265,6 +265,7 @@ retry: else { PR_ERROR("Unable to read memory. " \ "ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); + adu_unlock(adu); return -1; } } From patchwork Wed Aug 29 01:50:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963214 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 420TC36Qdyz9s1x for ; Wed, 29 Aug 2018 11:52:15 +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="qOVM5yU7"; 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 420TC34N4xzF1nQ for ; Wed, 29 Aug 2018 11:52:15 +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="qOVM5yU7"; 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:4864:20::442; helo=mail-pf1-x442.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="qOVM5yU7"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 420TBV6X5pzF13F for ; Wed, 29 Aug 2018 11:51:46 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id l9-v6so1496082pff.9 for ; Tue, 28 Aug 2018 18:51:46 -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=xZjNRCDcQXklAz8+IMOOIGVH7F5zdmpuGp8/KKvQEAE=; b=qOVM5yU7t9inGjvWsKuW/c8GBOE6qVpitYvPmLJRczpLtmF7mjDEjXbWAkEIPRNkEW N8PF05Uv1UcDscFbY6J1GKlLPl68rhXk3uQYoBxklnHTxLs+mqfJRsNVfKdttalpOi6C BDrlBmUYKePMRlfSSMPtjxwzXKdMeR38yLF83PCTtT+JAvPWgpTBFO6DbWkAbcJoLLch uqWZtAXDY+Ef7b+wpBcB5ln4loJLH0bXcXze8NX5X4FJGZKvPyVEwO++IROCxDdWNTJ0 +yf/lG8S+44O0cAsYoHOwOXZAoxCT4pMmETsV+ODxfcKHFUo7G7kPYMyIGk5DZ6N+9Tf dCtw== 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=xZjNRCDcQXklAz8+IMOOIGVH7F5zdmpuGp8/KKvQEAE=; b=h1HGJXYKbFo1XCjCoy4B4QmcL3cOsEtBtL+kU3y26mvGTTiozLVvuxpgP8P6R/D4v8 ssHVAaRqszJ6Oflsc1g/MxHi+5/azRNtuYMSrHESPfjK2C6V7qgf97+KGI9uf4syJv4t T86qlFrEs3orEdThm6rbu7EHQC9HS4w/OKMud7hgyNjN7q6EoPQaGXsA/MMb7LQY7Z8h O44OwJA/ddadhrndOKq0FsQ5yN4tsPVGc5hmT30PIvHBJnv/dzoeVTp7xcRu5KA9NN4c IdoE8ENmMdhPRJuUxBpry190VVMcmv7D27QHhqKenMDLG0xTtRBtr9ASDvLPLwo7e9YJ kjsA== X-Gm-Message-State: APzg51AnLsDUbZCjEtHm874uhVTyvFiHnMVHvRPQy/vf5CCwsErAgfnH 3spd6Z2mxPwL4uQCMeYp/bOhVixW X-Google-Smtp-Source: ANB0VdY7lmkasNlaMHVkeMZ/IcMp/X3fsO4YEOM3nitWpNCt4wG9+0AF3JEuj3ZGJLtOypDSPftftQ== X-Received: by 2002:a63:5d1c:: with SMTP id r28-v6mr3780548pgb.445.1535507505170; Tue, 28 Aug 2018 18:51:45 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:44 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:47 +1000 Message-Id: <20180829015047.7355-20-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 19/19] README: Add some gdbserver info X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 878e6d3..dcbbbe3 100644 --- a/README.md +++ b/README.md @@ -365,3 +365,29 @@ There are also low level htm commands which can also be used: - `stop` will still stop the trace and de-configure the hardware. - `dump` will dump the trace to a file. +### GDBSERVER +At the moment gdbserver is only supported on P8 while the cores are in the +kernel. + +To run a gdbserver on a P8 machine from a BMC running openbmc: + +Stop all the cores of the host +$ ./pdbg -d p8 -a stop + +Run gdbserver on thread 0 of core 11, accessible through port 44 +$ ./pdbg -d p8 -p0 -c11 -t0 gdbserver 44 + +On your local machine: +$ gdb +(gdb) set architecture powerpc:common64 +(gdb) target remote palm5-bmc:44 + +Debugging info: +(gdb) set debug remote 10 + + +Notes: +1. DON'T RUN PDBG OVER FSI WHILE HOSTBOOT IS RUNNING. Weird things seem to +happen. +2. If you want to view the kernel call trace then run gdb on the vmlinux that +the host is running (the kernel needs to be compiled with debug symbols).