From patchwork Tue Nov 20 04:19:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000259 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 42zXYN0zk1z9s4s for ; Tue, 20 Nov 2018 15:20: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="wkynwqz9"; 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 42zXYM2pTLzF3SW for ; Tue, 20 Nov 2018 15:20:07 +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="wkynwqz9"; 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 42zXYG10HrzF3Qx for ; Tue, 20 Nov 2018 15:20:02 +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="wkynwqz9"; 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 42zXYF5Bd6z9s4s; Tue, 20 Nov 2018 15:20:01 +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=1542687601; bh=jW+vbPdlzsEOVPFXGd4CtKUfD5olFssw69/qX513j9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wkynwqz9A20mQ4LCJOatoXobbzuydwONICAjdNWBwVUL+A1WyGARfWYZM2w/QG/e3 zLNJl6XoTWMcnXwD5VEk+cWzPNtqJSVL/z6tbBLogegX1pOllX9yws+Unsx2yaXz3N CRLNiH5Oi7gDc0q8fGy58jV312OKBnH+9uuEtbA8xLWa/hGizRbra8xpLY5hCMU0QI SVlEzvn3zTiO5WrYTNDwEl7yw27PTQ9JdF/dlw+4XWLyC4syA/uTNO3MdoxJDoIT0j bBgZ40MJ/1H4idngxC1iM82iq+mNMtcFfAsfAvf4oi2v0ixZ8zpD0YVjH69Gbe2w9M hDvLMfto308cg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:45 +1100 Message-Id: <20181120041953.402413-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 1/9] 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 961d850..8c83a49 100644 --- a/src/main.c +++ b/src/main.c @@ -672,7 +672,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 Tue Nov 20 04:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000261 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 42zXYX3hp4z9s8r for ; Tue, 20 Nov 2018 15:20:16 +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="yKfSaAqc"; 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 42zXYX1bv6zF3Sc for ; Tue, 20 Nov 2018 15:20:16 +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="yKfSaAqc"; 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 42zXYG5hZTzF3RC for ; Tue, 20 Nov 2018 15:20:02 +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="yKfSaAqc"; 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 42zXYG0bwvz9s8r; Tue, 20 Nov 2018 15:20:02 +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=1542687602; bh=bV0+3bYLdmQGTO7SM6uqAHKXpyR/eZrQKa0zUPToYb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yKfSaAqc8NmnupCYFfV3sBVrOSOvVFcdlLxEp3AjraI1Yb2PL6R1NPl8GPECz6tR5 v88mxeG+0NN6A5uOxWmBcQCID7ZPNXjN/CEUL1Sem2gOy/7gwSR2sOpe7iRId/ReJ4 Hfr1HbTiD/i8+IHouhogeYBSBskZEnzrh648e7TMo4uwUVrBe3sir86VePDmw4qKjk qBNQf1zJev5slQ2xm4vxVWAfk7Nt5SVaCfyHWDHzD5mmvyaIt+g0DNY6mecFzhl9ie tTWHiY7Bdj0xDeXoiKTXeT2+zDXjYq95wFvhnGOdg2MZJD0vwRFSyIsCszlw0e+V7a fix4dX7sMt2/w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:46 +1100 Message-Id: <20181120041953.402413-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/9] 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 Tue Nov 20 04:19:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000262 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 42zXYc2LD9z9s8r for ; Tue, 20 Nov 2018 15:20:20 +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="toStGddt"; 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 42zXYc0LPxzF3TJ for ; Tue, 20 Nov 2018 15:20:20 +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="toStGddt"; 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 42zXYG60b5zF3RF for ; Tue, 20 Nov 2018 15:20:02 +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="toStGddt"; 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 42zXYG2BhXz9s9G; Tue, 20 Nov 2018 15:20:02 +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=1542687602; bh=CVAg/EFkbk4AUyA0mYf72rOjVgDAhy/7a6wh8G9aPMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=toStGddtwZZ4kwlMfPzdngzD62btA4IpuN3FOO7Pgh+D5H9yAp8qXJZo5eTWmMADl UfnGqb+AxOjD0+dxVvq1zjceSTXCMTHd1N84kWzqprIWgukxBFhSb685N261e+TRd9 ARUUvoaLN2Llv/l4qHv15b8fBPgTK90dTDQ5P2N1s1tiHkDxEQtELtpPjiKzdEftAp 1y70lbg82CQEDBIK+FnoPqRnAaoqOIy/GOLeJnDPZd3tX7gZkKi991B0IqrV8E/1Jo PsHS6+hnj/2M0FAeiqIwhsvyltf4TLrVwx1feM5h7lBVnSrc+GM1N8d3gHb7PjEnT3 ZmHUPg2n4USSw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:47 +1100 Message-Id: <20181120041953.402413-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 3/9] 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 Tue Nov 20 04:19:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000263 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 42zXYg0bdFz9s8r for ; Tue, 20 Nov 2018 15:20:23 +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="gHd4Xagg"; 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 42zXYf5Z1XzF3Rv for ; Tue, 20 Nov 2018 15:20:22 +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="gHd4Xagg"; 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 42zXYH0SFCzF3QJ for ; Tue, 20 Nov 2018 15:20:03 +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="gHd4Xagg"; 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 42zXYG4tftz9s3q; Tue, 20 Nov 2018 15:20:02 +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=1542687602; bh=2awv0Xn7DU2H3ciluB88SNap1ftuXT3PdmCH5ZnkuDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHd4XaggzPfGxbyd8NR2QgXFbDg5QWEUF39XiA+04QEFJx3t23qxTnzFZghh85JxD M9pfh9x1ZZSoDzEL5rJlv/fQWNWjVQKCrmK1k7O25Iagf3lyTWSNNS5RKcIwYg2HI/ xE+hd+66rIn3ssf36ooBMCl/xhBhmp/TTgME6529M58fWup95RhvfAbn7xg26IbEW/ fGwVsK/KgJh25Kl8ECE8MSfPp7ZaWGals4eJr2wufoD2dvM2klxev29fbxQXWQuvgR sYh/eVjUPuJzBPg8pLiyEARfmzvaXYhNI8d7+5+s+2+dP/4SZPdW5P2lrOkDLbKq3I fzeP9NqqYYYyw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:48 +1100 Message-Id: <20181120041953.402413-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 4/9] 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 Tue Nov 20 04:19:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000264 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 42zXYk06bfz9s8r for ; Tue, 20 Nov 2018 15:20:26 +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="RyfPnFFf"; 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 42zXYj4gbRzF3TK for ; Tue, 20 Nov 2018 15:20:25 +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="RyfPnFFf"; 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 42zXYH35fWzF3Qx for ; Tue, 20 Nov 2018 15:20:03 +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="RyfPnFFf"; 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 42zXYH0KWvz9s4s; Tue, 20 Nov 2018 15:20:03 +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=1542687603; bh=3QIkdDYcpP1v7+Tm+vZp3sViPSVQGflIOsuoMXW+aeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RyfPnFFffrpnjCGG0e8Cb43HKjeoiA6DMZRYKZYc1MXKjSxXdooRhNq34pPTiZ9SR EvzR+WztAsvTwACrp3N/cEl3n0Q50eyOtp3jg09ALjzz7NNcQcDpURyFHhRXJYA5lN c3QmgAFVir7JO/z11g807qiRbc0UhRFbPBlJ6ItdarlBYqwBd7XMuxOfTr+mzc1w5X q+QuZFXsC/NbSNDwbwKdXa8Ctsq/99X5ViCZHBDXNFIgbkhB825iNUlIusNMdclLEK EYk/vwSv3zIbS+uKneRu3o79kkPlN2r46V4w3Xj8xdpKnqdpEG5Fu0dTQUIlHq384Z sSyjXtiP4DyVg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:49 +1100 Message-Id: <20181120041953.402413-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 5/9] 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 Tue Nov 20 04:19:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000265 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 42zXYm5LmSz9s4s for ; Tue, 20 Nov 2018 15:20:28 +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="J39kk48D"; 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 42zXYm3DRszF3TC for ; Tue, 20 Nov 2018 15:20:28 +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="J39kk48D"; 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 42zXYH5PTNzF3QJ for ; Tue, 20 Nov 2018 15:20:03 +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="J39kk48D"; 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 42zXYH2qb7z9s3q; Tue, 20 Nov 2018 15:20:03 +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=1542687603; bh=mePzTCiIctybCSr7dowZMuzXbrgiCk1b3tQ8Etzitb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J39kk48DpgDpzHU+wUyXRfdVUDb+3QNKagOw0Jvn50saOlFc9K80lpzOCtS90KGLD qgPrdb3mDqnX6aKLo056azBMzUAWp82FZg6NCdOg6rBXpUg56fGYc5SCpxHt1VY48q jzNvBmLHTkSEjXpQdpljWdevucIcsz+VjNpRUjO3VsXyd1v2DGF0Co5XlCXoQ7Pyjd us72CpalKMX28g6pkS4RDAdjVmgvgKNLkq9ujgEwhVrW8gnlS19KGyusblwId5eBuj yi/3QAMxzMmCBHDMhSUPRqwyS7vhUaha5frIoPC80djz1p68rXPXqVn8zpWr5lvNXb ubxCoCQyKwWIQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:50 +1100 Message-Id: <20181120041953.402413-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 6/9] 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 8c83a49..6693349 100644 --- a/src/main.c +++ b/src/main.c @@ -529,67 +529,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 Tue Nov 20 04:19:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000266 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 42zXYr6g27z9s4s for ; Tue, 20 Nov 2018 15:20:32 +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="lPs0UTpv"; 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 42zXYq64rkzF3Tf for ; Tue, 20 Nov 2018 15:20:31 +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="lPs0UTpv"; 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 42zXYJ0Z0pzF3Qx for ; Tue, 20 Nov 2018 15:20:04 +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="lPs0UTpv"; 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 42zXYH559xz9s8r; Tue, 20 Nov 2018 15:20:03 +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=1542687603; bh=+CVW9jCDktCOBwI2ukeaHjiJTJdDbMklAglLRVBK4wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPs0UTpvsjxhOC3uEd0+ZHQqLi99F9XIWTHRmCL1DbnNsEmPtIAMPZgpiH1/osfLy bZQIgf63M45wNtbkr32UDdyblc0cGNNfC+l3Cn47TMU5/rZpQEumRzaOGDCfUYPmYm Er/BWav3EUx1FpKn8G4VwDvGZPYrcPKw8ksROWmOLhbiplSnpd0Py03zCgGheVU213 Pd5fcv9eLFiuHPTZSLmxBAY+Iny9pwKV4BA/JcFz43n5TNAtQilDcULtOvRMl5pQkv H2W6MEGsXE6B6WwcWCSkdcc3RuDURlnU9SgvsBsEJWjfEwQNLVy/74fODU8zb585ni oF/tHBtGBYOcg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:51 +1100 Message-Id: <20181120041953.402413-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 7/9] 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" Signed-off-by: Amitay Isaacs --- src/htm.c | 57 +++++++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/src/htm.c b/src/htm.c index 10e35ae..b0e25a3 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") @@ -78,10 +79,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 +100,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 +121,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 +143,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 +171,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; @@ -283,16 +269,14 @@ 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 (!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; } } @@ -315,19 +299,18 @@ 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); + assert(path_target_add(target)); pdbg_target_probe(target); } } } if (type == HTM_NEST) { - pdbg_for_each_class_target("pib", target) { - if (!target_selected(target)) - continue; - - pdbg_for_each_target("nhtm", target, nhtm) - target_select(nhtm); + for_each_path_target_class("pib", target) { + pdbg_for_each_target("nhtm", target, nhtm) { + assert(path_target_add(nhtm)); + pdbg_target_probe(nhtm); + } } } From patchwork Tue Nov 20 04:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000267 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 42zXYv70pQz9s8r for ; Tue, 20 Nov 2018 15:20:35 +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="iXK0ZTXQ"; 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 42zXYv4KwmzF3Vb for ; Tue, 20 Nov 2018 15:20:35 +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="iXK0ZTXQ"; 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 42zXYJ2lxJzF3QJ for ; Tue, 20 Nov 2018 15:20:04 +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="iXK0ZTXQ"; 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 42zXYJ0G2tz9s3q; Tue, 20 Nov 2018 15:20:04 +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=1542687604; bh=3h7tySQH103LowsGZ9KhAmL5HX9et8pvH/TCL2iBcTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXK0ZTXQ42JEKX6Qb6YMlIwlPAQVVpY14Or6ZOJRkqAV/14mAJ9z6TKBfuwZ2JBAt ZIbYEUffWZjO55oAXOE6O5tQXcbdcLZNoxB5fggJcDlYT6hUU8318ih1Glme58Vy/A WjnOmmPRNHUYRuf8rkahQfI9GXd3ha/5RMzmVG5HvI9e3WHS9DWc1SzTEH8gXpn8lT NO+m1juhIFGUHcSGdQIdyumjyRJQ9ygiPLpqXI5HosT+sUtf1wKdqLgTJbTg0Ht5KK HCIR354vvh4WjmKflpsx5D4rVjaUJiFrCLSaVBkXuUpWut1P0Qh/4D03Q+vLtoBSBb xx73VBohGgITw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:52 +1100 Message-Id: <20181120041953.402413-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 8/9] 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 --- src/pdbgproxy.c | 72 +++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 697e58e..d317aec 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,49 @@ 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")); + + // // 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) { + PR_ERROR("No ADU found\n"); + return 0; + } + + gdbserver_start(thread, adu, port); return 0; } #else From patchwork Tue Nov 20 04:19:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000268 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 42zXYy5hnhz9s8r for ; Tue, 20 Nov 2018 15:20:38 +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="W4iRpe5U"; 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 42zXYy3PCnzF3VG for ; Tue, 20 Nov 2018 15:20: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="W4iRpe5U"; 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 42zXYJ5PWMzF3RC for ; Tue, 20 Nov 2018 15:20:04 +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="W4iRpe5U"; 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 42zXYJ2RfLz9s4s; Tue, 20 Nov 2018 15:20:04 +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=1542687604; bh=bbH4xJewxK7mQChaqi4m4HnR9CipmDN1vyqE8dvHv9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4iRpe5UggxzdZf31PStOdCZ/DW0LP4YwURQW6VU8b8CgF2M1FqLkY3D2NqWqDxqQ o7IfR1vulG3oXYINrHn6k8bLwbKmnmV/zGwgg8xvs16+ZuLjMzbO0ESSMUkzcvHdFn rrdpRPlzefeHN5+PeqxZPClBGHzCH//IjojY+J6TESKdsGyhiltWAoGiKS1ocpFlUV 0pJgs1UooAWyW/cPH+hZMlC1ckkNCi63QfioGx4npsdpw01v6xsycu382qn841nUtg ljh/KYtccn4+e4RG9Ttp9imMqKi1NCLnpuTmNzYhJgDpZz6e8KLa5NAefYKxeWiuNH iJkNTndCakj4w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:53 +1100 Message-Id: <20181120041953.402413-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 9/9] 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 6693349..358d0e0 100644 --- a/src/main.c +++ b/src/main.c @@ -519,16 +519,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) { @@ -631,7 +621,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);