| Message ID | 20260928181855.3217561-1-simon.marchi@polymtl.ca |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4ADF4BAE7CE for <patchwork@sourceware.org>; Mon, 28 Sep 2026 18:19:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4ADF4BAE7CE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=EaKx9v+3 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 214E84B9DB63 for <gdb-patches@sourceware.org>; Mon, 28 Sep 2026 18:19:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 214E84B9DB63 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 214E84B9DB63 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790619545; cv=none; b=HAY3j0iK0TyyUc8Azeg6cGYMj6iJcbfMFHraLGwebL8T2kKCW0EXBRN1yxRkMNuWRY9QybvtbfrOBDxzF3bVUwWpKFGKW6PzdcmGgt3OGmUBfJR/UC/ziXLzKse++4ndVtdLPuO27Ue6kHeJhxkN8xJ26H6A0jEmwqsk9ZzaB3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790619545; c=relaxed/simple; bh=TlVrx78syYpfsumtlXf49Km/BGGvTD5Hbe27TPIOu70=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=leLZTXrwkgEI0It2NfawCrcKOypdLRuZy6jcIqc1hTm2A+Qihwq2PaUxYRiD8S2iNhZRym3qb1MWY5ndirK/Rdi9LURn3NtLmjoFGXFHiTUqBl+/+ZEzbOMEGU2DmrhQQwI5dGY3NipRgj2gTWMptuYoKMMjF4OX2gmBc9mYBEo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=EaKx9v+3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 214E84B9DB63 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 68SIIup9139250 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Sep 2026 14:19:01 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 68SIIup9139250 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1790619542; bh=sV9B4LR0npJcGg75sgXK2aWCCqe8m5qOWu8wkUFPL9c=; h=From:To:Cc:Subject:Date:From; b=EaKx9v+35HprrwXWmH/Jtd+e66XSl4neH+ShhQSEebEySQZ/uZXvP1OJJCCYoXhaF 653Vfhu/xEZJUvhhYTNF2YnJbjl7rM9MSbIuaEp+B3hWtKbUC6BOIdDDhazDtNTyfR 0Q43BnXfhQEItKYYayuft5Xr9yT52CR4hRo6QL9+J8LZxMgdyhrNNdi12I3hB3gtna ZbMtJ3PyyzOe2FyIyiXpxYkP+Ndfrjgva5tCL3gedBNwy1xzKPkykBrqHQZRzDFMO8 k1rxrI+G5oKUFdcna1wZ921r9cwgB4WkW+68D8pkenSZWNuEHpw1d1z3sGUWAvcbDg 17uadeUNcB7BQ== Received: by simark.ca (Postfix) id 54BCE1E01F; Mon, 28 Sep 2026 14:18:56 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@efficios.com> Subject: [PATCH] gdb: fix nan in scoped_time_it output Date: Mon, 28 Sep 2026 14:18:48 -0400 Message-ID: <20260928181855.3217561-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 28 Sep 2026 18:18:56 +0000 X-Spam-Status: No, score=-3034.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
gdb: fix nan in scoped_time_it output
|
|
Checks
| Context | Check | Description |
|---|---|---|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Build passed |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm | fail | Patch failed to apply |
Commit Message
Simon Marchi
Sept. 28, 2026, 6:18 p.m. UTC
From: Simon Marchi <simon.marchi@efficios.com>
With "maintenance set per-command time on", a scope that takes less
than a millisecond prints:
Time for "...": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, -nan % CPU
The durations are converted to an integer millisecond count before the
CPU usage is computed, so a sub-millisecond scope truncates the wall
time to zero, and the division produces a NaN (or an infinity, if the
CPU time is not zero). We don't really care about sub-millisecond
durations for the purpose of this tool, so just add a check for
`wall_ms == 0`, and report the CPU usage as 0% if true. This is purely
cosmetic.
Change-Id: Iaf682bef4b537d6dbb58e82f7727c0ea079088aa
---
gdb/maint.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
base-commit: 421bec796fa3a06179856da870a13cf71ddf5df2
Comments
simon.marchi@polymtl.ca writes: > From: Simon Marchi <simon.marchi@efficios.com> > > With "maintenance set per-command time on", a scope that takes less > than a millisecond prints: > > Time for "...": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, -nan % CPU > > The durations are converted to an integer millisecond count before the > CPU usage is computed, so a sub-millisecond scope truncates the wall > time to zero, and the division produces a NaN (or an infinity, if the > CPU time is not zero). We don't really care about sub-millisecond > durations for the purpose of this tool, so just add a check for > `wall_ms == 0`, and report the CPU usage as 0% if true. This is purely > cosmetic. LGTM. Approved-By: Andrew Burgess <aburgess@redhat.com> Thanks, Andrew > > Change-Id: Iaf682bef4b537d6dbb58e82f7727c0ea079088aa > --- > gdb/maint.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gdb/maint.c b/gdb/maint.c > index 8027429e6d39..22954f624efe 100644 > --- a/gdb/maint.c > +++ b/gdb/maint.c > @@ -1230,7 +1230,8 @@ scoped_time_it::~scoped_time_it () > "user+sys %.03f, %.01f %% CPU\n", > m_what, wall_ms / 1000.0, user_ms / 1000.0, > sys_ms / 1000.0, user_plus_sys_ms / 1000.0, > - user_plus_sys_ms * 100.0 / wall_ms); > + (wall_ms == 0 > + ? 0.0 : user_plus_sys_ms * 100.0 / wall_ms)); > gdb_stdlog->write_async_safe (str.data (), str.size ()); > } > > > base-commit: 421bec796fa3a06179856da870a13cf71ddf5df2 > -- > 2.55.0
On 2026-09-28 17:59, Andrew Burgess wrote: > simon.marchi@polymtl.ca writes: > >> From: Simon Marchi <simon.marchi@efficios.com> >> >> With "maintenance set per-command time on", a scope that takes less >> than a millisecond prints: >> >> Time for "...": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, -nan % CPU >> >> The durations are converted to an integer millisecond count before the >> CPU usage is computed, so a sub-millisecond scope truncates the wall >> time to zero, and the division produces a NaN (or an infinity, if the >> CPU time is not zero). We don't really care about sub-millisecond >> durations for the purpose of this tool, so just add a check for >> `wall_ms == 0`, and report the CPU usage as 0% if true. This is purely >> cosmetic. > > LGTM. > > Approved-By: Andrew Burgess <aburgess@redhat.com> Thanks, pushed. Simon
diff --git a/gdb/maint.c b/gdb/maint.c index 8027429e6d39..22954f624efe 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1230,7 +1230,8 @@ scoped_time_it::~scoped_time_it () "user+sys %.03f, %.01f %% CPU\n", m_what, wall_ms / 1000.0, user_ms / 1000.0, sys_ms / 1000.0, user_plus_sys_ms / 1000.0, - user_plus_sys_ms * 100.0 / wall_ms); + (wall_ms == 0 + ? 0.0 : user_plus_sys_ms * 100.0 / wall_ms)); gdb_stdlog->write_async_safe (str.data (), str.size ()); }