From patchwork Fri Nov 9 07:10:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 996221 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 42tWdL0RT3z9s7h for ; Mon, 12 Nov 2018 11:21:10 +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="NXz6sdr0"; 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 42tWdK47lYzF3Ql for ; Mon, 12 Nov 2018 11:21:09 +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="NXz6sdr0"; 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 42rrry4SdNzF3ZM for ; Fri, 9 Nov 2018 18:10:26 +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="NXz6sdr0"; 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 42rrry21BSz9sBZ; Fri, 9 Nov 2018 18:10:26 +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=1541747426; bh=2Mfubnr3I4PBzASjkaqbmnyuJtK8imoL8a/hxQUz7O8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NXz6sdr0heIUnBdS04P7QQZhxGTtdX8TbbkN7qqzuUpuigS1iItdrulmvDKefXuxU f6UIBrr7o03ZkrnR/U89TLePPYconobjaXNBFTEWYXWck2bJ4E94KQWxqUFSs+Gzz/ p4iC7faBHJaBNu7vIWBQ2CGIzZLkNBWE2C3h2lXszMIPzApufMlV6QGZfwBzLpo1Rf d8MjWNFQTiJ3a9Dk2+IKUfRoXWfNe8PIO6Qc5aRk5Pwg21/dzrqNIAED79le/fnH3M +qE2/OZF7JfWYn2+nR2uhpcn0Sj3aT3KKGuBc4wHnUwgMH7X+Hiy3fkyDPtK64HWW/ yCV0BBoqF2pEw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 9 Nov 2018 18:10:08 +1100 Message-Id: <20181109071011.253734-13-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181109071011.253734-1-amitay@ozlabs.org> References: <20181109071011.253734-1-amitay@ozlabs.org> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 12 Nov 2018 11:21:06 +1100 Subject: [Pdbg] [PATCH v2 12/15] main: Update probe output to display device names 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" With capability of selecting any target in the device tree, probe output should display all the nodes with their device tree names. Signed-off-by: Amitay Isaacs --- src/main.c | 46 ++- tests/test_selection.sh | 591 +++++++++++++-------------- tests/test_selection2.sh | 838 ++++++++++++++++++++------------------- 3 files changed, 755 insertions(+), 720 deletions(-) diff --git a/src/main.c b/src/main.c index 77db48e..4654f71 100644 --- a/src/main.c +++ b/src/main.c @@ -670,38 +670,43 @@ static bool target_selection(void) return true; } +static void mark_target(struct pdbg_target *target) +{ + while (target && target != pdbg_target_root()) { + pdbg_target_priv_set(target, (void *)1); + target = pdbg_target_parent(NULL, target); + } +} + void print_target(struct pdbg_target *target, int level) { int i; struct pdbg_target *next; enum pdbg_target_status status; + char *classname; + void *priv; /* Does this target actually exist? */ status = pdbg_target_status(target); if (status != PDBG_TARGET_ENABLED) return; + /* Is this target marked for printing */ + priv = pdbg_target_priv(target); + if (!priv) + return; + for (i = 0; i < level; i++) printf(" "); - if (target) { - char c = 0; - - if (!pdbg_target_class_name(target)) - return; - - if (!strcmp(pdbg_target_class_name(target), "pib")) - c = 'p'; - else if (!strcmp(pdbg_target_class_name(target), "core")) - c = 'c'; - else if (!strcmp(pdbg_target_class_name(target), "thread")) - c = 't'; + classname = pdbg_target_class_name(target); + if (!classname) + return; - if (c) - printf("%c%d: %s\n", c, pdbg_target_index(target), pdbg_target_name(target)); - else - printf("%s\n", pdbg_target_name(target)); - } + printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); + if (target_selected(target)) + printf(" (*)"); + printf("\n"); pdbg_for_each_child_target(target, next) { print_target(next, level + 1); @@ -712,7 +717,12 @@ static int probe(void) { struct pdbg_target *target; - pdbg_for_each_class_target("pib", target) { + /* Mark all targets and their parents which are selected */ + for_each_path_target(target) { + mark_target(target); + } + + pdbg_for_each_child_target(pdbg_target_root(), target) { print_target(target, 0); } diff --git a/tests/test_selection.sh b/tests/test_selection.sh index 8909796..8a24a12 100755 --- a/tests/test_selection.sh +++ b/tests/test_selection.sh @@ -23,110 +23,111 @@ test_run pdbg -b fake probe test_result 0 <