Commit graph

592 commits

Author SHA1 Message Date
Nick Clifton
35c64456cd Change version number to 2.47.50 and regenerate files 2026-07-12 10:50:36 +01:00
Rainer Orth
c52a3e8683 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  <ro@CeBiTec.Uni-Bielefeld.DE>

	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.
2026-06-11 10:05:03 +02:00
Mark Wielaard
b8d39fd810 gprof: Fix strchr discarded qualifier call
In annotate_source strrchr is called on a const char *. So the result
should also be stored in a const char *.

	* gprof/source.c (annotate_source): Make name_only a const char *.
2026-05-04 05:47:56 +08:00
H.J. Lu
365fc34606 Fix the strrchr error for DOS based filesystem
Fix the strrchr error like:

gprof/source.c:130:28: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  130 |             char *bslash = strrchr (sf->name, '\\');

binutils/

	* bucomm.c (template_in_dir): Make bslash const char *.

gprof/

	* source.c (annotate_source): Make bslash const char *.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2026-05-03 11:49:59 +08:00
Frank Ch. Eigler
27d21139e3
gprof support for split debuginfo, tweak 2
This reverts commit a2ceac8957,
but adds back unconditional BFD_DECOMPRESS, as per amodra:
https://inbox.sourceware.org/binutils/afPQ5BGfFQHYBny1@squeak.grove.modra.org/

Signed-off-by: Frank Ch. Eigler <fche@elastic.org>
2026-04-30 21:18:06 -04:00
Frank Ch. Eigler
a2ceac8957
gprof support for split debuginfo, tweak
* gprof/corefile.c: Remove BFD_DECOMPRESS conditional, as per amodra.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
2026-04-30 13:20:42 -04:00
Frank Ch. Eigler
634e1cb34a
gprof support for split debuginfo
Use debug BFD for symbol and line information when a separated
debuginfo file is found, enabling gprof to work correctly with
binaries stripped with "strip -g".  Baby steps toward possible
future debuginfod/dwz support.

gprof/ChangeLog:

2026-04-29  Frank Ch. Eigler  <fche@redhat.com>

        * corefile.c: Add support for separated debuginfo files.
        (core_debug_bfd): New static variable to store separated debug BFD.
        (open_separated_debug_file): New function to locate and open external
        debug files via .gnu_debuglink, .gnu_debugaltlink, or build-id.
        (core_init): Call open_separated_debug_file() after opening the main
        binary to locate external debug info.
        * testsuite/Makefile.am, testsuite/tst-gmon-gprof-l2.sh: Run -l
        test again, but against stripped version of test binary.
        * testsuite/Makefile.in: Regenerated.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
2026-04-30 13:18:39 -04:00
Jan Beulich
1319410a1e gprof: fix testsuite with older glibc
It is quite sad that 2.46 has again shipped with this breakage. Short of
those responsible taking care, use the workaround that was suggested in
https://sourceware.org/pipermail/binutils/2025-April/140316.html.
2026-02-13 10:19:39 +01:00
Nick Clifton
0baf1ef52d
Updated/new translation files for the 2.46 release 2026-02-06 10:17:29 +00:00
Alan Modra
589f93f855 regen gprof and gprofng configure 2026-01-30 07:37:19 +10:30
Alan Modra
9eca9dcd85 regen pot files 2026-01-28 10:13:02 +10:30
Alan Modra
d2762b6201 regen pot files 2026-01-26 16:10:39 +10:30
Nick Clifton
1b66149b97
Regenerate autogenerated files 2026-01-25 10:28:05 +00:00
Alan Modra
c8f306af2f Update year range in copyright notice of binutils files
Avoid warnings about invalid escapes in etc/update-copyright.py by
using raw strings, add BinutilsFilter to skip psql.rc and add
"Kalray SA." as another copyright holder.
2026-01-01 23:22:14 +10:30
Claudiu Zissulescu
669c215363 gprofng: Add documentation on converting gmon files.
Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
2025-11-20 14:59:33 +02:00
Alan Modra
87b6078fc2 tidy m4 plugin config support
In CLANG_PLUGIN_FILE it is possible for plugin_file to be non-NULL
when LLVMgold.so does not exist.

configure output is messy, with results not printed against their
  "checking.." line, eg.
checking for clang... (cached) yes
checking for clang plugin file... checking for x86_64-pc-linux-gnu-ar... (cached) ar --plugin /usr/lib/llvm-20/lib/clang/20/../../LLVMgold.so
/usr/lib/llvm-20/lib/clang/20/../../LLVMgold.so

This patch fixes those problems, and a similar interposition of other
configure output between AC_MSG_CHECKING and AC_MSG_RESULT in
gcc-plugin.m4.  It also tidies some of the message text, and makes
similar code in gcc-plugin.m4 and clang-plugin.m4 a little more
consistent.

