[binutils-gdb] gprof: Fix tests on Solaris [PR34237]
Rainer Orth via Binutils-cvs <[email protected]> Thu, 11 Jun 2026 08:05:37 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c52a3e86835f40dc4048e038f3cec6b97dba69fb commit c52a3e86835f40dc4048e038f3cec6b97dba69fb Author: Rainer Orth <[email protected]> Date: Thu Jun 11 10:05:03 2026 +0200 gprof: Fix tests on Solaris [PR34237] The gprof tests FAIL on Solaris: tst-gmon-gprof.sh ../gprof tst-gmon --- expected +++ actual @@ -1,3 +1,4 @@ f1 2000 f2 1000 f3 1 +main 1 FAIL main is included in the call graph, probably because Solaris still uses the original BSD gmon.out format. This patch allows for that difference. To distinguish between targets with non-default handling, $target is passed to the test scripts. As detailed in the PR, the powerpc with function descriptors special case only applies to AIX, so that variant is guarded accordingly. Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. 2026-06-08 Rainer Orth <[email protected]> gprof: PR gprof/34237 * testsuite/Makefile.am (tst-gmon-gprof.out): Pass $(target) to tst-gmon-gprof.sh. (tst-gmon-gprof-l.out): Likewise. (tst-gmon-gprof-l2.out): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/tst-gmon-gprof.sh (expected_dot): Remove. <*-*-solaris2*>: Allow main in execution counters. <powerpc-*-aix* | rs6000-*-aix*>: Handle function descriptor case here. * testsuite/tst-gmon-gprof-l.sh: Likewise. * testsuite/tst-gmon-gprof-l2.sh: Likewise. Diff: --- gprof/testsuite/Makefile.am | 6 +++--- gprof/testsuite/Makefile.in | 6 +++--- gprof/testsuite/tst-gmon-gprof-l.sh | 20 ++++++++++++++------ gprof/testsuite/tst-gmon-gprof-l2.sh | 20 ++++++++++++++------ gprof/testsuite/tst-gmon-gprof.sh | 20 ++++++++++++++------ 5 files changed, 48 insertions(+), 24 deletions(-) diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am index 2f8a383a8dd..1eb91ce02d0 100644 --- a/gprof/testsuite/Makefile.am +++ b/gprof/testsuite/Makefile.am @@ -33,12 +33,12 @@ tst-gmon.$(OBJEXT): tst-gmon.c tst-gmon: tst-gmon.$(OBJEXT) $(LINK) tst-gmon.$(OBJEXT) tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF) - $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT) + $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT) $(target) check_SCRIPTS += tst-gmon-gprof-l.sh check_DATA += tst-gmon-gprof-l.out tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF) - $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT) + $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT) $(target) # Create a separated-debuginfo version of the initial binary check_SCRIPTS += tst-gmon-gprof-l2.sh @@ -49,7 +49,7 @@ tst-gmon2$(EXEEXT) tst-gmon2.debug: tst-gmon$(EXEEXT) objcopy --add-gnu-debuglink=tst-gmon2.debug tst-gmon2$(EXEEXT) tst-gmon-gprof-l2.out: tst-gmon2$(EXEEXT) tst-gmon2.debug $(GPROF) - $(srcdir)/tst-gmon-gprof-l2.sh $(GPROF) tst-gmon2$(EXEEXT) + $(srcdir)/tst-gmon-gprof-l2.sh $(GPROF) tst-gmon2$(EXEEXT) $(target) check_DATA += tst-gmon-gprof-l2.out MOSTLYCLEANFILES += tst-gmon2$(EXEEXT) tst-gmon2.debug diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in index 0160e44a8d2..c3ab9089b1c 100644 --- a/gprof/testsuite/Makefile.in +++ b/gprof/testsuite/Makefile.in @@ -898,9 +898,9 @@ uninstall-am: @NATIVE_TRUE@tst-gmon: tst-gmon.$(OBJEXT) @NATIVE_TRUE@ $(LINK) tst-gmon.$(OBJEXT) @[email protected]: tst-gmon$(EXEEXT) $(GPROF) -@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT) +@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT) $(target) @[email protected]: tst-gmon$(EXEEXT) $(GPROF) -@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT) +@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT) $(target) @NATIVE_TRUE@tst-gmon2$(EXEEXT) tst-gmon2.debug: tst-gmon$(EXEEXT) @NATIVE_TRUE@ cp -p tst-gmon$(EXEEXT) tst-gmon2$(EXEEXT) @NATIVE_TRUE@ objcopy --only-keep-debug tst-gmon2$(EXEEXT) tst-gmon2.debug @@ -908,7 +908,7 @@ uninstall-am: @NATIVE_TRUE@ objcopy --add-gnu-debuglink=tst-gmon2.debug tst-gmon2$(EXEEXT) @[email protected]: tst-gmon2$(EXEEXT) tst-gmon2.debug $(GPROF) -@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof-l2.sh $(GPROF) tst-gmon2$(EXEEXT) +@NATIVE_TRUE@ $(srcdir)/tst-gmon-gprof-l2.sh $(GPROF) tst-gmon2$(EXEEXT) $(target) # Run all tests in series, so they don't fight over the gmon.out file @[email protected]: diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh index d0c26cb62fa..5cb15f43ef7 100755 --- a/gprof/testsuite/tst-gmon-gprof-l.sh +++ b/gprof/testsuite/tst-gmon-gprof-l.sh @@ -24,6 +24,7 @@ if test -z "$GPROF"; then fi program="$2" +target="$3" # Generate gmon.out data=gmon.out rm -f $data @@ -40,11 +41,9 @@ exec 2>&1 actual=${program}.actual-l expected=${program}.expected-l -expected_dot=${program}.expected_dot-l cleanup () { rm -f "$actual" rm -f "$expected" - rm -f "$expected_dot" } trap cleanup 0 @@ -54,19 +53,28 @@ cat > "$expected" <<EOF 40 f3 1 EOF -# Special version for powerpc with function descriptors. -cat > "$expected_dot" <<EOF +case "$target" in + *-*-solaris2*) + # Solaris with the BSD gmon.out format includes main in the call graph. + cat >> $expected <<EOF +51 main 1 +EOF + ;; + powerpc-*-aix* | rs6000-*-aix*) + # Special version for powerpc with function descriptors. + cat > "$expected" <<EOF 25 .f1 2000 31 .f2 1000 40 .f3 1 EOF + ;; +esac "$GPROF" -l -C "$program" "$data" \ | awk -F '[(): ]' '/executions/{print $2, $5, $8}' \ | sort > "$actual" -if cmp -s "$actual" "$expected_dot" \ - || diff -u --label expected "$expected" --label actual "$actual" ; then +if diff -u --label expected "$expected" --label actual "$actual" ; then echo "PASS" else echo "FAIL" diff --git a/gprof/testsuite/tst-gmon-gprof-l2.sh b/gprof/testsuite/tst-gmon-gprof-l2.sh index 530d022e472..d0f47a7e9bb 100755 --- a/gprof/testsuite/tst-gmon-gprof-l2.sh +++ b/gprof/testsuite/tst-gmon-gprof-l2.sh @@ -24,6 +24,7 @@ if test -z "$GPROF"; then fi program="$2" +target="$3" # Generate gmon.out data=gmon.out rm -f $data @@ -40,11 +41,9 @@ exec 2>&1 actual=${program}.actual-l expected=${program}.expected-l -expected_dot=${program}.expected_dot-l cleanup () { rm -f "$actual" rm -f "$expected" - rm -f "$expected_dot" } trap cleanup 0 @@ -54,19 +53,28 @@ cat > "$expected" <<EOF 40 f3 1 EOF -# Special version for powerpc with function descriptors. -cat > "$expected_dot" <<EOF +case "$target" in + *-*-solaris2*) + # Solaris with the BSD gmon.out format includes main in the call graph. + cat >> $expected <<EOF +51 main 1 +EOF + ;; + powerpc-*-aix* | rs6000-*-aix*) + # Special version for powerpc with function descriptors. + cat > "$expected" <<EOF 25 .f1 2000 31 .f2 1000 40 .f3 1 EOF + ;; +esac "$GPROF" -l -C "$program" "$data" \ | awk -F '[(): ]' '/executions/{print $2, $5, $8}' \ | sort > "$actual" -if cmp -s "$actual" "$expected_dot" \ - || diff -u --label expected "$expected" --label actual "$actual" ; then +if diff -u --label expected "$expected" --label actual "$actual" ; then echo "PASS" else echo "FAIL" diff --git a/gprof/testsuite/tst-gmon-gprof.sh b/gprof/testsuite/tst-gmon-gprof.sh index ef66d93a23a..f912768aa29 100755 --- a/gprof/testsuite/tst-gmon-gprof.sh +++ b/gprof/testsuite/tst-gmon-gprof.sh @@ -24,6 +24,7 @@ if test -z "$GPROF"; then fi program="$2" +target="$3" # Generate gmon.out data=gmon.out rm -f $data @@ -40,11 +41,9 @@ exec 2>&1 actual=${program}.actual expected=${program}.expected -expected_dot=${program}.expected_dot cleanup () { rm -f "$actual" rm -f "$expected" - rm -f "$expected_dot" } trap cleanup 0 @@ -54,19 +53,28 @@ f2 1000 f3 1 EOF -# Special version for powerpc with function descriptors. -cat > "$expected_dot" <<EOF +case "$target" in + *-*-solaris2*) + # Solaris with the BSD gmon.out format includes main in the call graph. + cat >> $expected <<EOF +main 1 +EOF + ;; + powerpc-*-aix* | rs6000-*-aix*) + # Special version for powerpc with function descriptors. + cat > "$expected" <<EOF .f1 2000 .f2 1000 .f3 1 EOF + ;; +esac "$GPROF" -C "$program" "$data" \ | awk -F '[(): ]' '/executions/{print $5, $8}' \ | sort > "$actual" -if cmp -s "$actual" "$expected_dot" \ - || diff -u --label expected "$expected" --label actual "$actual" ; then +if diff -u --label expected "$expected" --label actual "$actual" ; then echo "PASS" else echo "FAIL"