565 Commits

Author SHA1 Message Date
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 b8189cf9e40bd90502c9a2ce0df39dd54419bea4 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
Nick Clifton
b33c4f8f82 Add markers for 2.43 branch/release 2024-07-20 12:43:19 +01:00
Alan Modra
56f3903369 Revert "Remove LIBINTL_DEP"
This reverts commit e874cbd3879843a83e4bcc4b54cd7107387b1df6.
The patch was wrong.  LIBINTL_DEP is needed with an in-tree gettext.
2024-06-20 21:15:27 +09:30
Alan Modra
e874cbd387 Remove LIBINTL_DEP
The intl directory in the source no longer exists.  LIBINTL_DEP is
thus always empty.  Remove references to it.

config/
	* gettext-sister.m4: Don't AC_SUBST LIBINTL_DEP.
bfd/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
binutils/
	* Makefile.am (*_DEPENDENCIES): Remove LIBINTL_DEP.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
gas/
	* Makefile.am (as_new_DEPENDENCIES): Remove LIBINTL_DEP.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
gdb/
	* Makefile.in (INTL_DEPS): Don't set or reference.
	* configure: Regenerate.
gdbserver/
	* Makefile.in (INTL_DEPS): Don't set or reference.
gdbsupport/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
gold/
	* Makefile.am (deps_var): Remove LIBINTL_DEP.
	(incremental_dump_DEPENDENCIES, dwp_DEPENDENCIES): Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.am (DEPENDENCIES): Remove LIBINTL_DEP.
	* testsuite/Makefile.in: Regenerate.
gprof/
	* Makefile.am (gprof_DEPENDENCIES): Remove LIBINTL_DEP.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
ld/
	* Makefile.am (ld_new_DEPENDENCIES): Remove LIBINTL_DEP.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
opcodes/
	* configure.ac (BUILD_LIBS): Remove LIBINTL.
	(BUILD_LIB_DEPS): Remove LIBINTL_DEP.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2024-06-20 18:33:28 +09:30
Matthieu Longo
e83746f535 autoupdate: regen after replacing obsolete macros 2024-06-10 08:25:56 +09:30
Matthieu Longo
3dee0baea2 autoupdate: add square brackets around arguments of AC_INIT
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fINIT-2
2024-06-10 08:25:56 +09:30
Matthieu Longo
2cac47f5ba autoupdate: replace obsolete macros AC_AIX, AC_MINIX, and AC_GNU_SOURCE
- AC_AIX, AC_MINIX, and AC_GNU_SOURCE by AC_USE_SYSTEM_EXTENSIONS
  https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fAIX
  https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fMINIX-1
  https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fGNU_005fSOURCE-1
2024-06-10 08:25:55 +09:30
Christophe Lyon
54e2d897a6 Add missing install-dvi and install-ps Makefie targets.
For some reason, these targets are missing although others from the
same family are present. This looks like an oversight.

This enables calling 'make install-dvi' from the top-level build
directory.
2024-04-05 07:02:56 +00:00
Nick Clifton
bfdd2ca621 Updated translations for various sub-directories 2024-01-18 11:23:48 +00:00
Nick Clifton
e775d3a9b7 Change version to 2.42.50 and regenerate files 2024-01-15 15:13:36 +00:00
Nick Clifton
299b91cd85 Add markers for 2.42 branch 2024-01-15 14:42:15 +00:00
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
Arsen Arsenovi?
862776f26a Finalized intl-update patches
* intl: Remove directory.  Replaced with out-of-tree GNU gettext.
  * .gitignore: Add '/gettext*'.
  * configure.ac (host_libs): Replace intl with gettext. (hbaseargs, bbaseargs, baseargs): Split baseargs into {h,b}baseargs. (skip_barg): New flag.  Skips appending current flag to bbaseargs. <library exemptions>: Exempt --with-libintl-{type,prefix} from target and build machine argument passing.
  * configure: Regenerate.
  * Makefile.def (host_modules): Replace intl module with gettext module. (configure-ld): Depend on configure-gettext.
  * Makefile.in: Regenerate.
  * src-release.sh: Remove references to the intl/ directory.
2023-11-15 12:53:04 +00:00
Alan Modra
6a6859cbff regen config
This regenerates config files changed by the previous 44 commits.
Note that subject lines in these commits mostly match the gcc git
originating commit.
2023-08-12 10:27:57 +09:30
Alan Modra
23f6f86ca0 gprof: sprintf sanitizer null destination pointer
* basic_blocks.c (annotate_with_count): Use output of sprintf
	rather than strlen.
2023-08-03 21:19:54 +09:30
Sam James
b5c37946cc Revert "2.41 Release sources"
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d.

See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-02 12:06:23 +01:00
Nick Clifton
675b9d612c 2.41 Release sources 2023-08-02 09:23:36 +01:00
Nick Clifton
6a6e82dc75 Updated Spanish translation for the gprof directory 2023-07-31 13:53:23 +01:00
Alan Modra
477c9f2ba2 PR30657, gprof heap buffer overflow
PR 30657
	* cg_arcs.c (cg_assemble): Sanity check find_call addresses.
	* i386.c (i386_find_call): Don't access past end of core_text_space.
	* aarch64.c (aarch64_find_call): Round up lowpc, round down highpc.
	* alpha.c (alpha_find_call): Likewise.
	* mips.c (mips_find_call): Likewise.
	* sparc.c (sparc_find_call): Likewise.
	* vax.c (vax_find_call): Sanity check core_text_space accesses.
2023-07-26 10:23:27 +09:30
Nick Clifton
87485f5349 Change version number to 2.41.50 and regenerate files 2023-07-03 11:54:06 +01:00
Nick Clifton
d501d38488 Add markers for the 2.41 branch 2023-07-03 11:12:15 +01:00
Nick Clifton
0cf7c497f2 Updated French translation for the gprof sub-directory 2023-06-26 13:24:19 +01:00
Nick Clifton
e185530b58 Updated Hungarian translation for the gprof directory 2023-04-19 10:37:33 +01:00
Nick Clifton
91496180eb Fix an illegal memorty access when running gprof over corrupt data.
PR 30324
  * symtab.c (symtab_finalize): Only change the end address if dst has been updated.
2023-04-11 16:22:28 +01:00
Nick Clifton
85b922fcdd Updated Serbian translations for gold, gprof and opcodes sub-directories 2023-02-27 12:50:31 +00:00
Nick Clifton
c375d69903 Updated translatios for the bfd and gprof directories. 2023-02-21 11:05:57 +00:00
Nick Clifton
4004cf8331 Updated transaltions for the gprof and binutils sub-directories 2023-01-09 10:24:13 +00:00
Nick Clifton
d3efc341c0 Updated Bulgarian and Russian translations for the gprof subdirectory 2023-01-05 08:27:35 +00:00