config/
	* clang-plugin.m4 (CLANG_PLUGIN_FILE): Don't place checks for
	tools (llvm-config, ar) inside AC_MSG_CHECKING..AC_MSG_RESULT
	for clang plugin file.  Clear plugin_file before loop exit.
	(CLANG_PLUGIN_FILE_FOR_TARGET): Similarly.
	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): Similarly.
	(GCC_PLUGIN_OPTION_FOR_TARGET): Correct AC_MSG_CHECKING.  Tidy
	return code.
binutils/
	* testsuite/lib/binutils-common.exp <llvm_plug_opt>: Set for
	non-native.
	* configure: Regenerate.
/
	* configure: Regenerate.
bfd/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gdb/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
gprofng/
	* configure: Regenerate.
	* libcollector/configure: Regenerate.
ld/
	* configure: Regenerate.
libbacktrace/
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
libiberty/
	* configure: Regenerate.
libsframe/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
sim/
	* configure: Regenerate.
zlib/
	* configure: Regenerate.
2025-11-03 10:59:50 +10:30
H.J. Lu
4f62e7d83f Binutils: Add clang LTO support to AR and RANLIB
Detect the clang plugin file and and pass it to --plugin for ar and ranlib
so that binutils can be built with clang LTO.

bfd/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

binutils/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

gas/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

gprof/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.

gprofng/

	PR binutils/33470
	* Makefile.am (ACLOCAL_AMFLAGS): Add -I ../config.
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* gp-display-html/Makefile.in: Likewise.
	* libcollector/Makefile.in: Likewise.
	* libcollector/aclocal.m4: Likewise.
	* libcollector/configure: Likewise.
	* src/Makefile.in: Likewise.
	* libcollector/Makefile.am (ACLOCAL_AMFLAGS): Add -I ../../config.

ld/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

libctf/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

libsframe/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

opcodes/

	PR binutils/33470
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-09-25 12:30:13 +08:00
Nick Clifton
3b465bc232
Updated and new translations for the binutils 2025-09-18 11:56:52 +01:00
Pietro Monteiro
bdee554202 Update obsolete autoconf macros
bfd/
	* bfd.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
binutils/
	* configure.ac: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
gas/
	* acinclude.m4: Replace AC_TRY_LINK with AC_LINK_IFELSE.
	Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
gprof/
	* configure.ac: Replace AC_OUTPUT(file list) with
	AC_CONFIG_FILES([file list])\nAC_OUTPUT.
libctf/
	* configure.ac: Replace AC_TRY_LINK with AC_LINK_IFELSE.
opcodes/
	* configure.ac: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
2025-08-07 22:14:49 +09:30
H.J. Lu
393e0434e2 gprof: Run tst-gmon-gprof-l.sh after tst-gmon-gprof.sh
Both tst-gmon-gprof.sh and tst-gmon-gprof-l.sh generate gmon.out and
process it.  Run tst-gmon-gprof-l.sh after tst-gmon-gprof.sh to avoid
the race condition.

	* testsuite/Makefile.am (tst-gmon-gprof-l.out): Depend on
	tst-gmon-gprof.out.
	* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-01 04:20:03 -07:00
Nick Clifton
657f10397e
Updated translations for various sub-directories 2025-07-22 15:58:21 +01:00
Nick Clifton
83be472a61
Updated translations for various sub-directories 2025-07-15 13:37:09 +01:00
Alan Modra
33aa1470c7 Delete AM_PO_SUBDIRS invocation
These aren't needed since commit 862776f26a.
2025-07-14 19:31:41 +09:30
Nick Clifton
47fdedbb95
Update version number on mainline 2025-07-13 08:57:08 +01:00
Nick Clifton
5c778308bd
Add markers for 2.45 branch 2025-07-13 08:35:45 +01:00
Alan Modra
d72ad17caa AM_PO_SUBDIRS
Swap AM_PO_SUBDIRS and ZW_GNU_GETTEXT_SISTER_DIR lines in
*/configure.ac.  ZW_GNU_GETTEXT_SISTER_DIR indirectly invokes
AC_REQUIRE(AM_PO_SUBDIRS) so results in AM_PO_SUBDIRS being emitted
before ZW_GNU_GETTEXT_SISTER_DIR if it hasn't already been invoked.
2025-07-11 08:23:40 +09:30
Alan Modra
a388feed3d asan: null pointer as arg 2 of memcpy
Replace xmalloc+memcpy+free with xrealloc, avoiding the asan warning
on the initial allocation where we had memcpy(p,0,0).

	* cg_arcs.c (arc_add): Use xrealloc.
2025-05-01 22:50:35 +09:30
H.J. Lu
8497f4cc42 gprof: Always compile tests with -g
Always compile gprof testsuite with -g for line number info checked by
tst-gmon-gprof-l.sh.

	PR gprof/32779
	* testsuite/Makefile.am (GPROF_FLAGS): Add -g.
	(COMPILE): Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS)".
	(LINK) Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS) $(AM_LDFLAGS)
	$(LDFLAGS) -o $@".
	* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-29 07:03:46 -07:00
Richard Allen
c912005af7 gprof: only process line numbers for intersection of vmas and histograms
Some programs like RTOS firmware may have a large number of symbols.
The profile information in the profile data file includes histogram
records, which capture low PC and high PC of program execution.  If all
histogram records come in the profile data file before any call-graph
records and basic-block records, we can look up only the line numbers
within low PC and high PC in histogram records, which reduces processing
time for such a firmware from ~2 minutes to ~2 seconds.

Add symbol table access function, get_symtab, get_symtab_direct and
set_symtab to delay loading the symbol table until its first use.

	* aarch64.c (aarch64_find_call): Call get_symtab to get the
	symbol table pointer
	* alpha.c (alpha_find_call): Likewise.
	* basic_blocks.c (bb_read_rec): Likewise.
	(bb_write_blocks): Likewise.
	(print_exec_counts): Likewise.
	(print_annotated_source): Likewise.
	* call_graph.c (cg_tally): Likewise.
	(cg_write_arcs): Likewise.
	* cg_arcs.c (cycle_link): Likewise.
	(propagate_flags): Likewise.
	(cg_assemble): Likewise.
	* cg_print.c (cg_print): Likewise.
	(cg_print_index): Likewise.
	(cg_print_function_ordering): Likewise.
	* corefile.c: Include "gmon_io.h".
	(core_create_syms_from): Call get_symtab_direct to get the
	symbol table pointer.
	(core_create_function_syms): Likewise.
	(core_create_line_syms): Likewise.  If all histogram records
	come in the profile data file before any call-graph records and
	basic-block records, we can look up only the line numbers within
	low PC and high PC in histogram records.
	* gmon_io.c (gmon_histograms_first): New.
	(gmon_out_read): Set gmon_histograms_first to true if all
	histogram records come first.
	(gmon_out_write): Call get_symtab to get the symbol table
	pointer.
	* hist.c (scale_and_align_entries): Likewise.
	(hist_assign_samples_1): Likewise.
	(hist_print): Likewise.
	* i386.c (i386_find_call): Likewise.
	* mips.c (mips_find_call): Likewise.
	* sparc.c (sparc_find_call): Likewise.
	* sym_ids.c (sym_id_parse): Likewise.
	* vax.c (vax_find_call): Likewise.
	* gmon_io.h (gmon_histograms_first): New.
	* gprof.c (man): Don't create profile info.
	(symtab_init): New.
	* gprof.h (symtab_init): New.
	* symtab.c (symtab): Changed to static.
	(get_symtab_direct): New.
	(get_symtab): Likewise.
	(set_symtab): Likewise.
	* symtab.h (symtab): Removed.
	(get_symtab_direct): New.
	(get_symtab): Likewise.
	(set_symtab): Likewise.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
2025-03-14 07:03:52 -07:00
H.J. Lu
72088cbe29 gprof: Append -l to tst-gmon-gprof-l.sh data files
Append -l to tst-gmon-gprof-l.sh data files to avoid conflicts with
tst-gmon-gprof.sh data files.

	* testsuite/tst-gmon-gprof-l.sh (actual): Append -l.
	(expected): Likewise.
	(expected_dot): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-10 08:07:17 -07:00
H.J. Lu
48691f6650 gprof: Add a simple test for gprof -l
Verify that "gprof -l" works properly.

	* testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/tst-gmon-gprof-l.sh: New.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-10 06:41:42 -07:00
H.J. Lu
1563d43f32 gprof: Compile tst-gmon.c with -O2 -fno-omit-frame-pointer
Compile tst-gmon.c with -O2 -fno-omit-frame-pointer to ensure proper call
graph generation.

	PR gprof/32768
	* configure.ac: Compile tst-gmon.c with -fno-omit-frame-pointer.
	* configure: Regenerated.
	* testsuite/Makefile.am (GPROF_FLAGS): Add -O2
	-fno-omit-frame-pointer.
	(AM_CFLAGS): Removed.
	(COMPILE): Append $(GPROF_FLAGS).
	(LINK): Likewise.
	* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-08 18:38:01 +08:00
H.J. Lu
bdf9485559 gprof: Update PR gprof/32764 test
1. Remove gmon.out first before generating it in the configure check.
2. Make tst-gmon-gprof.out depend on the gprof binary.
3. Check that gmon.out is non-empty.
4. Don't include <sys/cdefs.h> in tst-gmon.c.

	PR gprof/32764
	* configure.ac: Remove gmon.out first.
	* configure: Regenerated.
	* testsuite/Makefile.am (tst-gmon-gprof.out): Depend on
	$(GPROF).
	* testsuite/Makefile.in: Regenerated.
	* testsuite/tst-gmon-gprof.sh: Check that gmon.out is non-empty.
	* testsuite/tst-gmon.c: Don't include <sys/cdefs.h>.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-07 15:05:57 +08:00
H.J. Lu
d07a59a5ca gprof: Copy a simple test from glibc
Copy a simple gprof test from glibc to test the basic gprof functionality.

1. Tested natively on Linux/x86-64 and Linux/i686.
2. Tested for the x86_64-solaris cross target without cross-compiler.
3. Tested for the aarch64-linux-gnu cross target with cross-compiler.

	PR gprof/32764
	* Makefile.am (SUBDIRS): Add testsuite
	* configure.ac (AC_CONFIG_FILES): Removed.
	(AC_OUTPUT): Add Makefile testsuite/Makefile
	po/Makefile.in:po/Make-in.
	(AM_CONDITIONAL): Add NATIVE.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* testsuite/Makefile.am: New file.
	* testsuite/tst-gmon-gprof.sh: Likewise.
	* testsuite/tst-gmon.c: Likewise.
	* testsuite/Makefile.in: Generated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-07 09:15:49 +08:00
H.J. Lu
d0bcc49443 Revert "gprof: only process line numbers for intersection of vmas and histograms"
This reverts commit b8189cf9e4 to fix
PR gprof/32764:

https://sourceware.org/bugzilla/show_bug.cgi?id=32764
2025-03-06 15:30:54 +08:00
Richard Allen
b8189cf9e4 gprof: only process line numbers for intersection of vmas and histograms
Some programs like RTOS firmware may have a large number of symbols.

By loading the histograms before loading symbols, we can look up
only the line numbers that were captured in the histogram file,
which reduces processing time for such a firmware from ~2 minutes
to ~2 seconds.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-03 08:33:55 +10:30
Richard Allen
37afef6fe1 gprof: fix symbol miscount by merging passes
Instead of fixing "somebody miscounted" errors,
this patch combines the core_create_line_syms()
passes, and dynamically expands the ltab buffer.

Reducing the number of passes will make future
optimizations simpler.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01 11:17:13 +10:30
Richard Allen
9b65bc0067 gprof: remove unused variables
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01 11:17:13 +10:30
Richard Allen
b6539282a9 gprof: speed up line-by-line for MIPS/PowerPC/RISCV/SuperH
Roughly halves the number of bfd_find_nearest_line() calls,
about 40% less time for a few different large ELF files.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01 11:17:13 +10:30
Richard Allen
f19534f257 gprof: rename min_insn_size to insn_boundary
This distinction is important for architecures like Xtensa,
where 2B and 3B instructions are common, but the correct
value for instruction iteration is 1B, not 2B.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01 11:17:13 +10:30
Richard Allen
50eeb3b160 gprof: remove ASCII formfeed/0x0C bytes from source code
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01 11:17:13 +10:30
Richard Allen
2effb0d11f gprof: fix odd inst len hist scale calculation
With even instruction sizes, this rounding never truncated.
Xtensa CPUs mostly use 2-3 byte instructions, and this can lead
to a histogram being captured with an odd length address range.

This small truncation prevented gprof from parsing gmon.out files
containing multiple histograms when at least one of them has an
odd address range length and another has any other address range.

Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10 08:58:02 +10:30
Richard Allen
cb0930a000 gprof: print values of mismatched histogram scales
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10 08:58:02 +10:30
Richard Allen
0a00ac1d36 gprof: fix comment typos
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10 08:58:02 +10:30
Richard Allen
7fca0dec79 gprof: add missing newline to error text
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10 08:58:02 +10:30
Nick Clifton
8c7653ab09
Change version to 2.44.50 and regenerate files 2025-01-19 12:40:46 +00:00
Nick Clifton
b49d12e2c5
Add markers for bihnutils 2.44 branch 2025-01-19 12:09:01 +00:00
Alan Modra
e8e7cf2abe Update year range in copyright notice of binutils files 2025-01-01 18:29:57 +10:30
Nick Clifton
039db5946f
Updated Brazilian Portuguese translation for the gprof directory. 2024-09-26 16:11:59 +01:00
Nick Clifton
cff16e125a Change version to 2.43.50 2024-07-20 13:16:33 +01:00