From patchwork Wed Apr 10 08:01:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1083238 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) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44fGrN1Ytzz9s9h for ; Wed, 10 Apr 2019 18:03:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (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="VnhPzDWe"; 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 44fGrM661gzDqMb for ; Wed, 10 Apr 2019 18:03:47 +1000 (AEST) 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) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44fGpC68WKzDqNg for ; Wed, 10 Apr 2019 18:01:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (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="VnhPzDWe"; 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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 44fGpC3QMBz9sB3; Wed, 10 Apr 2019 18:01:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1554883315; bh=tmORS0Sw2bOK9G2i6TADPWULHU7FKdSrnYytppnWxtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VnhPzDWedPR2PXscGY9MSj+AfR24HR+DLufJjFz2pJ8NGQxNE4AE0QA5cnavR7BWI NeUaxtF784Ey0lz+5H4NopL9HyFiulaSa10ImYqh0Q3FgCN3s3GjYr+ZI/K+DkjDSN /ZxgzBG1YtDodMWkavZsW3VLQ9ZE5UCHC2ydTAabaStVvLdMFQtquUROn/dlU+1N+T BPSL+FToKpuxuhSgN8/n313475e5j1SL6WiyoiMteGEqpBcQabgpetLCP89hI7/mwP 2/V/mTnUxJawyFetUHLejwk3KJLG3WQKzWmRbyOT+t8d3EG34W6VZuguFAO429iMxA rDZ3F8VyiWC4w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Wed, 10 Apr 2019 18:01:49 +1000 Message-Id: <20190410080151.429876-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410080151.429876-1-amitay@ozlabs.org> References: <20190410080151.429876-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 3/5] mem: Dump memory only if mem_read was successful X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If mem_read() fails, try again with any other adu targets. Since we need to dump memory only once, move dumping of memory outside the loop. Signed-off-by: Amitay Isaacs --- src/mem.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/mem.c b/src/mem.c index 408ff11..8045069 100644 --- a/src/mem.c +++ b/src/mem.c @@ -45,7 +45,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci) { struct pdbg_target *target; uint8_t *buf; - int rc = 0; + int count = 0; if (size == 0) { PR_ERROR("Size must be > 0\n"); @@ -54,27 +54,33 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci) buf = malloc(size); assert(buf); + pdbg_for_each_class_target("adu", target) { + int rc; + if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; pdbg_set_progress_tick(progress_tick); progress_init(); rc = mem_read(target, addr, buf, size, block_size, ci); - if (rc) + progress_end(); + if (rc) { PR_ERROR("Unable to read memory.\n"); + continue; + } + count++; + break; + } + + if (count > 0) { if (write(STDOUT_FILENO, buf, size) < 0) PR_ERROR("Unable to write stdout.\n"); - else - rc++; - - progress_end(); - break; } - free(buf); - return rc; + free(buf); + return count; } static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags)