From patchwork Tue Oct 2 06:04:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTNl1tLwz9shx for ; Tue, 2 Oct 2018 16:13:27 +1000 (AEST) 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="oQRtCkOJ"; 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 42PTNk6stzzF3Dy for ; Tue, 2 Oct 2018 16:13:26 +1000 (AEST) 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="oQRtCkOJ"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBZ6dYFzDrCl for ; Tue, 2 Oct 2018 16:04:38 +1000 (AEST) 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="oQRtCkOJ"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBZ49lrz9shx; Tue, 2 Oct 2018 16:04:38 +1000 (AEST) 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=1538460278; bh=vPvKog6DBv/Tm077znUK1POUw9QmZ68yafPjgSnhWww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQRtCkOJAVk7PqSSZ7Xe1yc6ht/k/uNMRJEFYesUoTBZz/ULeUDtl326QBvlXFsnZ JoiK3+VL+kBVA2e98JG/mFVUgp0KYvINJMZeDjgIVnrTGdNHjudAjg/egxJSH6ev5q j7Cu+hW5IWqvngnC2MM6Iy22rex3nt++SBoWVGpgQKHDq+4iuJlA/Kewou6olf8Tfn 4YCNNUo9sPX0FqoA98KKmuDkSAJElCHLW8M9+lPkaIBZhm7yE1mMjZAbwi2O67kESF 05NilPzfPvzD1NKif/RN7eTMcPokbj7oV7DH0nMobroYDyUKx0GOEqxkgZtrkQhvYp lkmXWVu0KzZsg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:22 +1000 Message-Id: <20181002060430.3344784-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 01/10] main: Convert target_selection() to return a boolean 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- src/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index d6dffcd..cbcf612 100644 --- a/src/main.c +++ b/src/main.c @@ -597,7 +597,7 @@ void for_each_target_release(char *class) } } -static int target_selection(void) +static bool target_selection(void) { struct pdbg_target *fsi, *pib, *chip, *thread; @@ -610,7 +610,7 @@ static int target_selection(void) case FSI: if (device_node == NULL) { PR_ERROR("FSI backend requires a device type\n"); - return -1; + return false; } if (!strcmp(device_node, "p8")) pdbg_targets_init(&_binary_p8_fsi_dtb_o_start); @@ -622,14 +622,14 @@ static int target_selection(void) pdbg_targets_init(&_binary_p9z_fsi_dtb_o_start); else { PR_ERROR("Invalid device type specified\n"); - return -1; + return false; } break; case KERNEL: if (device_node == NULL) { PR_ERROR("kernel backend requires a device type\n"); - return -1; + return false; } if (!strcmp(device_node, "p8")) pdbg_targets_init(&_binary_p8_kernel_dtb_o_start); @@ -643,7 +643,7 @@ static int target_selection(void) case HOST: if (device_node == NULL) { PR_ERROR("Host backend requires a device type\n"); - return -1; + return false; } if (!strcmp(device_node, "p8")) pdbg_targets_init(&_binary_p8_host_dtb_o_start); @@ -651,7 +651,7 @@ static int target_selection(void) pdbg_targets_init(&_binary_p9_host_dtb_o_start); else { PR_ERROR("Unsupported device type for host backend\n"); - return -1; + return false; } break; #endif @@ -664,7 +664,7 @@ static int target_selection(void) /* parse_options deals with parsing user input, so it should be * impossible to get here */ assert(0); - return -1; + return false; } /* At this point we should have a device-tree loaded. We want @@ -719,7 +719,7 @@ static int target_selection(void) target_unselect(fsi); } - return 0; + return true; } void print_target(struct pdbg_target *target, int level) @@ -811,7 +811,7 @@ int main(int argc, char *argv[]) device_node = default_target(backend); /* Disable unselected targets */ - if (target_selection()) + if (!target_selection()) return 1; atexit(atexit_release); From patchwork Tue Oct 2 06:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTNc53v5z9shx for ; Tue, 2 Oct 2018 16:13:20 +1000 (AEST) 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="Qyjhv7DQ"; 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 42PTNc3JmyzF3Fj for ; Tue, 2 Oct 2018 16:13:20 +1000 (AEST) 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="Qyjhv7DQ"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBb1bPxzF3Dy for ; Tue, 2 Oct 2018 16:04:39 +1000 (AEST) 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="Qyjhv7DQ"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBZ6BX8z9shy; Tue, 2 Oct 2018 16:04:38 +1000 (AEST) 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=1538460278; bh=8sqJ4XSwBbFJBWtL81VyziAooPVpgSy2dGQAzO0EDDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qyjhv7DQt4V4LYhu+r+BR9nivLNNhVjBGaYFd0IYx6/f5liuH3KroDK8ilUXraNPZ KfXY8r+yDHiw++op2HFh2uqXq6yDBqj11bIBuqEGQmxXIl8S7pj/IYk/oR6MbReQ2m DPdA8ynXWatguRdaorSbDop/3f73eEqF6inHfHN2kDvqbNeRLPsFrCi7fFfNCu0rI2 YfcRWbwhiPVd8DI5DNHFUHQcwDim11DEflFud5PU7V0+vw8B3opJfregGAGPEg1q78 4sVvNAePsiwmjfPJCiQ7sPS+ZiFkBwKIPdtPQB6/viWwlIjxB2zYULBh0soBFiTbqH 5XA8IBhNaUmSQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:23 +1000 Message-Id: <20181002060430.3344784-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 02/10] Makefile: Keep the list of dependencies sorted 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 88aabe9..86d8733 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,24 +66,24 @@ optcmd_test_SOURCES = src/optcmd.c src/parsers.c src/tests/optcmd_test.c optcmd_test_CFLAGS = -Wall -g pdbg_SOURCES = \ - src/main.c \ src/cfam.c \ - src/scom.c \ - src/reg.c \ - src/mem.c \ - src/thread.c \ - src/ring.c \ src/htm.c \ - src/progress.c \ - src/parsers.c \ - src/optcmd.c \ - src/options_@ARCH@.c \ src/htm.h \ + src/main.c \ src/main.h \ + src/mem.c \ + src/optcmd.c \ src/optcmd.h \ + src/options_@ARCH@.c \ src/options.h \ + src/parsers.c \ src/parsers.h \ - src/progress.h + src/progress.c \ + src/progress.h \ + src/reg.c \ + src/ring.c \ + src/scom.c \ + src/thread.c src/main.c: $(DT_headers) From patchwork Tue Oct 2 06:04:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTNp6cG3z9shx for ; Tue, 2 Oct 2018 16:13:30 +1000 (AEST) 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="lCWt3NIk"; 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 42PTNp3vCKzF38q for ; Tue, 2 Oct 2018 16:13:30 +1000 (AEST) 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="lCWt3NIk"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBb4kxPzF3Bw for ; Tue, 2 Oct 2018 16:04:39 +1000 (AEST) 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="lCWt3NIk"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBb1Bcrz9sj0; Tue, 2 Oct 2018 16:04:39 +1000 (AEST) 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=1538460279; bh=gOh7WQZGGg9bpZ+YOXACmLhVkGWenNVrF3oIVFsjqAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCWt3NIk30mSDixlufDD5iIjRS1cw7804d0EtAWn05yRrNPpwzqidD46d3Bjc+1tn 1k4ovM0PzW6TJYKvGdJRFczL2mwDj2NWMei/tNnRRICUe74TSj7DkF9VKPVI2ZiiM0 suHlKI/OfE8tpd+LgsgE0S/F6AA/gP4UMs1Dxh2TR0O28N/XjbuhcHJlNtQwN1pqqM ojRZFGzxfX1PbdFH34tBrrws6d3HHUxwkS/hzo0nNbNPnUy+eqEdz4duhnBNKGFILd nZ/KPQjngE4aawuAlcuz4VOV1adGimBcyiGCOvht3QI0P8xvztm0kzX9tLWkSlADAm uWcWG0BA/Pugg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:24 +1000 Message-Id: <20181002060430.3344784-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 03/10] util: Move parse_list() into a separate file 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" ... and document the function. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 4 ++- src/main.c | 74 +---------------------------------------- src/util.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 34 +++++++++++++++++++ 4 files changed, 133 insertions(+), 74 deletions(-) create mode 100644 src/util.c create mode 100644 src/util.h diff --git a/Makefile.am b/Makefile.am index 86d8733..8bf2ba0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -83,7 +83,9 @@ pdbg_SOURCES = \ src/reg.c \ src/ring.c \ src/scom.c \ - src/thread.c + src/thread.c \ + src/util.c \ + src/util.h src/main.c: $(DT_headers) diff --git a/src/main.c b/src/main.c index cbcf612..f89ff6b 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "options.h" #include "optcmd.h" #include "progress.h" +#include "util.h" #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) @@ -177,79 +178,6 @@ static void print_usage(char *pname) printf(" %-15s %-27s %s\n", actions[i].name, actions[i].args, actions[i].desc); } -/* Parse argument of the form 0-5,7,9-11,15,17 */ -static bool parse_list(const char *arg, int max, int *list, int *count) -{ - char str[strlen(arg)+1]; - char *tok, *tmp, *saveptr = NULL; - int i; - - assert(max < INT_MAX); - - strcpy(str, arg); - - tmp = str; - while ((tok = strtok_r(tmp, ",", &saveptr)) != NULL) { - char *a, *b, *endptr, *saveptr2 = NULL; - unsigned long int from, to; - - a = strtok_r(tok, "-", &saveptr2); - if (a == NULL) { - return false; - } else { - endptr = NULL; - from = strtoul(a, &endptr, 0); - if (*endptr != '\0') { - fprintf(stderr, "Invalid value %s\n", a); - return false; - } - if (from >= max) { - fprintf(stderr, "Value %s larger than max %d\n", a, max-1); - return false; - } - } - - b = strtok_r(NULL, "-", &saveptr2); - if (b == NULL) { - to = from; - } else { - endptr = NULL; - to = strtoul(b, &endptr, 0); - if (*endptr != '\0') { - fprintf(stderr, "Invalid value %s\n", b); - return false; - } - if (to >= max) { - fprintf(stderr, "Value %s larger than max %d\n", b, max-1); - return false; - } - } - - if (from > to) { - fprintf(stderr, "Invalid range %s-%s\n", a, b); - return false; - } - - for (i = from; i <= to; i++) - list[i] = 1; - - tmp = NULL; - }; - - if (count != NULL) { - int n = 0; - - for (i = 0; i < max; i++) { - if (list[i] == 1) - n++; - } - - *count = n; - } - - return true; -} - #ifdef TARGET_PPC int get_pir(int linux_cpu) { diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..3a4520d --- /dev/null +++ b/src/util.c @@ -0,0 +1,95 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +/* Parse argument of the form 0-5,7,9-11,15,17 */ +bool parse_list(const char *arg, int max, int *list, int *count) +{ + char str[strlen(arg)+1]; + char *tok, *tmp, *saveptr = NULL; + int i; + + assert(max < INT_MAX); + + strcpy(str, arg); + + tmp = str; + while ((tok = strtok_r(tmp, ",", &saveptr)) != NULL) { + char *a, *b, *endptr, *saveptr2 = NULL; + unsigned long int from, to; + + a = strtok_r(tok, "-", &saveptr2); + if (a == NULL) { + return false; + } else { + endptr = NULL; + from = strtoul(a, &endptr, 0); + if (*endptr != '\0') { + fprintf(stderr, "Invalid value %s\n", a); + return false; + } + if (from >= max) { + fprintf(stderr, "Value %s larger than max %d\n", a, max-1); + return false; + } + } + + b = strtok_r(NULL, "-", &saveptr2); + if (b == NULL) { + to = from; + } else { + endptr = NULL; + to = strtoul(b, &endptr, 0); + if (*endptr != '\0') { + fprintf(stderr, "Invalid value %s\n", b); + return false; + } + if (to >= max) { + fprintf(stderr, "Value %s larger than max %d\n", b, max-1); + return false; + } + } + + if (from > to) { + fprintf(stderr, "Invalid range %s-%s\n", a, b); + return false; + } + + for (i = from; i <= to; i++) + list[i] = 1; + + tmp = NULL; + }; + + if (count != NULL) { + int n = 0; + + for (i = 0; i < max; i++) { + if (list[i] == 1) + n++; + } + + *count = n; + } + + return true; +} + diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..131e3f9 --- /dev/null +++ b/src/util.h @@ -0,0 +1,34 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __UTIL_H +#define __UTIL_H + +/** + * @brief Parse a range or a list of numbers from a string into an array + * + * For each number present in the string, set the corresponding list element + * to 1. The list acts as the index flags. The range of valid numbers varies + * from 0 to sizeof(list)-1. + * + * @param[in] arg String to parse + * @param[in] max The size of the list + * @param[in] list The list of flags + * @param[out] count Optional count of distinct numbers found + * @return true on success, false on error + */ +bool parse_list(const char *arg, int max, int *list, int *count); + +#endif From patchwork Tue Oct 2 06:04:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTNt3TkSz9sCw for ; Tue, 2 Oct 2018 16:13:34 +1000 (AEST) 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="ko1ffGqs"; 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 42PTNt19WYzF3FL for ; Tue, 2 Oct 2018 16:13:34 +1000 (AEST) 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="ko1ffGqs"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBc0ZP6zF3D0 for ; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) 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="ko1ffGqs"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBb4PX8z9sj1; Tue, 2 Oct 2018 16:04:39 +1000 (AEST) 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=1538460279; bh=AsIKxBA76/CxUTsithleZHfbEYjAaeXNMkBap4dfl9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ko1ffGqslvp0KYksIzIOAnWlXY2W8dxM27CLMwl9rl3WHp7ZnOKiwKfgQPdQ805cF LF80rsrC+4CSQsWAo07lUxUL4imCoOr+dg82aYmIg/4HyRNmwb9Bwn7tFDMOyWJcAB vMW2xBYBK00RM/qL9TsCJ8YL2PAwb/mAoTP9i+mKXffWn9bVRVBzSnj1DakGdyYH13 oPwk5wvAaJNZOdLvnIb4/cCCK8r1TDyZTo3ONB4ZXkPleDFt4asfLAs/0UpvbaHN1A 7cLJwrBCW5cd67sFT9XrMuzcb9NQO/NVVVwjHj5DDAd9wLf2kjtx+xg8KTBe6RYAoO UUWCcyWUVEXog== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:25 +1000 Message-Id: <20181002060430.3344784-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 04/10] path: Add device tree 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- Makefile.am | 2 + src/path.c | 383 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/path.h | 125 +++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 src/path.c create mode 100644 src/path.h diff --git a/Makefile.am b/Makefile.am index 8bf2ba0..653b7d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,6 +78,8 @@ pdbg_SOURCES = \ src/options.h \ src/parsers.c \ src/parsers.h \ + src/path.c \ + src/path.h \ src/progress.c \ src/progress.h \ src/reg.c \ diff --git a/src/path.c b/src/path.c new file mode 100644 index 0000000..66098bc --- /dev/null +++ b/src/path.c @@ -0,0 +1,383 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "path.h" +#include "util.h" + +#define MAX_PATH_COMP_LEN 32 +#define MAX_PATH_COMPONENTS 16 +#define MAX_PATH_LEN (MAX_PATH_COMP_LEN * MAX_PATH_COMPONENTS) + +/* This is max(MAX_PROCESSORS, MAX_CHIPS, MAX_THREADS) */ +#define MAX_PATH_INDEX 64 + +struct path_pattern { + char prefix[MAX_PATH_COMP_LEN]; + int index[MAX_PATH_INDEX]; + bool match_full; + bool match_index; +}; + +/* Start with max threads, rather than defining arbitrary number */ +#define MAX_TARGETS (64 * 24 * 8) + +static struct pdbg_target *path_target[MAX_TARGETS]; +static unsigned int path_target_count; + +static void safe_strcpy(char *dest, size_t n, const char *src) +{ + assert(strlen(src) + 1 <= n); + + strcpy(dest, src); +} + +static void safe_strcat(char *dest, size_t n, const char *src) +{ + assert(strlen(dest) + strlen(src) + 1 <= n); + + strcat(dest, src); +} + +/* + * Parse string components of following forms: + * pib0 + * core[1-3,11-13] + * thread* + * adu@123000 + */ +static bool path_pattern_parse(const char *arg, struct path_pattern *pat) +{ + char tmp[strlen(arg)+1]; + char *tok; + bool ok; + + safe_strcpy(tmp, sizeof(tmp), arg); + + memset(pat, 0, sizeof(*pat)); + + if (strchr(tmp, '@')) { + safe_strcpy(pat->prefix, sizeof(pat->prefix), tmp); + pat->match_full = true; + + } else if (strchr(tmp, '*')) { + tok = strtok(tmp, "*"); + if (!tok) + safe_strcpy(pat->prefix, sizeof(pat->prefix), "all"); + else + safe_strcpy(pat->prefix, sizeof(pat->prefix), tok); + + } else if (strchr(tmp, '[')) { + tok = strtok(tmp, "["); + if (tok == NULL) { + fprintf(stderr, "Invalid pattern '%s'\n", arg); + return false; + } + safe_strcpy(pat->prefix, sizeof(pat->prefix), tok); + + tok = strtok(NULL, "]"); + if (!tok) { + fprintf(stderr, "Invalid pattern '%s'\n", arg); + return false; + } + + ok = parse_list(tok, MAX_PATH_INDEX, pat->index, NULL); + if (!ok) + return false; + + pat->match_index = true; + + } else { + size_t n = strlen(tmp) - 1; + while (n >= 0 && isdigit(tmp[n])) + n--; + n++; + + if (n != strlen(tmp)) { + int index; + + index = atoi(&tmp[n]); + if (index < 0 || index >= MAX_PATH_INDEX) { + fprintf(stderr, "Invalid index '%s'\n", &tmp[n]); + return false; + } + tmp[n] = '\0'; + pat->index[index] = 1; + pat->match_index = true; + } + + safe_strcpy(pat->prefix, sizeof(pat->prefix), tmp); + } + + if (!pat->prefix) + return false; + + return true; +} + +static int path_pattern_split(const char *arg, struct path_pattern *pats) +{ + char arg_copy[MAX_PATH_LEN]; + char *tmp, *tok, *saveptr = NULL; + int n; + bool ok; + + safe_strcpy(arg_copy, sizeof(arg_copy), arg); + + tmp = arg_copy; + n = 0; + while ((tok = strtok_r(tmp, "/", &saveptr))) { + size_t len = strlen(tok); + + if (len == 0) + continue; + + if (len >= MAX_PATH_LEN) { + fprintf(stderr, "Pattern component '%s' too long\n", tok); + return -1; + } + + ok = path_pattern_parse(tok, &pats[n]); + if (!ok) + return -1; + + n++; + assert(n <= MAX_PATH_COMPONENTS); + + tmp = NULL; + } + + return n; +} + +static int path_target_find(struct pdbg_target *prev) +{ + int i; + + if (!prev) + return -1; + + for (i=0; i= 0) + return true; + + if (path_target_count == MAX_TARGETS) + return false; + + path_target[path_target_count] = target; + path_target_count++; + return true; +} + +static void path_pattern_match(struct pdbg_target *target, + struct path_pattern *pats, + int max_levels, + int level) +{ + struct pdbg_target *child; + char dn_name[MAX_PATH_COMP_LEN]; + char *tok; + int next = level; + bool found = false; + + if (target == pdbg_target_root()) { + goto end; + } + + if (!strcmp("all", pats[level].prefix)) { + if (!path_target_add(target)) + return; + goto end; + } + + safe_strcpy(dn_name, sizeof(dn_name), pdbg_target_dn_name(target)); + if (pats[level].match_full) { + tok = dn_name; + } else { + tok = strtok(dn_name, "@"); + } + + if (!strcmp(tok, pats[level].prefix)) { + found = true; + + if (pats[level].match_index) { + int index = pdbg_target_index(target); + + if (pats[level].index[index] != 1) + found = false; + } + } + + if (found) { + if (level == max_levels-1) { + path_target_add(target); + return; + } else { + next = level + 1; + } + } + +end: + pdbg_for_each_child_target(target, child) { + path_pattern_match(child, pats, max_levels, next); + } +} + +bool path_target_parse(const char **arg, int arg_count) +{ + struct path_pattern pats[MAX_PATH_COMPONENTS]; + int i, n; + + for (i=0; i 0); +} + +bool path_target_selected(struct pdbg_target *target) +{ + int index; + + index = path_target_find(target); + if (index >= 0) + return true; + + return false; +} + +static void path_target_build_path(struct pdbg_target *target, char *path, size_t len) +{ + char dn_name[MAX_PATH_LEN], *tok; + char number[16]; + int index; + + if (target != pdbg_target_root()) { + path_target_build_path(pdbg_target_parent(NULL, target), path, len); + index = pdbg_target_index(target); + if (index != -1) { + safe_strcpy(dn_name, sizeof(dn_name), pdbg_target_dn_name(target)); + tok = strtok(dn_name, "@"); + sprintf(number, "%d", index); + safe_strcat(path, len, "/"); + safe_strcat(path, len, tok); + safe_strcat(path, len, number); + } else { + safe_strcat(path, len, "/"); + safe_strcat(path, len, pdbg_target_dn_name(target)); + } + } else { + safe_strcpy(path, len, ""); + } +} + +char *path_target_path(struct pdbg_target *target) +{ + char path[MAX_PATH_LEN]; + + path_target_build_path(target, path, sizeof(path)); + return strdup(path); +} + +void path_target_dump(void) +{ + struct pdbg_target *target; + char *path; + + for_each_path_target(target, false) { + path = path_target_path(target); + assert(path); + printf("%s\n", path); + free(path); + } +} + +struct pdbg_target *path_target_next(struct pdbg_target *prev, + bool only_enabled) +{ + int index; + + index = path_target_find(prev); + return path_target_find_next(NULL, index, only_enabled); +} + +struct pdbg_target *path_target_next_class(const char *klass, + struct pdbg_target *prev, + bool only_enabled) +{ + int index; + + index = path_target_find(prev); + return path_target_find_next(klass, index, only_enabled); +} diff --git a/src/path.h b/src/path.h new file mode 100644 index 0000000..35c3a6e --- /dev/null +++ b/src/path.h @@ -0,0 +1,125 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __PDBG_PATH_H +#define __PDBG_PATH_H + +#include + +/** + * @brief Parse a list of path target strings + * + * @param[in] arg An array of strings + * @param[in] arg_count The number of strings + * @return true on success, false on error + */ +bool path_target_parse(const char **arg, int arg_count); + +/** + * @brief Check if there are any path targets + * + * @return true if number of path targets > 0, false otherwise + */ +bool path_target_present(void); + +/** + * @brief Add a target to the list + * + * @param[in] target pdbg target + * @return true on success, false on error + */ +bool path_target_add(struct pdbg_target *target); + +/** + * @brief Check if the specified target is selected + * + * @param[in] target pdbg target + * @return true if the target is selected, false otherwise + */ +bool path_target_selected(struct pdbg_target *target); + +/** + * @brief Get the device-tree path for a target + * + * @param[in] target pdbg target + * @return path for the target, NULL on error + * + * The path is allocated by malloc and should be freed by caller. + */ +char *path_target_path(struct pdbg_target *target); + +/** + * @brief Print the list of path targets to stdout + */ +void path_target_dump(void); + +/** + * @brief Iterator for list of path targets + * + * @param[in] prev The last pdbg target + * @param[in] only_enabled Whether to list enabled targets or all + * @return the next pdbg target in the list, NULL otherwise + * + * If prev is NULL, then return the first pdbg target in the list. + * If there are no more pdbg targets in the list, NULL is returned. + */ +struct pdbg_target *path_target_next(struct pdbg_target *prev, + bool only_enabled); + +/** + * @brief Iterator for a list of path targets of specified class + * + * @param[in] klass The class of the targets required + * @param[in] prev The last pdbg target + * @param[in] only_enabled Whether to list enabled targets or all + * @return the next matching pdbg target in the list, NULL otherwise + * + * If prev is NULL, then return the first matching pdbg target in the list. + * If there are no more matching pdbg targets, NULL is returned. + */ +struct pdbg_target *path_target_next_class(const char *klass, + struct pdbg_target *prev, + bool only_enabled); + +/** + * @brief Macro for iterating through all path targets + * + * target is of type struct pdbg_target + * only_eanbled is boolean + * + * If only_enabled is true, iterate through targets that are enabled; + * otherwise iterate through all targets + */ +#define for_each_path_target(target, only_enabled) \ + for (target = path_target_next(NULL, only_enabled); \ + target; \ + target = path_target_next(target, only_enabled)) + +/** + * @brief Macro for iterating through all path targets of specific class + * + * class is of type char * + * target is of type struct pdbg_target + * only_eanbled is boolean + * + * If only_enabled is true, iterate through targets that are enabled; + * otherwise iterate through all targets + */ +#define for_each_path_target_class(class, target, only_enabled) \ + for (target = path_target_next_class(class, NULL, only_enabled); \ + target; \ + target = path_target_next_class(class, target, only_enabled)) + +#endif From patchwork Tue Oct 2 06:04:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTNy0d4yz9sCw for ; Tue, 2 Oct 2018 16:13:38 +1000 (AEST) 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="Knycg4eG"; 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 42PTNx58RBzF3F0 for ; Tue, 2 Oct 2018 16:13:37 +1000 (AEST) 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="Knycg4eG"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBc2lsbzF38q for ; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) 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="Knycg4eG"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBb6y25z9s1c; Tue, 2 Oct 2018 16:04:39 +1000 (AEST) 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=1538460280; bh=xghMDKocTQRUg17J/5MN2FhnKwoZDG5fNLdTHj/K+lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Knycg4eGtR795jKV4inElh+EtgdYXNtk5uuzYB3qKho1/zcWcmiji7MgZyRd7x+wM AyFfD1J/ZXvzNYdYHGCAWOnyhuI8h0y144qRYCzbcsa0RUZcq0TSDAW3pVM4abJz8a SDFj9yuQmwR7qx8Fx9DC/g1656oA/CC4pVOINz3iSsa1d8MP3wLGwUSrjOxm/HIc71 WoBJmiqKjtJKS2kCUQv9JCnYNZEDpTPsqc14RYI/a3wtI/1SV0L2xupXq/6JT6iGU6 wgizyfr8Osp9eFZM9VQKpnKEYIPVcZ1Bkz9NWVQppMhZ5+TwupVLHiHK/u/J+F7khj TqIe4xodxtNTA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:26 +1000 Message-Id: <20181002060430.3344784-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 05/10] main: Add an option for path based targetting 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index f89ff6b..d57ce71 100644 --- a/src/main.c +++ b/src/main.c @@ -38,6 +38,7 @@ #include "optcmd.h" #include "progress.h" #include "util.h" +#include "path.h" #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) @@ -76,6 +77,11 @@ static int **processorsel[MAX_PROCESSORS]; static int *chipsel[MAX_PROCESSORS][MAX_CHIPS]; static int threadsel[MAX_PROCESSORS][MAX_CHIPS][MAX_THREADS]; +#define MAX_PATH_ARGS 16 + +static const char *pathsel[MAX_PATH_ARGS]; +static int pathsel_count; + static int probe(void); /* TODO: We are repeating ourselves here. A little bit more macro magic could @@ -150,6 +156,7 @@ static void print_usage(char *pname) #ifdef TARGET_PPC printf("\t-l, --cpu=<0-%d>||\n", MAX_PROCESSORS-1); #endif + printf("\t-P, --path=\n"); printf("\t-a, --all\n"); printf("\t\tRun command on all possible processors/chips/threads (default)\n"); printf("\t-b, --backend=backend\n"); @@ -240,6 +247,36 @@ void pir_map(int pir, int *chip, int *core, int *thread) {} #define PPC_OPTS #endif +static bool pathsel_add(char *format, ...) __attribute__((format (printf, 1, 2))); + +static bool pathsel_add(char *format, ...) +{ + va_list ap; + char path[1024]; + int len; + + va_start(ap, format); + + len = vsnprintf(path, sizeof(path), format, ap); + if (len > sizeof(path)) { + va_end(ap); + return false; + } + + va_end(ap); + + if (pathsel_count == MAX_PATH_ARGS) { + fprintf(stderr, "Too many path arguments\n"); + return false; + } + + pathsel[pathsel_count] = strdup(path); + assert(pathsel[pathsel_count]); + pathsel_count++; + + return true; +} + static bool parse_options(int argc, char *argv[]) { int c; @@ -263,6 +300,7 @@ static bool parse_options(int argc, char *argv[]) {"cpu", required_argument, NULL, 'l'}, #endif {"debug", required_argument, NULL, 'D'}, + {"path", required_argument, NULL, 'P'}, {"shutup", no_argument, NULL, 'S'}, {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0} @@ -275,7 +313,7 @@ static bool parse_options(int argc, char *argv[]) memset(l_list, 0, sizeof(l_list)); do { - c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:D:SV" PPC_OPTS, + c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:D:P:SV" PPC_OPTS, long_opts, NULL); if (c == -1) break; @@ -361,6 +399,11 @@ static bool parse_options(int argc, char *argv[]) fprintf(stderr, "Invalid slave address '%s'\n", optarg); break; + case 'P': + if (!pathsel_add(optarg)) + opt_error = true; + break; + case 'S': progress_shutup(); break; @@ -647,6 +690,11 @@ static bool target_selection(void) target_unselect(fsi); } + if (pathsel_count) { + if (!path_target_parse(pathsel, pathsel_count)) + return false; + } + return true; } From patchwork Tue Oct 2 06:04:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTP10DlMz9sCw for ; Tue, 2 Oct 2018 16:13:41 +1000 (AEST) 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="ZLGcLSpq"; 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 42PTP05MkmzF3Df for ; Tue, 2 Oct 2018 16:13:40 +1000 (AEST) 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="ZLGcLSpq"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBc5G5fzF3Bw for ; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) 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="ZLGcLSpq"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBc2Q6Xz9shx; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) 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=1538460280; bh=sVguDMudUbIBDfJG8rRs6RQG5EKxXNaLE+8LdcTSYhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLGcLSpq131N0Rxr63QY8FgWG5jDlcW+NaXeVwQrqLHqnIRamqOnxYCH1+Bd8mpG8 2vlCWI9bOxi0RrWg+TYCYPTFvEcjft4qv07kFPRsOaQ/WqfLfiRdoevsHAq5k0LWxU VJmRZAraXmZOLJqHzOG8UO+wBNq9aK7hVgZCwz1F/MYR5sO5XM9+Sigiwd2EV6m0UI Y9p9xbLW23O9e8iV/vcEThSblolzuBZeaPDZEhqQhLRRj9aAhzrVZVlLk6nrYRyNDQ xogCn+CM34zjmTcnX39e7IJBsI+q0o9peU4+9ASTaVt44DGUwOl53Felb4LS1jtjoz 8h/BwNg809eUg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:27 +1000 Message-Id: <20181002060430.3344784-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 06/10] main: Convert -p/-c/-t/-a/-l to path based targets 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 72 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/src/main.c b/src/main.c index d57ce71..38cd0ea 100644 --- a/src/main.c +++ b/src/main.c @@ -277,6 +277,26 @@ static bool pathsel_add(char *format, ...) return true; } +static bool list_to_string(int *list, int max, char *str, size_t len) +{ + char tmp[16]; + int i; + + memset(str, 0, len); + + for (i=0; i len) { + return false; + } + strcat(str, tmp); + } + } + + return true; +} + static bool parse_options(int argc, char *argv[]) { int c; @@ -286,7 +306,7 @@ static bool parse_options(int argc, char *argv[]) int t_list[MAX_THREADS]; int l_list[MAX_LINUX_CPUS]; int p_count = 0, c_count = 0, t_count = 0, l_count = 0; - int i, j, k; + int i; struct option long_opts[] = { {"all", no_argument, NULL, 'a'}, {"backend", required_argument, NULL, 'b'}, @@ -306,6 +326,7 @@ static bool parse_options(int argc, char *argv[]) {NULL, 0, NULL, 0} }; char *endptr; + char p_str[256], c_str[256], t_str[256]; memset(p_list, 0, sizeof(p_list)); memset(c_list, 0, sizeof(c_list)); @@ -434,6 +455,16 @@ static bool parse_options(int argc, char *argv[]) return false; } + if (pathsel_count > 0 && l_count > 0) { + fprintf(stderr, "Can't mix -l with -P\n"); + return false; + } + + if ((c_count > 0 || t_count > 0 || p_count > 0) && (pathsel_count > 0)) { + fprintf(stderr, "Can't mix -P with -p/-c/-t/-a\n"); + return false; + } + if ((c_count > 0 || t_count > 0) && p_count == 0) { fprintf(stderr, "No processor(s) selected\n"); fprintf(stderr, "Use -p or -a to select processor(s)\n"); @@ -446,25 +477,27 @@ static bool parse_options(int argc, char *argv[]) return false; } - for (i = 0; i < MAX_PROCESSORS; i++) { - if (p_list[i] == 0) - continue; - - processorsel[i] = &chipsel[i][0]; - - for (j = 0; j < MAX_CHIPS; j++) { - if (c_list[j] == 0) - continue; + if (p_count) + if (!list_to_string(p_list, MAX_PROCESSORS, p_str, sizeof(p_str))) + return false; - chipsel[i][j] = &threadsel[i][j][0]; + if (c_count) + if (!list_to_string(c_list, MAX_CHIPS, c_str, sizeof(c_str))) + return false; - for (k = 0; k < MAX_THREADS; k++) { - if (t_list[k] == 0) - continue; + if (t_count) + if (!list_to_string(t_list, MAX_THREADS, t_str, sizeof(t_str))) + return false; - threadsel[i][j][k] = 1; - } - } + if (t_count) { + if (!pathsel_add("pib[%s]/core[%s]/thread[%s]", p_str, c_str, t_str)) + return false; + } else if (c_count) { + if (!pathsel_add("pib[%s]/core[%s]", p_str, c_str)) + return false; + } else if (p_count) { + if (!pathsel_add("pib[%s]", p_str)) + return false; } if (l_count) { @@ -478,9 +511,8 @@ static bool parse_options(int argc, char *argv[]) pir_map(pir, &chip, &core, &thread); - processorsel[chip] = &chipsel[chip][0]; - chipsel[chip][core] = &threadsel[chip][core][0]; - threadsel[chip][core][thread] = 1; + if (!pathsel_add("pib%d/core%d/thread%d", chip, core, thread)) + return false; } } } From patchwork Tue Oct 2 06:04:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTP41W3Jz9sCw for ; Tue, 2 Oct 2018 16:13:44 +1000 (AEST) 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="Z7tv0AJx"; 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 42PTP36hFYzF3FW for ; Tue, 2 Oct 2018 16:13:43 +1000 (AEST) 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="Z7tv0AJx"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBd24PBzF3D0 for ; Tue, 2 Oct 2018 16:04:41 +1000 (AEST) 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="Z7tv0AJx"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBc54sjz9shy; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) 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=1538460280; bh=xZtJV6TQewEXatSTLxrxHiIgbKvmxH1UPOHin4G6CFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7tv0AJxlvt39VHWt2SbCesC9O+WxUAgJUrrV67bamvGLlxYEPcUxRK7T2LAtniS5 M3N0hhQVOk6GMenOPBK1YIrQW4bvn+q4A4GqqwHlPcKd2yShtyvXskOLiMyp3qbriH JrH4fBRm6YkakIwSE5HAy4JJvPhaM2i6Qh8IQJ70DIQIcvzy4KSoFfulXpJ/ZxzAPQ 1QdswsY7w1FoqxTHBpYJk+9AotJrAKXvNZtr4AtukMdHyF5dYr1Rxet1G99vJW466X ubB5yqI4ggD/h2nNGoX8o8W65J0XjnXz6NfZpw8LZSnWgVWMo7GOZ9jdg+AnT3ZTRv TwpRlG9tF/KPg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:28 +1000 Message-Id: <20181002060430.3344784-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 07/10] main: Switch to path based target selection 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Drop the old target selection code. Signed-off-by: Amitay Isaacs --- src/main.c | 82 +++++++----------------------------------------------- 1 file changed, 10 insertions(+), 72 deletions(-) diff --git a/src/main.c b/src/main.c index 38cd0ea..feb24fa 100644 --- a/src/main.c +++ b/src/main.c @@ -73,10 +73,6 @@ static int i2c_addr = 0x50; #define MAX_LINUX_CPUS (MAX_PROCESSORS * MAX_CHIPS * MAX_THREADS) -static int **processorsel[MAX_PROCESSORS]; -static int *chipsel[MAX_PROCESSORS][MAX_CHIPS]; -static int threadsel[MAX_PROCESSORS][MAX_CHIPS][MAX_THREADS]; - #define MAX_PATH_ARGS 16 static const char *pathsel[MAX_PATH_ARGS]; @@ -522,19 +518,12 @@ static bool parse_options(int argc, char *argv[]) void target_select(struct pdbg_target *target) { - /* We abuse the private data pointer atm to indicate the target is - * selected */ - pdbg_target_priv_set(target, (void *) 1); -} - -void target_unselect(struct pdbg_target *target) -{ - pdbg_target_priv_set(target, NULL); + path_target_add(target); } bool target_selected(struct pdbg_target *target) { - return (bool) pdbg_target_priv(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. */ @@ -600,10 +589,8 @@ void for_each_target_release(char *class) } } -static bool target_selection(void) +static bool target_selection(const char *prog) { - struct pdbg_target *fsi, *pib, *chip, *thread; - switch (backend) { #ifdef TARGET_ARM case I2C: @@ -670,63 +657,17 @@ static bool target_selection(void) return false; } - /* At this point we should have a device-tree loaded. We want - * to walk the tree and disabled nodes we don't care about - * prior to probing. */ - pdbg_for_each_class_target("pib", pib) { - int proc_index = pdbg_target_index(pib); - - if (backend == I2C && device_node) - pdbg_set_target_property(pib, "bus", device_node, strlen(device_node) + 1); - - if (processorsel[proc_index]) { - target_select(pib); - pdbg_for_each_target("core", pib, chip) { - int chip_index = pdbg_target_index(chip); - if (pdbg_parent_index(chip, "pib") != proc_index) - continue; - - if (chipsel[proc_index][chip_index]) { - target_select(chip); - pdbg_for_each_target("thread", chip, thread) { - int thread_index = pdbg_target_index(thread); - if (threadsel[proc_index][chip_index][thread_index]) - target_select(thread); - else - target_unselect(thread); - } - } else - target_unselect(chip); - } - - /* This is kinda broken as we're overloading what '-c' - * means - it's now up to each command to select targets - * based on core/chiplet. We really need a better - * solution to target selection. */ - pdbg_for_each_target("chiplet", pib, chip) { - int chip_index = pdbg_target_index(chip); - if (chipsel[proc_index][chip_index]) { - target_select(chip); - } else - target_unselect(chip); - } - } else - target_unselect(pib); - } - - pdbg_for_each_class_target("fsi", fsi) { - int index = pdbg_target_index(fsi); - if (processorsel[index]) - target_select(fsi); - else - target_unselect(fsi); - } - if (pathsel_count) { if (!path_target_parse(pathsel, pathsel_count)) return false; } + if (!path_target_present()) { + printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); + printf("Alternatively run '%s -a probe' to get a list of all valid targets\n", basename(prog)); + return false; + } + return true; } @@ -819,7 +760,7 @@ int main(int argc, char *argv[]) device_node = default_target(backend); /* Disable unselected targets */ - if (!target_selection()) + if (!target_selection(argv[0])) return 1; atexit(atexit_release); @@ -853,8 +794,5 @@ found_action: if (rc > 0) return 0; - printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); - printf("Alternatively run '%s -a probe' to get a list of all valid targets\n", - basename(argv[0])); return 1; } From patchwork Tue Oct 2 06:04:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTP72kVXz9sCw for ; Tue, 2 Oct 2018 16:13:47 +1000 (AEST) 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="KxS0hKBd"; 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 42PTP70dWdzF3FL for ; Tue, 2 Oct 2018 16:13:47 +1000 (AEST) 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="KxS0hKBd"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBd5xbVzF3DL for ; Tue, 2 Oct 2018 16:04:41 +1000 (AEST) 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="KxS0hKBd"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBd1l8Qz9shx; Tue, 2 Oct 2018 16:04:41 +1000 (AEST) 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=1538460281; bh=T7J+JcrwhHb093TdSn/OmRazNf90DF6tCNogRsxrst0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxS0hKBdu78VGuESiInWS8X7VaMDTvcOjRMqRg5B3d9NMqVvdODDLJTfoqW81QRB0 CZnaaXQAHw6ubimL4F2y1ZZ6DcDKAMfewTjliivX3vmjPLKshtNPAH3/tP5zKzTlEe i6FCk++Be835xbRRuo2De6T6JZTm/7RqaQYn9XhZ7IUyP9GsXJMhlGIIZGdGGRHBb7 MGgf/bOY3DbPFjtIznnQqj5RYkUOG0UOAAns9xFOm2z8Q3Zz+1dVsccum5cbkNTNcI vV/O8ULYQwCwcDh+DdkNZmY640T7a/J7Vul10JjqNi0fSEMLIBDekymUHc0GfY4Yff ACWiYBLZra6vg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:29 +1000 Message-Id: <20181002060430.3344784-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 08/10] main: Convert probe to use path style 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 15 ++++---------- tests/test_selection.sh | 43 +++-------------------------------------- 2 files changed, 7 insertions(+), 51 deletions(-) diff --git a/src/main.c b/src/main.c index feb24fa..95796b9 100644 --- a/src/main.c +++ b/src/main.c @@ -677,8 +677,6 @@ void print_target(struct pdbg_target *target, int level) struct pdbg_target *next; enum pdbg_target_status status; - pdbg_target_probe(target); - /* Does this target actually exist? */ status = pdbg_target_status(target); if (status != PDBG_TARGET_ENABLED) @@ -707,9 +705,6 @@ void print_target(struct pdbg_target *target, int level) } pdbg_for_each_child_target(target, next) { - if (!target_selected(next)) - continue; - print_target(next, level + 1); } } @@ -718,16 +713,14 @@ static int probe(void) { struct pdbg_target *target; - pdbg_for_each_class_target("pib", target) { - if (!target_selected(target)) - continue; + for_each_path_target(target, false) { + pdbg_target_probe(target); + } + pdbg_for_each_class_target("pib", target) { print_target(target, 0); } - printf("\nNote that only selected targets will be shown above. If none are shown\n" - "try adding '-a' to select all targets\n"); - return 1; } OPTCMD_DEFINE_CMD(probe, probe); diff --git a/tests/test_selection.sh b/tests/test_selection.sh index 2b23ec1..8909796 100755 --- a/tests/test_selection.sh +++ b/tests/test_selection.sh @@ -13,10 +13,9 @@ do_skip () fi } -test_result 0 < X-Patchwork-Id: 977653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTPD1s2Pz9sj0 for ; Tue, 2 Oct 2018 16:13:52 +1000 (AEST) 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="ZlNC6BMV"; 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 42PTPC6gpWzF3Ff for ; Tue, 2 Oct 2018 16:13:51 +1000 (AEST) 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="ZlNC6BMV"; 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBf2gTfzF3D0 for ; Tue, 2 Oct 2018 16:04:42 +1000 (AEST) 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="ZlNC6BMV"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBd5dG9z9s1c; Tue, 2 Oct 2018 16:04:41 +1000 (AEST) 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=1538460281; bh=bKhNhqpIhe4uRlAHb7Lvowql4ZsDKWlSxoOLXtztf3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZlNC6BMVLhbVBFtLYFCfNt+q8TQTgLheYZWJsi7JgDR71VbrzF9x5g6BvBakZy1lf vXm+TVn4zgIHikxRw1fJ+5YV32VrgGSBtmjsRXANfmzv5/kPUeTdIfqr7R1qfU3YAZ 4e0i1sISCrzhaWhLimjqdiyWZmL6DamPa7TJ/AVEqZP6oMs5yUB9Ejn5RXZedM5AMC 3tNDEySblyxdwCyFvStG0LxiBKZooH5sf5mTe3fDLFF5itq2JYc1L3rPyj0x6iduQC H5kz2XJ7L3M+wrJ9QhE21okdc2ZsW1OuDf2/YMY4YQLIDeUofx9/bt6yJ6mZs0xAyV 2yhLS0dE29UDg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:30 +1000 Message-Id: <20181002060430.3344784-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 09/10] tests: Add path based selection tests 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 1 + tests/test_selection2.sh | 537 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 538 insertions(+) create mode 100755 tests/test_selection2.sh diff --git a/Makefile.am b/Makefile.am index 653b7d9..5fa1083 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,7 @@ check_PROGRAMS = $(libpdbg_tests) optcmd_test PDBG_TESTS = \ tests/test_selection.sh \ + tests/test_selection2.sh \ tests/test_hw_bmc.sh TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS) diff --git a/tests/test_selection2.sh b/tests/test_selection2.sh new file mode 100755 index 0000000..96da2f8 --- /dev/null +++ b/tests/test_selection2.sh @@ -0,0 +1,537 @@ +#!/bin/sh + +. $(dirname "$0")/driver.sh + +test_group "path target selection tests" + +arch=$(arch 2>/dev/null) + +do_skip () +{ + if [ "$arch" != "x86_64" ] ; then + test_skip + fi +} + +test_result 0 <