From patchwork Thu Aug 2 04:35:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 952576 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gy5g4hpfz9rxx for ; Thu, 2 Aug 2018 14:35:19 +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="fBKzZGkX"; 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 41gy5g2bZCzF1Rs for ; Thu, 2 Aug 2018 14:35:19 +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="fBKzZGkX"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (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 41gy5W0nPWzF1Qn for ; Thu, 2 Aug 2018 14:35:11 +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="fBKzZGkX"; 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 41gy5V54pHz9s2g; Thu, 2 Aug 2018 14:35:10 +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=1533184510; bh=GRY9t3JXQYlUgtvEGX7g+FCzsaIzG+NqtVHJPeKmXDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBKzZGkXAXsedoKjA0AYzHYP8J2okRO5yFlfp88NVTgjx8vAD3kUREMWSUzTGvqVa yrMlCzphE9Im88OihJ8WWi0QtAveoDzkk2284gjBJhWkQuQMuqRAym/5fUO8kZJPPL nTZi02FAglIrlo3qyAcIMliu+/V9ZBNYM2hw2tV6IduZhhblAN1+aZXEiBViP5y+g3 o4nY5Nu7SEJEfkA0YJNk/bn+no0j/54VEWuibhCanTrWFHhL62xCB6J26Zu9Y4kghi ly82XQbxY0YDk7qOX16c8HkOuwzfUawUcf2QCyrawMgy0qxeFksduNN1vkReFxF1tE tMPdM7TLqeCyA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Aug 2018 14:35:04 +1000 Message-Id: <20180802043507.28734-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802043507.28734-1-amitay@ozlabs.org> References: <20180802043507.28734-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 1/4] progress: End function on a new line X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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/progress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/progress.c b/src/progress.c index fe443b9..9772374 100644 --- a/src/progress.c +++ b/src/progress.c @@ -42,7 +42,8 @@ void progress_init(void) fprintf(stderr, " "); fprintf(stderr, "] 0%%"); fflush(stderr); - clock_gettime(CLOCK_MONOTONIC, &progress_start);} + clock_gettime(CLOCK_MONOTONIC, &progress_start); +} void progress_tick(uint64_t cur, uint64_t end) { From patchwork Thu Aug 2 04:35:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 952577 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gy5n1B2Wz9rxx for ; Thu, 2 Aug 2018 14:35:25 +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="G7bYSqT/"; 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 41gy5l1NDqzF1Qn for ; Thu, 2 Aug 2018 14:35:23 +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="G7bYSqT/"; 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 41gy5W2ykHzF1R6 for ; Thu, 2 Aug 2018 14:35:11 +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="G7bYSqT/"; 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 41gy5W01cLz9s3x; Thu, 2 Aug 2018 14:35:10 +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=1533184511; bh=YC5NmQ+ZrLocy8sWPgD2AqShf+0S9M2agc3gwZ/izec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G7bYSqT/wzGNsHqjxJKd96TAabsO93lqIDvCsC/ESoj6pBW7b5Mz02Q72rOg4Ts9P OEKsYPxBzZaiUuJrX2AaOxo+XszFb/ogK+7JNtHpUzC5G5jHTzWGXBF10+VYGPCnxw 26n49iF10nsQu+WAyfwPDFngPgZ7Iun0lHE6dHJ+7BSdJGzetnlrgsYDPgvGlduDZN /+6DnR4KtWd+9LEWx/DUGb3xxCH4PMze4uoIeg0bBTo0y8UaV1R7mHf6z3JMoBC8Lb 1TUjIpi7g4UkE9rBMOayxnrgbJ2y30Nvx277atWqIKOiHMEYXkiW+HeljHl+G7QysD wpt5q4TqwFelw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Aug 2018 14:35:05 +1000 Message-Id: <20180802043507.28734-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802043507.28734-1-amitay@ozlabs.org> References: <20180802043507.28734-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 2/4] progress: Refactor progress_bar to print progress bars X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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/progress.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/progress.c b/src/progress.c index 9772374..8aef486 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,43 +29,46 @@ static struct timespec progress_start; #define PROGRESS_CHARS 50 -void progress_init(void) +static void progress_bar(unsigned int percent) { - unsigned int i; + unsigned int i, progress; - progress_pcent = 0; - progress_n_upd = ULONG_MAX; - progress_prevsec = ULONG_MAX; + progress = (percent * PROGRESS_CHARS) / 101; fprintf(stderr, "\r["); - for (i = 0; i < PROGRESS_CHARS; i++) + for (i = 0; i <= progress; i++) + fprintf(stderr, "="); + for (; i < PROGRESS_CHARS; i++) fprintf(stderr, " "); - fprintf(stderr, "] 0%%"); + fprintf(stderr, "] %u%%", percent); fflush(stderr); +} + +void progress_init(void) +{ + progress_pcent = 0; + progress_n_upd = ULONG_MAX; + progress_prevsec = ULONG_MAX; + + progress_bar(0); + clock_gettime(CLOCK_MONOTONIC, &progress_start); } void progress_tick(uint64_t cur, uint64_t end) { - unsigned int i, pos; struct timespec now; - uint64_t pcent; + unsigned int pcent; double sec; - pcent = (cur * 100) / end; + pcent = (unsigned int)((cur * 100) / end); if (progress_pcent == pcent && cur < progress_n_upd && cur < end) return; progress_pcent = pcent; - pos = (pcent * PROGRESS_CHARS) / 101; clock_gettime(CLOCK_MONOTONIC, &now); - fprintf(stderr, "\r["); - for (i = 0; i <= pos; i++) - fprintf(stderr, "="); - for (; i < PROGRESS_CHARS; i++) - fprintf(stderr, " "); - fprintf(stderr, "] %" PRIu64 "%%", pcent); + progress_bar(pcent); sec = difftime(now.tv_sec, progress_start.tv_sec); if (sec >= 5 && pcent > 0) { From patchwork Thu Aug 2 04:35:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 952578 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gy5r03VDz9s2g for ; Thu, 2 Aug 2018 14:35:28 +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="P/+E48/k"; 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 41gy5q4gxNzF1R6 for ; Thu, 2 Aug 2018 14:35:27 +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="P/+E48/k"; 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 41gy5W50mfzF0pD for ; Thu, 2 Aug 2018 14:35:11 +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="P/+E48/k"; 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 41gy5W2Rkqz9s5K; Thu, 2 Aug 2018 14:35:11 +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=1533184511; bh=LDC7K/v1tstaQJKAFqRn/y1u+2L90CHGxXHV61oQr0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/+E48/kUZiTw1sEALiekvnFQGsxb/6y+H4mfOExQWqBF52haUGvu/Pk4oMcWGhNt HoiB2fsL8L3lvSlv7z/xwyO9ka6a4KAyqnMEuZSqkDYr3WlPwtSQLz1W93qGDbsJbo RhqQCoDHBiumP7ncwn7z+FM11t0dqnMG6ECGrNVpJGSWqGsvt2zwiAXgauvDZCz/8v +QsguuPyMNtjo5HiuM2Kb3p2vI3rKh316tMiq2EmQ/1X7Qva0f+8Mx+/n7Caierm3H josUR8B162Ev+XWXOp8LZi14fPjB/2gMCE/x5/jYrP9j6cTk1Op/lUjLDebKw4ApJ1 9CS4x/gH+5JIg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Aug 2018 14:35:06 +1000 Message-Id: <20180802043507.28734-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802043507.28734-1-amitay@ozlabs.org> References: <20180802043507.28734-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 3/4] progress: Add assert to avoid programming errors X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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/progress.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/progress.c b/src/progress.c index 8aef486..648596d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "progress.h" @@ -33,6 +34,8 @@ static void progress_bar(unsigned int percent) { unsigned int i, progress; + assert(percent <= 100); + progress = (percent * PROGRESS_CHARS) / 101; fprintf(stderr, "\r["); From patchwork Thu Aug 2 04:35:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 952579 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 ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gy5w39y4z9s2g for ; Thu, 2 Aug 2018 14:35:32 +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="FbksvW/o"; 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 41gy5w0wh4zF1dK for ; Thu, 2 Aug 2018 14:35:32 +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="FbksvW/o"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (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 41gy5X09JfzF1Qn for ; Thu, 2 Aug 2018 14:35:12 +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="FbksvW/o"; 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 41gy5W4mCLz9rxx; Thu, 2 Aug 2018 14:35:11 +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=1533184511; bh=EPRYic/UoqMU8I6cf9opj1yegNCsaBkFOM7wo/Dgt1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FbksvW/obj7wLCAlsKbSq1eB6qszh4LxnQ6OjYD7O6wA5wwc7Z9ML7Zv2e2RcUCWE W0GXcr4hmFaXsRQXptCjSRDNCz9HNv5/HwWPEzZ3jTj1j+RnLDV+DqGy1dYOaC9RJh E8Un9YHwFw50cY80UsOOtdAaO3RApR5ixQWFmKDNGvae8d2r7bTm3Uyy1ZkpzXjHqI Bw/dZieIKijxB2brtq3LtLRMkI6dIIUxykXoFm2mBPGpUIk1Xm9phN7eff8I4w4kST IbLmEUTB9qnVR2H+p/8tIxF/tZTp4Ig++DmK7EMA/tb887ghKGV7N1BuO52Mg0jurS 12yvdeEU/13EA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Aug 2018 14:35:07 +1000 Message-Id: <20180802043507.28734-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802043507.28734-1-amitay@ozlabs.org> References: <20180802043507.28734-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 4/4] mem: Avoid floating point exception if size == 0 X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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/mem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mem.c b/src/mem.c index 4b2c829..ce099c2 100644 --- a/src/mem.c +++ b/src/mem.c @@ -46,6 +46,11 @@ static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags) uint8_t *buf; int rc = 0; + if (size == 0) { + PR_ERROR("Size must be > 0\n"); + return 1; + } + buf = malloc(size); assert(buf); pdbg_for_each_class_target("adu", target) {