From patchwork Fri Nov 23 04:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1002111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 431Nsq2V2Tz9s1c for ; Fri, 23 Nov 2018 15:40:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 431Nsq0SDfzDqT1 for ; Fri, 23 Nov 2018 15:40:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 431NsM66QdzDqRk for ; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KjqwSMSN"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 431NsM3JD6z9s1c; Fri, 23 Nov 2018 15:40:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542948023; bh=CVAg/EFkbk4AUyA0mYf72rOjVgDAhy/7a6wh8G9aPMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjqwSMSNoNlevfmAueCr4HGMpY/pLlbi07WfV2IshSJrEsMDWTSYQ8Uruy+7h3nCy ryziso2QFpsn59E8KFA9qLfQbGm0OnaQPujOERkClY4gt40EO4MYC/TwnyOvqiZjRb JwEWJ88inpS/Yp2SeNkvhcWIrnbhbNXOCGycROCpv4emxqSWkBy8ovCn72syTFBJrq fG4z/QvTmeao+njLDRR1wdgzmJhS/lIXM4R0l2I/E5B+qLsGgUestiwqORFSW2+omz kg3WKkpATGt09cY5+6YrAN1zgCUp+bO9FEAkGkbpx6+5qniwrNZYHxgusgWZFLKaC+ EuUgLgD8cT8cA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 23 Nov 2018 15:40:13 +1100 Message-Id: <20181123044019.633814-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123044019.633814-1-amitay@ozlabs.org> References: <20181123044019.633814-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 04/10] main: Convert thread commands start/stop/step/sreset X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/thread.c | 75 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/src/thread.c b/src/thread.c index 4401384..97becc4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -22,6 +22,7 @@ #include "main.h" #include "optcmd.h" +#include "path.h" static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *valid) { @@ -240,26 +241,6 @@ static int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t ind return for_each_child_target("core", pib_target, print_core_thread_status, &maxindex, NULL); }; -static int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_start_thread(thread_target) ? 0 : 1; -} - -static int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1) -{ - return ram_step_thread(thread_target, *count) ? 0 : 1; -} - -static int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_stop_thread(thread_target) ? 0 : 1; -} - -static int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1) -{ - return ram_sreset_thread(thread_target) ? 0 : 1; -} - static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *i_doBacktrace, uint64_t *unused) { struct thread_regs regs; @@ -276,19 +257,52 @@ static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint6 static int thread_start(void) { - return for_each_target("thread", start_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_start_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(start, thread_start); -static int thread_step(uint64_t count) +static int thread_step(uint64_t steps) { - return for_each_target("thread", step_thread, &count, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_step_thread(target, (int)steps); + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(step, thread_step, (DATA)); static int thread_stop(void) { - return for_each_target("thread", stop_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_stop_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(stop, thread_stop); @@ -300,7 +314,18 @@ OPTCMD_DEFINE_CMD(threadstatus, thread_status_print); static int thread_sreset(void) { - return for_each_target("thread", sreset_thread, NULL, NULL); + struct pdbg_target *target; + int count = 0; + + for_each_path_target_class("thread", target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + ram_sreset_thread(target); + count++; + } + + return count; } OPTCMD_DEFINE_CMD(sreset, thread_sreset);