From patchwork Fri Nov 23 04:40:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431NsZ5sMjz9s7T for ; Fri, 23 Nov 2018 15:40:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="IE/GhXWS"; 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 431NsZ2k9qzDqSr for ; Fri, 23 Nov 2018 15:40:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="IE/GhXWS"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsM1hs0zDqSr for ; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="IE/GhXWS"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsL3Zbkz9s7T; Fri, 23 Nov 2018 15:40:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948022; bh=pwP3irUMtqJVcfCX6d3ZCcARKR+cM8ltPDeBJZzVV2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IE/GhXWSUkMpK7C4stN6eDuAu0zuDS23icEWYetwwDuOmUk62DVgkIHieTVUQ4jFG A+uR9vZrqwELsAzBrzf5zk9Vyz3PLhTYE7xhH4uK6DOIBgHdkuNxGr8k+ZMqelTCgT f8Z4JuWYxA3aE0SvOdrY6nVpbeTFCEtffGktUOHmxrRfXNSzcFBgE7mu+kV0zfMnX9 y3EOEu2zr+9SzRpKmHFui4mbqAphtXeYW5emKiCcjN5gcKZav7qtrH3osF74iWszm+ rfkSii7Vs3ZN7ItgM8+Q7Fm182gjR3St/aRc0veSa2FIRRU+dAlOJridxO6OjqtUtL 4Ti+WiXmlrlog== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:10 +1100 Message-Id: <20181123044019.633814-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 01/10] main: Move device_node setting before parse_options X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Parsing -l options requires device_node to be set. It is used in pir_map() to map Linux CPU to proc/core/thread. Signed-off-by: Amitay Isaacs --- src/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 961d850..45ecd6a 100644 --- a/src/main.c +++ b/src/main.c @@ -502,6 +502,9 @@ static bool parse_options(int argc, char *argv[]) if (l_count) { int pir = -1, i, chip, core, thread; + if (!device_node) + return false; + for (i = 0; i < MAX_LINUX_CPUS; i++) { if (l_list[i] == 1) { pir = get_pir(i); @@ -730,6 +733,9 @@ int main(int argc, char *argv[]) backend = default_backend(); + if (!device_node) + device_node = default_target(backend); + if (!parse_options(argc, argv)) return 1; @@ -738,9 +744,6 @@ int main(int argc, char *argv[]) return 1; } - if (!device_node) - device_node = default_target(backend); - /* Disable unselected targets */ if (!target_selection()) return 1; From patchwork Fri Nov 23 04:40:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nsg1q8Wz9s7T for ; Fri, 23 Nov 2018 15:40:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Ms0hNf8N"; 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 431Nsf6jjPzDqT2 for ; Fri, 23 Nov 2018 15:40:38 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Ms0hNf8N"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsM24mHzDqSs for ; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Ms0hNf8N"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsL5bdjz9sCV; Fri, 23 Nov 2018 15:40:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948022; bh=97JMkVQi8yaKRAlgW4Z+ZyKCIrji6f9/1LOSdfTaQjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ms0hNf8NInACs8dRBG6HFQGnvN/JewbghTB1vQM3Tu2HF/wF91Jwqnt1YxggyUR5X srU2GxDT3Ip28uODOayZb4vo5sSnKlU8gWLJshjJgNDNKwZiHhDFTMF4kbQV/YXhu8 JWcgMnOPGhFHR8D+LQ6AescdPXTt35Ow8y2LIqI3tkUoGSQvJVcpwnJ6SMoiRVhqqn kDpQKAgCAKo8QlSla/dKOW995k1o7DOqhUv6xa99UuW9gAB8b8taxBbAxCuQzPgTYS MIKRgswr3zZZQrNWdAvim2/5xYdLFyyt3oaWWBMzBmBOQMRj70mK5oOC9w1S2JvJAP vvnEuTVNGz+iw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:11 +1100 Message-Id: <20181123044019.633814-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 02/10] main: Mark print_target static X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 45ecd6a..d311332 100644 --- a/src/main.c +++ b/src/main.c @@ -675,7 +675,7 @@ static bool target_selection(void) return true; } -void print_target(struct pdbg_target *target, int level) +static void print_target(struct pdbg_target *target, int level) { int i; struct pdbg_target *next; From patchwork Fri Nov 23 04:40:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002110 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nsm0hSPz9s1c for ; Fri, 23 Nov 2018 15:40:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="pt2joT23"; 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 431Nsk6GxQzDqSw for ; Fri, 23 Nov 2018 15:40:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="pt2joT23"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsM3g9XzDqSv for ; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="pt2joT23"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsM1HVXz9sCh; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948023; bh=bV0+3bYLdmQGTO7SM6uqAHKXpyR/eZrQKa0zUPToYb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pt2joT23VgNOeFkTrDYMLX1ocwtj4JDvmnl/NMjWrlwyZBV3msF++4DMAKi4ZF24f QBy+sdDtJwyZ8rPDCJYmz/rfapC6pmKYINYpiNcbPsPaNyXHKrl7oMh9n03VrJUX8G wV23mbUlLlO+5DZZSn58PGMidj18Z98t5XTxLjke5ClU/ofWkBhMetJ1Wv0VQORRTq g/nODfnqIKsHsQY6u0iyDSbwvtT/lqTp3OMCy3iD7VV9dTp01DBKYDmX9g7YDdmtAU PAjgxUEkrPIR6uX/4jI7T5qvNOkexll0NxKOHhdlZ2KWumi+oPXb84AgHhz7vyKn6Z mZUaQ2scjLrTA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:12 +1100 Message-Id: <20181123044019.633814-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 03/10] main: Convert getring to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/ring.c | 56 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/ring.c b/src/ring.c index 58df4d1..1e40db6 100644 --- a/src/ring.c +++ b/src/ring.c @@ -24,36 +24,56 @@ #include "main.h" #include "optcmd.h" +#include "path.h" -static int pdbg_getring(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *len) +static int get_ring(uint64_t ring_addr, uint64_t ring_len) { + struct pdbg_target *target; uint32_t *result; - int i, words; - int ring_len = *len; + int count = 0; + int words; - words = (ring_len + 32 - 1)/32; + words = (ring_len + 32 - 1) / 32; result = calloc(words, sizeof(*result)); assert(result); - getring(target, *addr, ring_len, result); + for_each_path_target_class("chiplet", target) { + char *path; + int rc, i, len; - for (i = 0; i < ring_len/32; i++) - printf("%08" PRIx32, result[i]); + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; - ring_len -= i*32; + path = pdbg_target_path(target); + assert(path); - /* Print out remaining bits */ - for (i = 0; i < (ring_len + 4 - 1)/4; i++) - printf("%01" PRIx32, (result[words - 1] >> (28 - i*4)) & 0xf); + printf("%s: 0x%016" PRIx64 " = ", path, ring_addr); + free(path); - printf("\n"); + rc = getring(target, ring_addr, ring_len, result); + if (rc) { + printf("failed\n"); + continue; + } - return 1; -} + printf("\n"); -static int _getring(uint64_t ring_addr, uint64_t ring_len) -{ - return for_each_target("chiplet", pdbg_getring, &ring_addr, &ring_len); + len = (int)ring_len; + for (i = 0; i < len/32; i++) + printf("%08" PRIx32, result[i]); + + len -= i*32; + + for (i=0; i < (len + 4 - 1)/4; i++) + printf("%01" PRIx32, (result[words-1] >> (28 - i*4)) & 0xf); + + printf("\n"); + + count++; + } + + free(result); + return count; } -OPTCMD_DEFINE_CMD_WITH_ARGS(getring, _getring, (ADDRESS, DATA)); +OPTCMD_DEFINE_CMD_WITH_ARGS(getring, get_ring, (ADDRESS, DATA)); From patchwork Fri Nov 23 04:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002111 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nsq2V2Tz9s1c for ; Fri, 23 Nov 2018 15:40:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; 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 431Nsq0SDfzDqT1 for ; Fri, 23 Nov 2018 15:40:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsM66QdzDqRk for ; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsM3JD6z9s1c; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948023; bh=CVAg/EFkbk4AUyA0mYf72rOjVgDAhy/7a6wh8G9aPMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjqwSMSNoNlevfmAueCr4HGMpY/pLlbi07WfV2IshSJrEsMDWTSYQ8Uruy+7h3nCy ryziso2QFpsn59E8KFA9qLfQbGm0OnaQPujOERkClY4gt40EO4MYC/TwnyOvqiZjRb JwEWJ88inpS/Yp2SeNkvhcWIrnbhbNXOCGycROCpv4emxqSWkBy8ovCn72syTFBJrq fG4z/QvTmeao+njLDRR1wdgzmJhS/lIXM4R0l2I/E5B+qLsGgUestiwqORFSW2+omz kg3WKkpATGt09cY5+6YrAN1zgCUp+bO9FEAkGkbpx6+5qniwrNZYHxgusgWZFLKaC+ EuUgLgD8cT8cA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:13 +1100 Message-Id: <20181123044019.633814-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 04/10] main: Convert thread commands start/stop/step/sreset X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/thread.c | 75 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/src/thread.c b/src/thread.c index 4401384..97becc4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -22,6 +22,7 @@ #include "main.h" #include "optcmd.h" +#include "path.h" static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *valid) { @@ -240,26 +241,6 @@ static int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t ind return for_each_child_target("core", pib_target, print_core_thread_status, &maxindex, NULL); }; -static int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_start_thread(thread_target) ? 0 : 1; -} - -static int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1) -{ - return ram_step_thread(thread_target, *count) ? 0 : 1; -} - -static int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_stop_thread(thread_target) ? 0 : 1; -} - -static int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_sreset_thread(thread_target) ? 0 : 1; -} - static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *i_doBacktrace, uint64_t *unused) { struct thread_regs regs; @@ -276,19 +257,52 @@ static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint6 static int thread_start(void) { - return for_each_target("thread", start_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_start_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(start, thread_start); -static int thread_step(uint64_t count) +static int thread_step(uint64_t steps) { - return for_each_target("thread", step_thread, &count, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_step_thread(target, (int)steps); + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(step, thread_step, (DATA)); static int thread_stop(void) { - return for_each_target("thread", stop_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_stop_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(stop, thread_stop); @@ -300,7 +314,18 @@ OPTCMD_DEFINE_CMD(threadstatus, thread_status_print); static int thread_sreset(void) { - return for_each_target("thread", sreset_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_sreset_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(sreset, thread_sreset); From patchwork Fri Nov 23 04:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002112 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nst5s3Qz9sCV for ; Fri, 23 Nov 2018 15:40:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="b8ypqfbX"; 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 431Nst3TKYzDqSr for ; Fri, 23 Nov 2018 15:40:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="b8ypqfbX"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsN1QH7zDqSr for ; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="b8ypqfbX"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsM5psbz9s7T; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948023; bh=2awv0Xn7DU2H3ciluB88SNap1ftuXT3PdmCH5ZnkuDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8ypqfbXlCefSN/5REOArvozU9QbayWqBxWnMGZVNiIGvp9smRAmkxgVVCM/usruk aW1xQ4eY6DYJZ2755LV9VU9DU+l0E84kAkMZGwtTjZmjz6Qy6T6hRfrSRZXn+1cr7M Pq1m4DYtzVzzmbq8I8yzfd5YW3NuTfbhqZtGlY2USpwlL9qt89EFrCSTui7WJA9eIr zENFebWKN/vbDtdB8NnTRrHkL64ZkVJ0rQrhagbrA6dYUQnBMcWhvFoGV+x9BwfFvh j+3rdjZ9+kPwYEELmyLK8rWoZgQsCqbPrVDETN1IlvsOo/CHLzcC2lqWkvwGXdzzX1 9RUAeelbwkdHQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:14 +1100 Message-Id: <20181123044019.633814-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 05/10] main: Convert threadstatus command to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/thread.c | 183 +++++++++++++++++++++++++-------------------------- 1 file changed, 91 insertions(+), 92 deletions(-) diff --git a/src/thread.c b/src/thread.c index 97becc4..3af37be 100644 --- a/src/thread.c +++ b/src/thread.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -24,70 +25,6 @@ #include "optcmd.h" #include "path.h" -static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *valid) -{ - struct thread_state *status = (struct thread_state *) arg; - - status[index] = thread_status(target); - valid[index] = true; - return 1; -} - -static int print_core_thread_status(struct pdbg_target *core_target, uint32_t index, uint64_t *maxindex, uint64_t *unused1) -{ - struct thread_state status[8]; - uint64_t valid[8] = {0}; - int i, rc; - - printf("c%02d: ", index); - - /* TODO: This cast is gross. Need to rewrite for_each_child_target as an iterator. */ - rc = for_each_child_target("thread", core_target, print_thread_status, (uint64_t *) &status[0], &valid[0]); - for (i = 0; i <= *maxindex; i++) { - if (!valid[i]) { - printf(" "); - continue; - } - - if (status[i].active) - printf("A"); - else - printf("."); - - switch (status[i].sleep_state) { - case PDBG_THREAD_STATE_DOZE: - printf("D"); - break; - - case PDBG_THREAD_STATE_NAP: - printf("N"); - break; - - case PDBG_THREAD_STATE_SLEEP: - printf("Z"); - break; - - case PDBG_THREAD_STATE_STOP: - printf("S"); - break; - - default: - printf("."); - break; - } - - if (status[i].quiesced) - printf("Q"); - else - printf("."); - printf(" "); - - } - printf("\n"); - - return rc; -} - static bool is_real_address(struct thread_regs *regs, uint64_t addr) { return true; @@ -214,33 +151,6 @@ no_flip: return 0; } -static int get_thread_max_index(struct pdbg_target *target, uint32_t index, uint64_t *maxindex, uint64_t *unused) -{ - if (index > *maxindex) - *maxindex = index; - return 1; -} - -static int get_core_max_threads(struct pdbg_target *core_target, uint32_t index, uint64_t *maxindex, uint64_t *unused1) -{ - return for_each_child_target("thread", core_target, get_thread_max_index, maxindex, NULL); -} - -static int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - int i; - uint64_t maxindex = 0; - - for_each_child_target("core", pib_target, get_core_max_threads, &maxindex, NULL); - - printf("\np%01dt:", index); - for (i = 0; i <= maxindex; i++) - printf(" %d", i); - printf("\n"); - - return for_each_child_target("core", pib_target, print_core_thread_status, &maxindex, NULL); -}; - static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *i_doBacktrace, uint64_t *unused) { struct thread_regs regs; @@ -306,9 +216,98 @@ static int thread_stop(void) } OPTCMD_DEFINE_CMD(stop, thread_stop); + +static int print_one_thread(struct pdbg_target *thread) +{ + struct thread_state tstate; + char c; + + if (!path_target_selected(thread)) { + printf("... "); + return 0; + } + + tstate = thread_status(thread); + + + switch (tstate.sleep_state) { + case PDBG_THREAD_STATE_DOZE: + c = 'D'; + break; + + case PDBG_THREAD_STATE_NAP: + c = 'N'; + break; + + case PDBG_THREAD_STATE_SLEEP: + c = 'Z'; + break; + + case PDBG_THREAD_STATE_STOP: + c = 'S'; + break; + + default: + c = '.'; + break; + } + + printf("%c%c%c ", + (tstate.active ? 'A' : '.'), + c, + (tstate.quiesced ? 'Q': '.')); + return 1; +} + static int thread_status_print(void) { - return for_each_target("pib", print_proc_thread_status, NULL, NULL); + struct pdbg_target *thread, *core, *pib; + int threads_per_core = 0; + int count = 0; + + for_each_path_target_class("thread", thread) { + core = pdbg_target_parent("core", thread); + assert(path_target_add(core)); + + pib = pdbg_target_parent("pib", core); + assert(path_target_add(pib)); + } + + pib = __pdbg_next_target("pib", pdbg_target_root(), NULL); + assert(pib); + + core = __pdbg_next_target("core", pib, NULL); + assert(core); + + pdbg_for_each_target("thread", core, thread) + threads_per_core++; + + for_each_path_target_class("pib", pib) { + int i; + + if (pdbg_target_status(pib) != PDBG_TARGET_ENABLED) + continue; + + printf("\np%01dt:", pdbg_target_index(pib)); + for (i = 0; i < threads_per_core; i++) + printf(" %d", i); + printf("\n"); + + pdbg_for_each_target("core", pib, core) { + if (!path_target_selected(core)) + continue; + if (pdbg_target_status(core) != PDBG_TARGET_ENABLED) + continue; + + printf("c%02d: ", pdbg_target_index(core)); + + pdbg_for_each_target("thread", core, thread) + count += print_one_thread(thread); + printf("\n"); + } + } + + return count; } OPTCMD_DEFINE_CMD(threadstatus, thread_status_print); From patchwork Fri Nov 23 04:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nsy269Lz9s7T for ; Fri, 23 Nov 2018 15:40:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FttxW6qv"; 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 431Nsx6yM7zDqT2 for ; Fri, 23 Nov 2018 15:40:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FttxW6qv"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsN3tzRzDqRk for ; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FttxW6qv"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsN1BmMz9sCV; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948024; bh=3QIkdDYcpP1v7+Tm+vZp3sViPSVQGflIOsuoMXW+aeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FttxW6qvx5DxQT5uvO6c67b6hUjpj8T0o/n+fD8SvpnD5+sSLOWWClHc64n5XQiIk HiJl9IFnxafAp4R3z5py9a2zLj7tYXxxzsf0iYodQHFMbE3+56Hu33prb1gmEAzgtg MqUKTMwTN4IljxdZG3VXAzzVwy5rsY749RnnoA4drm3aFuwDdpjDLhU2zBBy17rfFb beUj8P4im0rOplDk4mPWh3qVmDQ/fWl7fGJhRDS3JHdVSo7/dnLt8oL3beJg8C8PeB HP77BzcANN0OXy6rkT50QoiljqKTqGEuD3NO3fCpMM++j7h1I5wJz/hJnj3BCI2Q+f cteWMCgoja7fA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:15 +1100 Message-Id: <20181123044019.633814-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 06/10] main: Convert regs command to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/thread.c | 67 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/thread.c b/src/thread.c index 3af37be..1fd448d 100644 --- a/src/thread.c +++ b/src/thread.c @@ -52,23 +52,13 @@ uint64_t flip_endian(uint64_t v) #endif } -static int dump_stack(struct thread_regs *regs) +static int dump_stack(struct thread_regs *regs, struct pdbg_target *adu) { - struct pdbg_target *target; uint64_t next_sp = regs->gprs[1]; uint64_t pc; bool finished = false; - pdbg_for_each_class_target("adu", target) { - if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) - continue; - break; - } - printf("STACK: SP NIA\n"); - if (!target) - pdbg_log(PDBG_ERROR, "Unable to read memory (no ADU found)\n"); - if (!(next_sp && is_real_address(regs, next_sp))) { printf("SP:0x%016" PRIx64 " does not appear to be a stack\n", next_sp); return 0; @@ -87,9 +77,9 @@ static int dump_stack(struct thread_regs *regs) if (!is_real_address(regs, sp)) break; - if (!load8(target, sp, &tmp)) + if (!load8(adu, sp, &tmp)) return 1; - if (!load8(target, sp + 16, &pc)) + if (!load8(adu, sp + 16, &pc)) return 1; tmp2 = flip_endian(tmp); @@ -151,20 +141,6 @@ no_flip: return 0; } -static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *i_doBacktrace, uint64_t *unused) -{ - struct thread_regs regs; - bool do_backtrace = (bool) i_doBacktrace; - - if (ram_state_thread(thread_target, ®s)) - return 0; - - if (do_backtrace) - dump_stack(®s); - - return 1; -} - static int thread_start(void) { struct pdbg_target *target; @@ -335,15 +311,38 @@ struct reg_flags { #define REG_BACKTRACE_FLAG ("--backtrace", do_backtrace, parse_flag_noarg, false) -static int thread_state(struct reg_flags flags) +static int thread_regs_print(struct reg_flags flags) { - int err; + struct pdbg_target *pib, *core, *thread; + struct thread_regs regs; + int count = 0; + + for_each_path_target_class("thread", thread) { + core = pdbg_target_parent("core", thread); + pib = pdbg_target_parent("pib", core); - err = for_each_target("thread", state_thread, - (uint64_t *)flags.do_backtrace, NULL); + printf("p%d c%d t%d\n", + pdbg_target_index(pib), + pdbg_target_index(core), + pdbg_target_index(thread)); + + if (ram_state_thread(thread, ®s)) + continue; - for_each_target_release("thread"); + if (flags.do_backtrace) { + struct pdbg_target *adu; - return err; + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) { + dump_stack(®s, adu); + break; + } + } + } + + count++; + } + + return count; } -OPTCMD_DEFINE_CMD_ONLY_FLAGS(regs, thread_state, reg_flags, (REG_BACKTRACE_FLAG)); +OPTCMD_DEFINE_CMD_ONLY_FLAGS(regs, thread_regs_print, reg_flags, (REG_BACKTRACE_FLAG)); From patchwork Fri Nov 23 04:40:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nt20rp0z9s1c for ; Fri, 23 Nov 2018 15:40:58 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="mPwweQim"; 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 431Nt15xMTzDqTL for ; Fri, 23 Nov 2018 15:40:57 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="mPwweQim"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsN67rDzDqSr for ; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="mPwweQim"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsN3b3Tz9s1c; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948024; bh=116DG6LMv+1590qxq1iLkOEjUd28VWXaonJNt8AcS8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPwweQimxPyBWQXMg+L5hxgemWz5COwh3zGrdpKq/OpXUBbtzX5I8rbM3mG/aBZWc D4wP5+o7qz30HDCtVUyznvzbF7LoC3USscSL4WovD85KbKV6sC3Lu+BR3xYcme7Oiv M6QZvg9M2k2Ycso1w6o/VddUI2rhh7nwT+NRdKJmv1u1FhiUqBt7AqaBxkwLxYJI8Y yRXXzlLQmNYk5l+rTlrvWp3Wy7Udlfrqs+BZVHwwJwcrW/mpX2wvdntX2D7PQ7406X d17WSRKjQSCAJljWiffzWeH82EelnGuDm84xXtZ+NhgrGl2Vs3drumjf5aAxrJCgZM sXKp2E3rw3jnw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:16 +1100 Message-Id: <20181123044019.633814-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 07/10] main: Drop unused iterators with callbacks X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 61 ------------------------------------------------------ src/main.h | 8 ------- 2 files changed, 69 deletions(-) diff --git a/src/main.c b/src/main.c index d311332..b4aa7f7 100644 --- a/src/main.c +++ b/src/main.c @@ -532,67 +532,6 @@ bool target_selected(struct pdbg_target *target) return path_target_selected(target); } -/* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */ -int for_each_child_target(char *class, struct pdbg_target *parent, - int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *), - uint64_t *arg1, uint64_t *arg2) -{ - int rc = 0; - struct pdbg_target *target; - uint32_t index; - enum pdbg_target_status status; - - pdbg_for_each_target(class, parent, target) { - if (!target_selected(target)) - continue; - - index = pdbg_target_index(target); - assert(index != -1); - status = pdbg_target_status(target); - if (status != PDBG_TARGET_ENABLED) - continue; - - rc += cb(target, index, arg1, arg2); - } - - return rc; -} - -int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *), uint64_t *arg1, uint64_t *arg2) -{ - struct pdbg_target *target; - uint32_t index; - enum pdbg_target_status status; - int rc = 0; - - pdbg_for_each_class_target(class, target) { - if (!target_selected(target)) - continue; - - index = pdbg_target_index(target); - assert(index != -1); - status = pdbg_target_status(target); - if (status != PDBG_TARGET_ENABLED) - continue; - - rc += cb(target, index, arg1, arg2); - } - - return rc; -} - -void for_each_target_release(char *class) -{ - struct pdbg_target *target; - - pdbg_for_each_class_target(class, target) { - if (!target_selected(target)) - continue; - - pdbg_target_release(target); - } -} - static bool target_selection(void) { switch (backend) { diff --git a/src/main.h b/src/main.h index b1366d9..a97826c 100644 --- a/src/main.h +++ b/src/main.h @@ -30,11 +30,3 @@ static inline bool target_is_disabled(struct pdbg_target *target) void target_select(struct pdbg_target *target); void target_unselect(struct pdbg_target *target); bool target_selected(struct pdbg_target *target); - -/* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */ -int for_each_child_target(char *class, struct pdbg_target *parent, - int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *), - uint64_t *arg1, uint64_t *arg2); - -int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *), uint64_t *arg1, uint64_t *arg2); -void for_each_target_release(char *class); From patchwork Fri Nov 23 04:40:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002115 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nt53Q0Vz9s7T for ; Fri, 23 Nov 2018 15:41:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B+duFS7k"; 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 431Nt51CF7zDqSw for ; Fri, 23 Nov 2018 15:41:01 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B+duFS7k"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsP17VdzDqRk for ; Fri, 23 Nov 2018 15:40:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B+duFS7k"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsN5s76z9s7T; Fri, 23 Nov 2018 15:40:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948024; bh=knjhjjuDrhIUGlaIyvHy8mg3hFymEjNn9b3QALvlWDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+duFS7kcrAD1pC0mnoMdyCIi3x6baSFRsUME+QHVhuTkmpJvbV/TW4yM3B4B9v3j //tln8vJhMtC/c0KzmiodNShu7cFYu1sdCcINTuVYyiQ/BgO13H3qtpFHhUSta1C0f xjdwIZK0KXwmL7YSx+n0L/0N2kPJG58IOmeVLOCpbazAjNf2xWUZUIdDlzqa/eQF6U pUNj68qQdmS0BjhvZHxrMu6r58cdf8pCLsROkk1z9+ICQNWUWYHQnQJuKnRX5N3Day jf0n8C5z6lD6hjfkzd6oT8le0rp2SaLySm4CcRShzM57NTu4WwveTI34W6u4xQGct/ 3bRVgLLUSC9xQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:17 +1100 Message-Id: <20181123044019.633814-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 08/10] main: Convert htm commands to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If none of the expected targets are selected, log an error. core htm - core target nest htm - pib target Signed-off-by: Amitay Isaacs --- src/htm.c | 106 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/src/htm.c b/src/htm.c index 10e35ae..e0c746d 100644 --- a/src/htm.c +++ b/src/htm.c @@ -37,6 +37,7 @@ #include #include "main.h" +#include "path.h" #define HTM_ENUM_TO_STRING(e) ((e == HTM_NEST) ? "nhtm" : "chtm") @@ -55,7 +56,9 @@ static inline void print_htm_address(enum htm_type type, printf("p%d:", pdbg_parent_index(target, "pib")); printf("c%d:", pdbg_parent_index(target, "core")); } - printf("t%d\n", pdbg_target_index(target)); + if (type == HTM_NEST) { + printf("p%d\n", pdbg_parent_index(target, "pib")); + } } static char *get_htm_dump_filename(struct pdbg_target *target) @@ -78,10 +81,7 @@ static int run_start(enum htm_type type) struct pdbg_target *target; int rc = 0; - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); + for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) { if (target_is_disabled(target)) continue; @@ -102,10 +102,7 @@ static int run_stop(enum htm_type type) struct pdbg_target *target; int rc = 0; - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); + for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) { if (target_is_disabled(target)) continue; @@ -126,10 +123,7 @@ static int run_status(enum htm_type type) struct pdbg_target *target; int rc = 0; - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); + for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) { if (target_is_disabled(target)) continue; @@ -151,10 +145,7 @@ static int run_dump(enum htm_type type) char *filename; int rc = 0; - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); + for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) { if (target_is_disabled(target)) continue; @@ -182,10 +173,7 @@ static int run_record(enum htm_type type) char *filename; int rc = 0; - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); + for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) { if (target_is_disabled(target)) continue; @@ -254,9 +242,11 @@ fail: int run_htm(int optind, int argc, char *argv[]) { - struct pdbg_target *target, *nhtm; + struct pdbg_target *target; enum htm_type type; struct pdbg_target *core_target = NULL; + struct pdbg_target *pib_target = NULL; + enum pdbg_target_status status; int i, rc = 0; /* @@ -283,29 +273,27 @@ int run_htm(int optind, int argc, char *argv[]) } if (type == HTM_CORE) { - pdbg_for_each_class_target("core", target) { - if (target_selected(target)) { - if (!core_target) { - core_target = target; - } else { - fprintf(stderr, "It doesn't make sense to core trace on" - " multiple cores at once.\n"); - fprintf(stderr, "What you probably want is -p 0 -c x\n"); - return 0; - } + for_each_path_target_class("core", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + if (!core_target) { + core_target = target; + } else { + fprintf(stderr, "It doesn't make sense to run core trace on multiple cores at once.\n"); + return 0; } } if (!core_target) { - fprintf(stderr, "You haven't selected any HTM Cores\n"); + fprintf(stderr, "No core selected\n"); return 0; } /* Check that powersave is off */ pdbg_for_each_class_target("thread", target) { - pdbg_target_probe(target); - - if (pdbg_target_status(target) == PDBG_TARGET_NONEXISTENT) + status = pdbg_target_probe(target); + if (status == PDBG_TARGET_NONEXISTENT) continue; if (!is_smt1(target)) @@ -313,21 +301,51 @@ int run_htm(int optind, int argc, char *argv[]) } /* Select the correct chtm target */ - pdbg_for_each_child_target(core_target, target) { - if (!strcmp(pdbg_target_class_name(target), "chtm")) { - target_select(target); - pdbg_target_probe(target); + pdbg_for_each_target("chtm", core_target, target) { + status = pdbg_target_probe(target); + if (status == PDBG_TARGET_ENABLED) { + assert(path_target_add(target)); + break; } } + + if (!target) { + fprintf(stderr, "No CHTM target enabled\n"); + return 0; + } } if (type == HTM_NEST) { - pdbg_for_each_class_target("pib", target) { - if (!target_selected(target)) + for_each_path_target_class("pib", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) continue; - pdbg_for_each_target("nhtm", target, nhtm) - target_select(nhtm); + if (!pib_target) { + pib_target = target; + } else { + fprintf(stderr, "It doesn't make sense to run nest trace on multiple cores at once.\n"); + + return 0; + } + } + + if (!pib_target) { + fprintf(stderr, "No pib selected\n"); + return 0; + } + + + pdbg_for_each_target("nhtm", pib_target, target) { + status = pdbg_target_probe(target); + if (status == PDBG_TARGET_ENABLED) { + assert(path_target_add(target)); + break; + } + } + + if (!target) { + fprintf(stderr, "No NHTM target enabled\n"); + return 0; } } From patchwork Fri Nov 23 04:40:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002116 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nt83NRqz9s7T for ; Fri, 23 Nov 2018 15:41:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ygKn3JQd"; 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 431Nt817YQzDqTL for ; Fri, 23 Nov 2018 15:41:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ygKn3JQd"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsP3k8pzDqSr for ; Fri, 23 Nov 2018 15:40:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ygKn3JQd"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsP0sRQz9sCV; Fri, 23 Nov 2018 15:40:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948025; bh=8uv0lg+g2j2rWi/YAOuT9lKMLgblpO0+vMMngjjxScs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ygKn3JQdibzqu2eyQM+NMSR6glIrlL7nxroTG37tg17zxLIkz9KP+0eID4ATdSGkD BeH6qiTYrlfkZbwf7Ssmb1flBDHcvQLw+GK4z+SC8eh2vQ0oEQe9gq7wy8stGrtIJa FW/LU5PIYiVTI2DWCsASVFWHfLEOVdxvamLNIRImZF6uhLEZnQZUDPvmR463o64FBQ sYMnJxjiExdutaedNW6RW1yHbmy4b/r9UP8Vs11a/IIeFto7j4y/oS+ApDOWNIDCf0 6aq0mQ8LLL4q7NJ+9e6msr3s3OI5LhC+SXo6I+ijZPFFDoel5MVVMtG20ZcmHsKfK1 GJrJQQ+i213nQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:18 +1100 Message-Id: <20181123044019.633814-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 09/10] main: Convert gdbserver command to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Rashmica Gupta --- src/pdbgproxy.c | 77 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 697e58e..dedea7a 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -24,6 +24,7 @@ #include "optcmd.h" #include "debug.h" #include "chip.h" +#include "path.h" #ifndef DISABLE_GDBSERVER @@ -41,6 +42,7 @@ #define TEST_SKIBOOT_ADDR 0x40000000 static struct pdbg_target *thread_target = NULL; +static struct pdbg_target *adu_target; static struct timeval timeout; static int poll_interval = 100; static int fd = -1; @@ -200,7 +202,6 @@ static uint64_t get_real_addr(uint64_t 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)]; @@ -210,17 +211,6 @@ static void get_mem(uint64_t *stack, void *priv) 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) { PR_INFO("Too much memory requested, truncating\n"); len = MAX_DATA; @@ -233,7 +223,7 @@ static void get_mem(uint64_t *stack, void *priv) linear_map = get_real_addr(addr); if (linear_map != -1UL) { - if (adu_getmem(adu, linear_map, (uint8_t *) data, len)) { + if (adu_getmem(adu_target, linear_map, (uint8_t *) data, len)) { PR_ERROR("Unable to read memory\n"); err = 1; } @@ -261,7 +251,6 @@ out: 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, 0x00, 0x02, 0x00}; @@ -277,17 +266,6 @@ static void put_mem(uint64_t *stack, void *priv) 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_real_addr(addr); if (addr == -1UL) { PR_ERROR("TODO: No virtual address support for putmem\n"); @@ -315,7 +293,7 @@ static void put_mem(uint64_t *stack, void *priv) PR_INFO("put_mem 0x%016" PRIx64 " = 0x%016" PRIx64 "\n", addr, stack[2]); - if (adu_putmem(adu, addr, data, len)) { + if (adu_putmem(adu_target, addr, data, len)) { PR_ERROR("Unable to write memory\n"); err = 3; } @@ -442,14 +420,15 @@ command_cb callbacks[LAST_CMD + 1] = { disconnect, NULL}; -int gdbserver_start(struct pdbg_target *target, uint16_t port) +int gdbserver_start(struct pdbg_target *thread, struct pdbg_target *adu, uint16_t port) { int sock, i; struct sockaddr_in name; fd_set active_fd_set, read_fd_set; parser_init(callbacks); - thread_target = target; + thread_target = thread; + adu_target = adu; sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { @@ -516,34 +495,54 @@ int gdbserver_start(struct pdbg_target *target, uint16_t port) static int gdbserver(uint16_t port) { - struct pdbg_target *target = NULL; + struct pdbg_target *target, *adu, *thread = NULL; uint64_t msr; int rc; - for_each_class_target("thread", target) { - if (!target_selected(target)) + for_each_path_target_class("thread", target) { + if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; - if (pdbg_target_probe(target) == PDBG_TARGET_ENABLED) - break; + + if (!thread) { + thread = target; + } else { + fprintf(stderr, "GDB server cannot be run on multiple threads at once.\n"); + return 0; + } } - if (!target->class) - return -1; - assert(!strcmp(target->class, "thread")); + + if (!thread) { + fprintf(stderr, "No thread selected\n"); + return 0; + } + + // // Temporary until I can get this working a bit smoother on p9 - if (strcmp(target->compatible, "ibm,power8-thread")) { + if (strcmp(thread->compatible, "ibm,power8-thread")) { PR_ERROR("GDBSERVER is only tested on POWER8\n"); return -1; } /* Check endianess in MSR */ - rc = ram_getmsr(target, &msr); + rc = ram_getmsr(thread, &msr); if (rc) { PR_ERROR("Couldn't read the MSR. Are all threads on this chiplet quiesced?\n"); return 1; } littleendian = 0x01 & msr; - gdbserver_start(target, port); + /* Select ADU target */ + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) + break; + } + + if (!adu) { + fprintf(stderr, "No ADU found\n"); + return 0; + } + + gdbserver_start(thread, adu, port); return 0; } #else From patchwork Fri Nov 23 04:40:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002117 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431NtD4lXMz9s7T for ; Fri, 23 Nov 2018 15:41:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Vbx3s5RY"; 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 431NtD2KlMzDqT8 for ; Fri, 23 Nov 2018 15:41:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Vbx3s5RY"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsP5xWFzDqRk for ; Fri, 23 Nov 2018 15:40:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Vbx3s5RY"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsP3Q26z9s1c; Fri, 23 Nov 2018 15:40:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948025; bh=Eu8y/+CzqRUEMW38SR/3KUyXflWqI/dawJYbBrb9qCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vbx3s5RYtDeg19nlHWALY5oEVfADcwz8lKO+sYum9LFB138qACW9DLFyZu11MelKH rpm/AYLiyb4Zw3OHe/+tCA5QJak1/pBSTD+lknHsqw6aonNcLwKx0oJkDcLzWh4oeC /YCZNn4SCj0wx6SkUlLAYRJXqJxMsDsTDYXGY4hetSirKfPm8Gg/mKA1XV01+WVGUF I4AbW3w24DzwpyNOPhd235IRrkF7LoZs6UoEIxHk1o6B8zOgIPBunN2jRZV2coUSCS ptRa/kj8cKFU+wOoMUr3LZ6qB2dzeH35JVRLxtBtRSnn4JTSw7jlR/F+TDFuZMPLdW glraSWtmNK6gA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:19 +1100 Message-Id: <20181123044019.633814-11-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 10/10] main: Drop unused target_select/target_selected functions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 12 +----------- src/main.h | 4 ---- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main.c b/src/main.c index b4aa7f7..1f68fa8 100644 --- a/src/main.c +++ b/src/main.c @@ -522,16 +522,6 @@ static bool parse_options(int argc, char *argv[]) return true; } -void target_select(struct pdbg_target *target) -{ - path_target_add(target); -} - -bool target_selected(struct pdbg_target *target) -{ - return path_target_selected(target); -} - static bool target_selection(void) { switch (backend) { @@ -634,7 +624,7 @@ static void print_target(struct pdbg_target *target, int level) return; printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); - if (target_selected(target)) + if (path_target_selected(target)) printf(" (*)"); printf("\n"); diff --git a/src/main.h b/src/main.h index a97826c..78b4d92 100644 --- a/src/main.h +++ b/src/main.h @@ -26,7 +26,3 @@ static inline bool target_is_disabled(struct pdbg_target *target) return pdbg_target_status(target) == PDBG_TARGET_DISABLED || pdbg_target_status(target) == PDBG_TARGET_NONEXISTENT; } - -void target_select(struct pdbg_target *target); -void target_unselect(struct pdbg_target *target); -bool target_selected(struct pdbg_target *target);