From patchwork Fri Jun 26 11:33:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 137870 Return-Path: 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 8E4E44BA799B for ; Fri, 26 Jun 2026 11:41:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E4E44BA799B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=RtG7rd8A X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id BD0AB4BA7993 for ; Fri, 26 Jun 2026 11:38:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD0AB4BA7993 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD0AB4BA7993 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782473934; cv=none; b=rIucjA42Q2W8OAUV2cbWaJUoWI/UXAkzXK9y4wzwM8CdhXIsg5YSv4RMn0w8+4N+8Vfmn9Qejli8R//F1NEep6lMh2v2XAY2BBZQZqXW1mOye+HN58IXP7mr7xlS2cwuPiAV7ay10sKsV5DC4aBZ2SadhYFHyGsPEcz6eb8w+uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782473934; c=relaxed/simple; bh=VmcUKwCwkORaDHjDMxoid4KqwlkaDyJEOHOiP0lWb64=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=n5Z+azYg1dZuMbHdRE2byX+zo++bPS2UI4/OzgFeNYXmwq13AnmoWeH9VSMVjKBRw04GRw5Txfg4gqL8z1hPQMyf73gxF3qf17H2Bp2aePLlN6nrBESjSz2OxNHEx1ZwLwOkVjEKNwpQvYs1AZ2nvBiNO5TFFYbizZgfVTkqKSQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=RtG7rd8A DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD0AB4BA7993 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-49258ac7294so5787765e9.0 for ; Fri, 26 Jun 2026 04:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782473934; x=1783078734; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U7ARGTKDVpVOqLyF/0GjJPVgAhqQdOY4tR0YXTLEnQ4=; b=RtG7rd8AN/PSn4MyL8Vn2UV7fFoozdMEE/xJnQaooZApzQ1yz+nlmP10INnOS8Tdfx Bq91nG/A8ivcoAzhptyuHP8KHp4tbOEAxOCvnGb8qQRTA16eXB1juC2rhfSKpFnNbuoR YWhwe8kAWDfBXBg9CHNNReLPvlqHPbgEC61e/1mFs/JbAHV4c+61Pswily+KRL/+f/Tg KRrOkInw7Suh/zYFBU+MYFhNIrUA9JVSq28Z+gPaoWqP4BIL8R6SWryAMdcTutKdhZK+ +h9VfVJ84GxYlRMPEKLsSSx6MPWR8sEQ5/KPRPP1lWu0uJW5VACzrwxavpJfUdbVo/Ct pq3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782473934; x=1783078734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=U7ARGTKDVpVOqLyF/0GjJPVgAhqQdOY4tR0YXTLEnQ4=; b=WjXTBSxxceRX0eYnG34+F2ki9iCoRCvP0AEKM0kAN707I7NaFeghDssjZykOLPIJP6 3XneLH+UGe7gEkCF/hjoNf1ClFQQqQH7Drcn8DB276zRMXow61lq/vxL2aLLw/KWxUx7 hoqPoYSkF7CFrCUa80bag9fP5YBatm8L5nJ6XDC9GLya5y1MukbHeFe25oMvZb7DvKmG ZSDU+9AtS9YAIbaA6/ca9kDZ8ihq4DllemFG2hp4gsbtV9uWS0RfmLDxNxGtT1jr/jdF Wuh4A9NQ9iC+nzkyB3QDsINqr+ClDE9y/BVTln7nSFw4ex1UPywGSFua5W5DtpGIKDJE Zokg== X-Gm-Message-State: AOJu0YzDWkLCsaVEPMqBulS/i8gpfYg3/WgaoM6lvoACt2YHDu/IkNj9 2jvvCTjezxsYrwozJLcsYR5ui7O+//h4F1Bu16fyIiNP8jocCXYW38DjqQvy4L0P X-Gm-Gg: AfdE7ck0do8FosT7jSeiNzu82DUFScyBzXydfY67hpw9sPQNMzR3WEvyRm9CZmk3rXb i2mCvT+QIfBnCU22zpVN3wbHz2ZMjURPOOBH5NmJiBzwfQ9DFeRdx/xIsrPnXy4Xwm1S7UgSRPh wWRs2J6UPBvbmUNpCx2gR1Ej2uQR/sGdVBGUIkeJkAWzFmMmX9Z84lb9iUk19gWSdtRYuQi3D/i XCdbJLaPYH0rHlcE5MsyKtfoG6g5zcDfR7laSO4HqBlet8E7Jk2Dw35oaY7SpCn0tC1mG30s4CL csIZuXCp5eLVMH1h5Efe35wtg/K1ji9dakzClad99gRjw48uS++TnMr5b6KY6SsDl1PODNJS614 mIOJ2nTtAxqwWbie58nH/GiB6DtXVUWdOT+u1n5EibGIal7+x3GHaHoCnjosgja8gQ1CL6AE78N DP X-Received: by 2002:a05:600c:e54a:20b0:492:28be:6098 with SMTP id 5b1f17b1804b1-49266864257mr65340065e9.11.1782473933337; Fri, 26 Jun 2026 04:38:53 -0700 (PDT) Received: from fedora ([5.12.139.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690a1a85sm124466935e9.15.2026.06.26.04.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 04:38:53 -0700 (PDT) From: Claudiu Zissulescu To: binutils@sourceware.org Cc: jemarch@gnu.org, simone_maione@yahoo.com Subject: [PATCH 3/4] gprofng: testsuite coverage for HW-counter precision markings Date: Fri, 26 Jun 2026 14:33:21 +0300 Message-ID: <20260626113840.44715-4-claziss@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626113840.44715-1-claziss@gmail.com> References: <20260626113840.44715-1-claziss@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Add two DejaGnu tests that pin the user-facing output added by the previous two commits. hwc_listing.exp verifies that "gprofng collect app -h" groups counters into "Precise events" and "Standard events" sections, and that precise counters carry the "memoryspace (precise)" type tag. hwc_precision_marker.exp records an HW-counter experiment with the default counter set, runs "display text", and asserts that the column header marker "(*)" and the explanatory footnote. A marker without a footnote, or vice versa, is a regression. gprofng/ * testsuite/gprofng.display/hwc_listing.exp: New test. * testsuite/gprofng.display/hwc_precision_marker.exp: New test. --- .../testsuite/gprofng.display/hwc_listing.exp | 60 ++++++++++++++++ .../gprofng.display/hwc_precision_marker.exp | 72 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 gprofng/testsuite/gprofng.display/hwc_listing.exp create mode 100644 gprofng/testsuite/gprofng.display/hwc_precision_marker.exp diff --git a/gprofng/testsuite/gprofng.display/hwc_listing.exp b/gprofng/testsuite/gprofng.display/hwc_listing.exp new file mode 100644 index 00000000000..c70b7ea8695 --- /dev/null +++ b/gprofng/testsuite/gprofng.display/hwc_listing.exp @@ -0,0 +1,60 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# Verify that "gprofng collect app -h" groups the available HW counters +# into a "Precise events" section and a "Standard events" section, and +# tags precise counters as "memoryspace (precise)" in the type column. +# This pins the user-facing output added to gprofng/common/hwctable.c +# so a future refactor cannot silently drop the section split. + +set gprofng $::env(GPROFNG) +set testname "hwc_listing" + +set output [run_native_host_cmd "$gprofng collect app -h"] +set out [lindex $output 1] + +if { [string first "not supported on this system" $out] >= 0 } then { + unsupported $testname + return +} + +# Standard events block is always emitted when any counter is listed. +if { [string first "Standard events" $out] < 0 } then { + send_log "missing 'Standard events' section in -h output:\n$out\n" + fail $testname + return +} + +# If any precise counters are present (type column shows "memoryspace"), +# the "(precise)" tag and the "Precise events" heading must both appear. +if { [string first "memoryspace" $out] >= 0 } then { + if { [string first "memoryspace (precise)" $out] < 0 } then { + send_log "'memoryspace' type without '(precise)' tag:\n$out\n" + fail $testname + return + } + if { [string first "Precise events" $out] < 0 } then { + send_log "missing 'Precise events' heading despite memoryspace counters:\n$out\n" + fail $testname + return + } +} + +pass $testname diff --git a/gprofng/testsuite/gprofng.display/hwc_precision_marker.exp b/gprofng/testsuite/gprofng.display/hwc_precision_marker.exp new file mode 100644 index 00000000000..0d38b7b3f83 --- /dev/null +++ b/gprofng/testsuite/gprofng.display/hwc_precision_marker.exp @@ -0,0 +1,72 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# Verify that "display text" on an HW-counter experiment marks +# non-precise counter columns with " (*)" and emits the explanatory +# footnote. This pins the behavior introduced in gprofng/src/Metric.cc +# and gprofng/src/Print.cc that addresses the most common user +# confusion (cache misses attributed to a loop-header line because of +# PMU skid). + +global srcdir CC CLOCK_GETTIME_LINK +set gprofng $::env(GPROFNG) +set testname "hwc_precision_marker" +set tdir "tmpdir/hwc_precision_marker" + +run_native_host_cmd "mkdir -p $tdir" + +# Build and try to record with the default HW counter set. If the +# host has no PMU access the collect step will fail with a message +# containing "not supported"; treat that as unsupported, not a fail. +set output [run_native_host_cmd "cd $tdir && \ + cp $srcdir/lib/smalltest.c t.c && \ + $CC -g t.c $CLOCK_GETTIME_LINK && \ + $gprofng collect app -p off -h on -a off -O exp.er ./a.out"] +set status [lindex $output 0] +set out [lindex $output 1] +if { $status != 0 } then { + if { [string first "not supported" $out] >= 0 \ + || [string first "HW counter" $out] >= 0 \ + || [string first "perf_event" $out] >= 0 } then { + unsupported $testname + return + } + send_log "collect with -h on failed unexpectedly:\n$out\n" + fail $testname + return +} + +set output [run_native_host_cmd "$gprofng display text -functions $tdir/exp.er"] +set out [lindex $output 1] + +set have_mark [expr {[string first "(*)" $out] >= 0}] +set have_footnote [expr {[string first "Non-precise HW event:" $out] >= 0}] + +# The marker and the footnote must be consistent. Both present means a +# non-precise counter was selected and explained; both absent means the +# default set was entirely precise (rare but valid). One without the +# other is a regression. +if { $have_mark != $have_footnote } then { + send_log "marker/footnote inconsistency (mark=$have_mark footnote=$have_footnote):\n$out\n" + fail $testname + return +} + +pass $testname