Commit Graph

57 Commits

Author SHA1 Message Date
Martin Liska 28cfea987e libgcov: add ATTRIBUTE_UNUSED for dump_string
Mitigates the following clang warning:
libgcc/libgcov-driver.c:416:1: warning: unused function 'dump_string' [-Wunused-function]

libgcc/ChangeLog:

	* libgcov-driver.c: Add ATTRIBUTE_UNUSED.
2022-05-02 06:46:05 +02:00
Sebastian Huber 39d80300b3 gcov: Add __gcov_filename_to_gcfn()
gcc/

	* doc/invoke.texi (fprofile-info-section): Mention
	__gcov_filename_to_gcfn().  Use "freestanding" to match with C11
	standard language.  Fix minor example code issues.
	* gcov-io.h (GCOV_FILENAME_MAGIC): Define and document.

gcc/testsuite/

	* gcc.dg/gcov-info-to-gcda.c: Test __gcov_filename_to_gcfn().

libgcc/

	* gcov.h (__gcov_info_to_gcda): Mention __gcov_filename_to_gcfn().
	(__gcov_filename_to_gcfn): Declare and document.
	* libgcov-driver.c (dump_string): New.
	(__gcov_filename_to_gcfn): Likewise.
	(__gcov_info_to_gcda): Adjust comment to match C11 standard language.
2022-04-28 20:46:49 +02:00
Sebastian Huber 1a6314b040 gcov: Add open mode parameter to gcov_do_dump()
gcc/

	* gcov-tool.cc (gcov_do_dump): Add mode parameter.
	(gcov_output_files): Open files for reading and writing.

libgcc/

	* libgcov-driver-system.c (gcov_exit_open_gcda_file): Add mode
	parameter.  Pass mode to gcov_open() calls.
	* libgcov-driver.c (dump_one_gcov):  Add mode parameter.  Pass mode to
	gcov_exit_open_gcda_file() call.
	(gcov_do_dump): Add mode parameter.  Pass mode to dump_one_gcov()
	calls.
	(__gcov_dump_one):  Open file for reading and writing.
2022-04-28 20:46:49 +02:00
Martin Liska cd9912b593 Manual changes for .cc renaming.
gcc/ChangeLog:

	* Makefile.in: Rename .c names to .cc.
	* config.gcc: Likewise.
	* configure: Regenerate. Likewise.
	* configure.ac: Likewise.
	* gengtype.cc (set_gc_used): Likewise.
	(source_dot_c_frul): Likewise.
	(source_dot_cc_frul): Likewise.
	(struct file_rule_st): Likewise.
	(close_output_files): Likewise.
	* config/avr/t-avr: Use CXXFLAGS_* and CXX_FOR_BUILD.

gcc/ada/ChangeLog:

	* Makefile.rtl: Rename .c names to .cc.
	* gcc-interface/Make-lang.in: Likewise.
	* gcc-interface/Makefile.in: Likewise.

libgcc/ChangeLog:

	* libgcov-driver.c: Rename .c names to .cc.

libcpp/ChangeLog:

	* Makefile.in: Rename .c names to .cc.
2022-01-17 22:12:14 +01:00
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Martin Liska 72e0c742bd gcov: make profile merging smarter
Support merging of profiles that are built from a different .o files
but belong to the same source file. Moreover, a checksum is verified
during profile merging and so we can safely combine such profile.

	PR gcov-profile/90364

gcc/ChangeLog:

	* coverage.c (build_info): Emit checksum to the global variable.
	(build_info_type): Add new field for checksum.
	(coverage_obj_finish): Pass object_checksum.
	(coverage_init): Use 0 as checksum for .gcno files.
	* gcov-dump.c (dump_gcov_file): Dump also new checksum field.
	* gcov.c (read_graph_file): Read also checksum.
	* doc/invoke.texi: Document the behaviour change.

libgcc/ChangeLog:

	* libgcov-driver.c (merge_one_data): Skip timestamp and verify
	checksums.
	(write_one_data): Write also checksum.
	* libgcov-util.c (read_gcda_file): Read also checksum field.
	* libgcov.h (struct gcov_info): Add new field.
2021-10-13 15:26:58 +02:00
Sebastian Huber 3c94db20be gcov: Remove <stdint.h> from libgcov-driver.c
In the patch to add __gcov_info_to_gcda(), the include of <stdint.h> was added
to libgcov-driver.c even if inhibit_libc is defined.  It turned out that this
header file is not always available.  Remove the include of <stdint.h> and
replace the intptr_t with the compiler provided __INTPTR_TYPE__.

libgcc/

	* libgcov-driver.c (#include <stdint.h>): Remove.
	(write_topn_counters): Use __INTPTR_TYPE__ instead of intptr_t.
2021-08-06 12:27:48 +02:00
Sebastian Huber 9124bbe185 gcov: Add __gcov_info_to_gdca()
Add __gcov_info_to_gcda() to libgcov to get the gcda data for a gcda info in a
freestanding environment.  It is intended to be used with the
-fprofile-info-section option.  A crude test program which doesn't use a linker
script is (use "gcc -coverage -fprofile-info-section -lgcov test.c" to compile
it):

  #include <gcov.h>
  #include <stdio.h>
  #include <stdlib.h>

  extern const struct gcov_info *my_info;

  static void
  filename (const char *f, void *arg)
  {
    printf("filename: %s\n", f);
  }

  static void
  dump (const void *d, unsigned n, void *arg)
  {
    const unsigned char *c = d;

    for (unsigned i = 0; i < n; ++i)
      printf ("%02x", c[i]);
  }

  static void *
  allocate (unsigned length, void *arg)
  {
    return malloc (length);
  }

  int main()
  {
    __asm__ volatile (".set my_info, .LPBX2");
    __gcov_info_to_gcda (my_info, filename, dump, allocate, NULL);
    return 0;
  }

With this patch, <stdint.h> is included in libgcov-driver.c even if
inhibit_libc is defined.  This header file should be also available for
freestanding environments.  If this is not the case, then we have to define
intptr_t somehow.

The patch removes one use of memset() which makes the <string.h> include
superfluous.

gcc/

	* gcov-io.h (gcov_write): Declare.
	* gcov-io.c (gcov_write): New.
	(gcov_write_counter): Remove.
	(gcov_write_tag_length): Likewise.
	(gcov_write_summary): Replace gcov_write_tag_length() with calls to
	gcov_write_unsigned().
	* doc/invoke.texi (fprofile-info-section): Mention
	__gcov_info_to_gdca().

gcc/testsuite/

	* gcc.dg/gcov-info-to-gcda.c: New test.

libgcc/

	* Makefile.in (LIBGCOV_DRIVER): Add _gcov_info_to_gcda.
	* gcov.h (gcov_info): Declare.
	(__gcov_info_to_gdca): Likewise.
	* libgcov.h (gcov_write_counter): Remove.
	(gcov_write_tag_length): Likewise.
	* libgcov-driver.c (#include <stdint.h>): New.
	(#include <string.h>): Remove.
	(NEED_L_GCOV): Conditionally define.
	(NEED_L_GCOV_INFO_TO_GCDA): Likewise.
	(are_all_counters_zero): New.
	(gcov_dump_handler): Likewise.
	(gcov_allocate_handler): Likewise.
	(dump_unsigned): Likewise.
	(dump_counter): Likewise.
	(write_topn_counters): Add dump_fn, allocate_fn, and arg parameters.
	Use dump_unsigned() and dump_counter().
	(write_one_data): Add dump_fn, allocate_fn, and arg parameters.  Use
	dump_unsigned(), dump_counter(), and are_all_counters_zero().
	(__gcov_info_to_gcda): New.
2021-08-06 07:28:26 +02:00
marxin 23eb66d1d4 gcov: Use system IO buffering
gcc/ChangeLog:

	* gcov-io.c (gcov_write_block): Remove.
	(gcov_write_words): Likewise.
	(gcov_read_words): Re-implement using gcov_read_bytes.
	(gcov_allocate): Remove.
	(GCOV_BLOCK_SIZE): Likewise.
	(struct gcov_var): Remove most of the fields.
	(gcov_position): Implement with ftell.
	(gcov_rewrite): Remove setting of start and offset fields.
	(from_file): Re-format.
	(gcov_open): Remove setbuf call. It should not be needed.
	(gcov_close): Remove internal buffer handling.
	(gcov_magic): Use __builtin_bswap32.
	(gcov_write_counter): Use directly gcov_write_unsigned.
	(gcov_write_string): Use direct fwrite and do not round
	to 4 bytes.
	(gcov_seek): Use directly fseek.
	(gcov_write_tag): Use gcov_write_unsigned directly.
	(gcov_write_length): Likewise.
	(gcov_write_tag_length): Likewise.
	(gcov_read_bytes): Use directly fread.
	(gcov_read_unsigned): Use gcov_read_words.
	(gcov_read_counter): Likewise.
	(gcov_read_string): Use gcov_read_bytes.
	* gcov-io.h (GCOV_WORD_SIZE): Adjust to reflect
	that size is not in bytes, but words (4B).
	(GCOV_TAG_FUNCTION_LENGTH): Likewise.
	(GCOV_TAG_ARCS_LENGTH): Likewise.
	(GCOV_TAG_ARCS_NUM): Likewise.
	(GCOV_TAG_COUNTER_LENGTH): Likewise.
	(GCOV_TAG_COUNTER_NUM): Likewise.
	(GCOV_TAG_SUMMARY_LENGTH): Likewise.

libgcc/ChangeLog:

	* libgcov-driver.c: Fix GNU coding style.
2021-05-13 10:59:36 +02:00
Martin Liska e3a682f419 Use genversion to generate version.h.
c++tools/ChangeLog:

	* Makefile.in: Include also ../gcc folder.

gcc/ChangeLog:

	* Makefile.in: Rename gcov-iov to genversion and depend
	on version.h (instead of gcov-iov.h).
	* gcov-io.h: Include version.h instread of gcov-iov.h.
	* gengtype-state.c (read_state_version): Likewise.
	* gcov-iov.c: Moved to...
	* genversion.c: ...here.
	* lto-streamer.h (LTO_major_version): Define it with
	GCC_major_version.
	* version.c: Removed.
	* version.h: Removed.

libgcc/ChangeLog:

	* libgcov-driver.c (gcov_version): Use different name that does
	not clash with newly introduced macro.
2021-05-10 09:13:46 +02:00
Eric Botcazou 9ec469f504 Add parallelism support to gcov for MinGW platforms
If you attempt a profiled bootstrap on the MinGW platforms with -jN, N > 1,
it miserably fails because of profile mismatches all over the place, the
reason being that gcov has no support for parallelism on these platforms.

libgcc/
	* libgcov.h: For the target, define GCOV_LOCKED_WITH_LOCKING
	if __MSVCRT__ and, for the host, define it if HOST_HAS_LK_LOCK.
	* libgcov-driver.c: Add directives if GCOV_LOCKED_WITH_LOCKING.
gcc/
	* configure.ac: Check for the presence of sys/locking.h header and
	for whether _LK_LOCK is supported by _locking.
	* configure: Regenerate.
	* config.in: Likewise.
	* gcov-io.h: Define GCOV_LOCKED_WITH_LOCKING if HOST_HAS_LK_LOCK.
	* gcov-io.c (gcov_open): Add support for GCOV_LOCKED_WITH_LOCKING.
	* system.h: Include <sys/locking.h> if HAVE_SYS_LOCKING_H.
2021-04-29 16:02:17 +02:00
Martin Liska 6a8fc0c31a profiling: fix streaming of TOPN counters
libgcc/ChangeLog:

	PR gcov-profile/99105
	* libgcov-driver.c (write_top_counters): Rename to ...
	(write_topn_counters): ... this.
	(write_one_data): Pre-allocate buffer for number of items
	in the corresponding linked lists.
	* libgcov.h (malloc_mmap): New function.
	(allocate_gcov_kvp): Use it.

gcc/testsuite/ChangeLog:

	PR gcov-profile/99105
	* gcc.dg/tree-prof/indir-call-prof-malloc.c: Use profile
	correction as the wrapped malloc is called one more time
	from libgcov.
	* gcc.dg/tree-prof/pr97461.c: Likewise.
2021-03-04 16:21:52 +01:00
Martin Liska 00d79dc4be gcov: use mmap pools for KVP.
gcc/ChangeLog:

	PR gcov-profile/97461
	* gcov-io.h (GCOV_PREALLOCATED_KVP): Remove.

libgcc/ChangeLog:

	PR gcov-profile/97461
	* config.in: Regenerate.
	* configure: Likewise.
	* configure.ac: Check sys/mman.h header file
	* libgcov-driver.c (struct gcov_kvp): Remove static
	pre-allocated pool and use a dynamic one.
	* libgcov.h (MMAP_CHUNK_SIZE): New.
	(gcov_counter_add): Use mmap to allocate pool for struct
	gcov_kvp.
2021-03-03 14:21:45 +01:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Sergei Trofimovich 4ecf368f4b gcov: fix TOPN streaming from shared libraries
Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

	PR gcov-profile/96913
	* libgcov-driver.c (write_one_data): Avoid function pointer
	comparison in TOP streaming decision.
2020-09-22 11:41:04 +01:00
Martin Liska bc2b1a232b libgcov: support overloaded malloc
gcc/ChangeLog:

	* gcov-io.h (GCOV_PREALLOCATED_KVP): New.

libgcc/ChangeLog:

	* libgcov-driver.c: Add __gcov_kvp_pool
	and __gcov_kvp_pool_index variables.
	* libgcov.h (allocate_gcov_kvp): New.
	(gcov_topn_add_value): Use it.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-prof/indir-call-prof-malloc.c: New test.
2020-07-31 10:57:50 +02:00
Martin Liska ece21ff6ea
Do not stream all zeros for gcda files.
gcc/ChangeLog:

	PR gcov-profile/95348
	* coverage.c (read_counts_file): Read only COUNTERS that are
	not all-zero.
	* gcov-dump.c (tag_function): Change signature from unsigned to
	signed integer.
	(tag_blocks): Likewise.
	(tag_arcs): Likewise.
	(tag_lines): Likewise.
	(tag_counters): Likewise.
	(tag_summary): Likewise.
	* gcov.c (read_count_file): Read all non-zero counters
	sensitively.

libgcc/ChangeLog:

	PR gcov-profile/95348
	* libgcov-driver.c (merge_one_data): Merge only profiles
	that are not of non-zero type.
	(write_one_data): Write counters only if there's one non-zero
	value.
	* libgcov-util.c (tag_function): Change signature from unsigned
	to int.
	(tag_blocks): Likewise.
	(tag_arcs): Likewise.
	(tag_counters): Likewise.
	(tag_summary): Likewise.
	(tag_lines): Read only if COUNTERS is non-zero.
	(read_gcda_file): Handle negative length for COUNTERS type.
2020-07-02 10:16:02 +02:00
Martin Liska 88891c5ff0
gcov-tool: fix merge operation for summary
libgcc/ChangeLog:

	* libgcov-driver.c (merge_summary): Remove function as its name
	is misleading and doing something different.
	(dump_one_gcov): Add ATTRIBUTE_UNUSED for 2 args. Take read summary
	in gcov-tool.
	* libgcov-util.c (curr_object_summary): Remove.
	(read_gcda_file): Remove unused curr_object_summary.
	(gcov_merge): Merge summaries.
	* libgcov.h: Add summary argument for gcov_info struct.
2020-06-25 11:27:12 +02:00
Martin Liska 862b9b225f
libgcov: fix TOPN type casting
The patch fixes tree-prof.exp tests on solaris11 and i686-linux-gnu,
problem was that sizeof of a pointer is different from sizeof gcov_type.

I'm going to install it if there are no objections.
Thanks,
Martin

libgcc/ChangeLog:

	PR gcov-profile/95494
	* libgcov-driver.c (write_top_counters): Cast first to
	intptr_t as sizeof(*) != sizeof(gcov_type).
	* libgcov.h (gcov_counter_set_if_null): Remove.
	(gcov_topn_add_value): Cast first to intptr_t and update
	linked list directly.
2020-06-09 13:07:41 +02:00
Martin Liska 871e5ada6d
Make TOPN counter dynamically allocated.
gcc/ChangeLog:

	* coverage.c (get_coverage_counts): Skip sanity check for TOP N counters
	as they have variable number of counters.
	* gcov-dump.c (main): Add new option -r.
	(print_usage): Likewise.
	(tag_counters): All new raw format.
	* gcov-io.h (struct gcov_kvp): New.
	(GCOV_TOPN_VALUES): Remove.
	(GCOV_TOPN_VALUES_COUNTERS): Likewise.
	(GCOV_TOPN_MEM_COUNTERS): New.
	(GCOV_TOPN_DISK_COUNTERS): Likewise.
	(GCOV_TOPN_MAXIMUM_TRACKED_VALUES): Likewise.
	* ipa-profile.c (ipa_profile_generate_summary): Use
	GCOV_TOPN_MAXIMUM_TRACKED_VALUES.
	(ipa_profile_write_edge_summary): Likewise.
	(ipa_profile_read_edge_summary): Likewise.
	(ipa_profile): Remove usage of GCOV_TOPN_VALUES.
	* profile.c (sort_hist_values): Sort variable number
	of counters.
	(compute_value_histograms): Special case for TOP N counters
	that have dynamic number of key-value pairs.
	* value-prof.c (dump_histogram_value): Dump variable number
	of key-value pairs.
	(stream_in_histogram_value): Stream in variable number
	of key-value pairs for TOP N counter.
	(get_nth_most_common_value): Deal with variable number
	of key-value pairs.
	(dump_ic_profile): Use GCOV_TOPN_MAXIMUM_TRACKED_VALUES
	for loop iteration.
	(gimple_find_values_to_profile): Set GCOV_TOPN_MEM_COUNTERS
	to n_counters.
	* doc/gcov-dump.texi: Document new -r option.

libgcc/ChangeLog:

	* libgcov-driver.c (prune_topn_counter): Remove.
	(prune_counters): Likewise.
	(merge_one_data): Special case TOP N counters
	as they have variable length.
	(write_top_counters): New.
	(write_one_data): Special case TOP N.
	(dump_one_gcov): Do not prune TOP N counters.
	* libgcov-merge.c (merge_topn_values_set): Remove.
	(__gcov_merge_topn): Use gcov_topn_add_value.
	* libgcov-profiler.c (__gcov_topn_values_profiler_body):
	Likewise here.
	* libgcov.h (gcov_counter_add): New.
	(gcov_counter_set_if_null): Likewise.
	(gcov_topn_add_value): New.
2020-06-02 12:11:02 +02:00
Martin Liska e9ee848dcd
Remove wrong bail out in prune_topn_counter.
* libgcov-driver.c (prune_topn_counter): Remove
	check for -1 as we only prune run-time counters
	that do not generate an invalid state.
2020-01-23 14:34:59 +01:00
Martin Liska 5f32f9cf13
Smart relaxation of TOP N counter.
PR tree-optimization/92924
	* profile.c (compute_value_histograms): Divide
	all counter values.
	PR tree-optimization/92924
	* libgcov-driver.c (prune_topn_counter): New.
	(prune_counters): Likewise.
	(dump_one_gcov): Prune a run-time counter.
	* libgcov-profiler.c (__gcov_topn_values_profiler_body):
	For a known value, add GCOV_TOPN_VALUES to value.
	Otherwise, decrement all counters by one.
2020-01-22 12:08:11 +01:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Martin Liska e37333bad7 Remove indirect call top N counter type.
2019-06-07  Martin Liska  <mliska@suse.cz>

	* doc/invoke.texi: Remove param.
	* gcov-counter.def (GCOV_COUNTER_ICALL_TOPNV):
	Remove.
	* gcov-io.h (GCOV_ICALL_TOPN_VAL): Likewise.
	(GCOV_ICALL_TOPN_NCOUNTS): Likewise.
	* params.def (PARAM_INDIR_CALL_TOPN_PROFILE): Likewise.
	* profile.c (instrument_values): Remove
	HIST_TYPE_INDIR_CALL_TOPN.
	* tree-profile.c (init_ic_make_global_vars):
	Always build __gcov_indirect_call only.
	(gimple_init_gcov_profiler): Remove usage
	of PARAM_INDIR_CALL_TOPN_PROFILE.
	(gimple_gen_ic_profiler): Likewise.
	* value-prof.c (dump_histogram_value): Likewise.
	(stream_in_histogram_value): Likewise.
	(gimple_indirect_call_to_profile): Likewise.
	(gimple_find_values_to_profile): Likewise.
	* value-prof.h (enum hist_type): Likewise.
2019-06-07  Martin Liska  <mliska@suse.cz>

	* Makefile.in: Remove usage of
	_gcov_merge_icall_topn.
	* libgcov-driver.c (gcov_sort_n_vals): Remove.
	(gcov_sort_icall_topn_counter): Likewise.
	(gcov_sort_topn_counter_arrays): Likewise.
	(dump_one_gcov): Remove call to gcov_sort_topn_counter_arrays.
	* libgcov-merge.c (__gcov_merge_icall_topn): Remove.
	* libgcov-profiler.c (__gcov_topn_value_profiler_body):
	Likewise.
	(GCOV_ICALL_COUNTER_CLEAR_THRESHOLD): Remove.
	(struct indirect_call_tuple): Remove.
	(__gcov_indirect_call_topn_profiler): Remove.
	* libgcov-util.c (__gcov_icall_topn_counter_op): Remove.
	* libgcov.h (gcov_sort_n_vals): Remove.
	(L_gcov_merge_icall_topn): Likewise.
	(__gcov_merge_icall_topn): Likewise.
	(__gcov_indirect_call_topn_profiler): Likewise.

From-SVN: r272030
2019-06-07 06:41:58 +00:00
Martin Liska d273c40a55 Update error message prefix in libgcov profiling.
2019-01-18  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c (GCOV_PROF_PREFIX): Define.
	(gcov_version): Use in gcov_error.
	(merge_one_data): Likewise.
	(dump_one_gcov): Likewise.

From-SVN: r268070
2019-01-18 11:31:45 +00:00
Martin Liska be9d9fdbed Describe better version mismatch in libgcov driver.
2019-01-18  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c (gcov_version_string): New function.
	(gcov_version): Convert version integer into string.

From-SVN: r268069
2019-01-18 11:30:56 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Martin Liska 512cc01512 Remove arc profile histogram in non-LTO mode.
2018-09-21  Martin Liska  <mliska@suse.cz>

	* auto-profile.c (autofdo_source_profile::read): Do not
	set sum_all.
	(read_profile): Do not add working sets.
	(read_autofdo_file): Remove sum_all.
	(afdo_callsite_hot_enough_for_early_inline): Remove const
	qualifier.
	* coverage.c (struct counts_entry): Remove gcov_summary.
	(read_counts_file): Read new GCOV_TAG_OBJECT_SUMMARY,
	do not support GCOV_TAG_PROGRAM_SUMMARY.
	(get_coverage_counts): Remove summary and expected
	arguments.
	* coverage.h (get_coverage_counts): Likewise.
	* doc/gcov-dump.texi: Remove -w option.
	* gcov-dump.c (dump_working_sets): Remove.
	(main): Do not support '-w' option.
	(print_usage): Likewise.
	(tag_summary): Likewise.
	* gcov-io.c (gcov_write_summary): Do not dump
	histogram.
	(gcov_read_summary): Likewise.
	(gcov_histo_index): Remove.
	(gcov_histogram_merge): Likewise.
	(compute_working_sets): Likewise.
	* gcov-io.h (GCOV_TAG_OBJECT_SUMMARY): Mark
	it not obsolete.
	(GCOV_TAG_PROGRAM_SUMMARY): Mark it obsolete.
	(GCOV_TAG_SUMMARY_LENGTH): Adjust.
	(GCOV_HISTOGRAM_SIZE): Remove.
	(GCOV_HISTOGRAM_BITVECTOR_SIZE): Likewise.
	(struct gcov_summary): Simplify rapidly just
	to runs and sum_max fields.
	(gcov_histo_index): Remove.
	(NUM_GCOV_WORKING_SETS): Likewise.
	(compute_working_sets): Likewise.
	* gcov-tool.c (print_overlap_usage_message): Remove
	trailing empty line.
	* gcov.c (read_count_file): Read GCOV_TAG_OBJECT_SUMMARY.
	(output_lines): Remove program related line.
	* ipa-profile.c (ipa_profile): Do not consider GCOV histogram.
	* lto-cgraph.c (output_profile_summary): Do not stream GCOV
	histogram.
	(input_profile_summary): Do not read it.
	(merge_profile_summaries): And do not merge it.
	(input_symtab): Do not call removed function.
	* modulo-sched.c (sms_schedule): Do not print sum_max.
	* params.def (HOT_BB_COUNT_FRACTION): Reincarnate param that was
	removed when histogram method was invented.
	(HOT_BB_COUNT_WS_PERMILLE): Mention that it's used only in LTO
	mode.
	* postreload-gcse.c (eliminate_partially_redundant_load): Fix
	GCOV coding style.
	* predict.c (get_hot_bb_threshold): Use HOT_BB_COUNT_FRACTION
	and dump selected value.
	* profile.c (add_working_set): Remove.
	(get_working_sets): Likewise.
	(find_working_set): Likewise.
	(get_exec_counts): Do not work with working sets.
	(read_profile_edge_counts): Do not inform as sum_max is removed.
	(compute_branch_probabilities): Likewise.
	(compute_value_histograms): Remove argument for call of
	get_coverage_counts.
	* profile.h: Do not make gcov_summary const.
2018-09-21  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c (crc32_unsigned): Remove.
	(gcov_histogram_insert): Likewise.
	(gcov_compute_histogram): Likewise.
	(compute_summary): Simplify rapidly.
	(merge_one_data): Do not handle PROGRAM_SUMMARY tag.
	(merge_summary): Rapidly simplify.
	(dump_one_gcov): Ignore gcov_summary.
	(gcov_do_dump): Do not handle program summary, it's not
	used.
	* libgcov-util.c (tag_summary): Remove.
	(read_gcda_finalize): Fix coding style.
	(read_gcda_file): Initialize curr_object_summary.
	(compute_summary): Remove.
	(calculate_overlap): Remove settings of run_max.

From-SVN: r264462
2018-09-21 08:41:17 +00:00
Martin Liska 244aebfd6c Fix compilation of libgcov with GCOV_LOCKED=0.
2018-06-07  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c: Rename cs_all to all and assign it from
        all_prg.

From-SVN: r261261
2018-06-07 04:23:16 +00:00
Martin Liska 6c086e8c75 Fix libgcov-driver-system bootstrap failure (PR bootstrap/86057).
2018-06-07  Martin Liska  <mliska@suse.cz>

        PR bootstrap/86057
	* libgcov-driver-system.c (replace_filename_variables): Use
        memcpy instead of mempcpy.
	(allocate_filename_struct): Do not allocate filename, allocate
        prefix and set it.
	(gcov_exit_open_gcda_file): Allocate memory for gf->filename
        here and properly copy content into it.
	* libgcov-driver.c (struct gcov_filename): Remove max_length
        field, change prefix from size_t into char *.
	(compute_summary): Do not calculate longest filename.
	(gcov_do_dump): Release memory of gf.filename after each file.
	* libgcov-util.c (compute_summary): Use new signature of
        compute_summary.
	(calculate_overlap): Likewise.

From-SVN: r261260
2018-06-07 04:21:35 +00:00
Martin Liska 7f3577f528 Simplify gcov_histogram as it's used only for ARCS counters.
2018-06-05  Martin Liska  <mliska@suse.cz>

	* auto-profile.c (read_autofdo_file): Do not use
	gcov_ctr_summary struct.
	(afdo_callsite_hot_enough_for_early_inline): Likewise.
	* coverage.c (struct counts_entry): Likewise.
	(read_counts_file): Read just single summary entry.
	(get_coverage_counts): Use gcov_summary struct.
	* coverage.h (get_coverage_counts): Likewise.
	* gcov-dump.c (dump_working_sets): Likewise.
	(tag_summary): Dump just single summary.
	* gcov-io.c (gcov_write_summary): Write just histogram
	summary.
	(gcov_read_summary): Read just single summary.
	(compute_working_sets): Use gcov_summary struct.
	* gcov-io.h (GCOV_TAG_SUMMARY_LENGTH): Remove usage
	of GCOV_COUNTERS_SUMMABLE.
	(GCOV_COUNTERS_SUMMABLE): Remove.
	(GCOV_FIRST_VALUE_COUNTER): Replace with
	GCOV_COUNTER_V_INTERVAL.
	(struct gcov_ctr_summary): Remove.
	(struct gcov_summary): Directly use fields of former
	gcov_ctr_summary.
	(compute_working_sets): Use gcov_summary struct.
	* gcov.c (read_count_file): Do not use ctrs fields.
	* lto-cgraph.c (merge_profile_summaries): Use gcov_summary
	struct.
	* lto-streamer.h (struct GTY): Make profile_info gcov_summary
	struct.
	* profile.c: Likewise.
	* profile.h: Likewise.
2018-06-05  Martin Liska  <mliska@suse.cz>

	* libgcov-driver.c (gcov_compute_histogram): Remove usage
	of gcov_ctr_summary.
	(compute_summary): Do it just for a single summary.
	(merge_one_data): Likewise.
	(merge_summary): Simplify as we read just single summary.
	(dump_one_gcov): Pass proper argument.
	* libgcov-util.c (compute_one_gcov): Simplify as we have just
	single summary.
	(gcov_info_count_all_cold): Likewise.
	(calculate_overlap): Likewise.

From-SVN: r261189
2018-06-05 08:13:31 +00:00
Martin Liska 0e8f29daae libgcov: report about a different timestamp (PR gcov-profile/85759).
2018-05-29  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/85759
	* doc/gcov.texi: Document GCOV_ERROR_FILE and GCOV_EXIT_AT_ERROR
	env variables.
2018-05-29  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/85759
	* libgcov-driver-system.c (gcov_error): Introduce usage of
        GCOV_EXIT_AT_ERROR env. variable.
	* libgcov-driver.c (merge_one_data): Print error that we
        overwrite a gcov file with a different timestamp.

From-SVN: r260895
2018-05-29 12:11:21 +00:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Martin Liska 6397118495 Validate that destination gcov file does not exist for gcov-tool (PR gcov-profile/78783).
2017-04-18  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78783
	* libgcov-driver.c (gcov_get_filename): New function.
2017-04-18  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78783
	* gcov-tool.c (gcov_output_files): Validate that destination
	file is either removed by the tool or by a user.

From-SVN: r246961
2017-04-18 07:24:20 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Martin Liska 8c9434c2f9 gcov: dump in a static dtor instead of in an atexit handler
PR gcov-profile/7970
	PR gcov-profile/16855
	PR gcov-profile/44779
	* g++.dg/gcov/pr16855.C: New test.
	* coverage.c (build_gcov_exit_decl): New function.
	(coverage_obj_init): Call the function and generate __gcov_exit
	destructor.
	* doc/gcov.texi: Document when __gcov_exit function is called.
	* libgcov-driver.c (__gcov_init): Do not register a atexit
	handler.
	(__gcov_exit): Rename from gcov_exit.
	* libgcov.h (__gcov_exit): Declare.

From-SVN: r240529
2016-09-27 11:07:11 +00:00
Aaron Conole 8aa5bdd61e On behalf of Aaron Conole <aconole@redhat.com>
On behalf of  Aaron Conole  <aconole@redhat.com>
	* libgcov-driver-system.c (__gcov_error_file): New.
	(get_gcov_error_file): New.
	(gcov_error): Use and set __gcov_error_file.
	(gcov_error_exit): New.
	* libgcov-driver.c (gcov_exit): Call gcov_error_exit.

From-SVN: r237033
2016-06-02 12:22:01 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Rong Xu 9b84e7a836 Add overlap functionality to gcov-tool.
2014-10-08  Rong Xu  <xur@google.com>

	* gcc/gcov-tool.c (profile_overlap): New driver function
        to compute profile overlap. 
	(print_overlap_usage_message): New.
	(overlap_usage): New.
	(do_overlap): New.
	(print_usage): Add calls to overlap function.
	(main): Ditto.
	* libgcc/libgcov-util.c (read_gcda_file): Fix format.
	(find_match_gcov_info): Ditto.
	(calculate_2_entries): New.
	(compute_one_gcov): Ditto.
	(gcov_info_count_all_cold): Ditto.
	(gcov_info_count_all_zero): Ditto.
	(extract_file_basename): Ditto.
	(get_file_basename): Ditto.
	(set_flag): Ditto.
	(matched_gcov_info): Ditto.
	(calculate_overlap): Ditto.
	(gcov_profile_overlap): Ditto.
	* libgcc/libgcov-driver.c (compute_summary): Make
        it avavilable for external calls.
	* gcc/doc/gcov-tool.texi: Add documentation.

From-SVN: r216015
2014-10-08 21:51:41 +00:00
Rong Xu afe0c5ee91 Makefile.in: Fix dependence.
2014-10-06  Rong Xu  <xur@google.com>

	* gcc/Makefile.in: Fix dependence.
	* gcc/gcov-counter.def (GCOV_COUNTER_ICALL_TOPNV): Add
        indirect call topn profiler.
	* gcc/gcov-io.h: Ditto.
	* libgcc/Makefile.in: Ditto.
	* libgcc/libgcov-driver.c (gcov_sort_n_vals): New utility function.
	(gcov_sort_icall_topn_counter): Ditto.
	(gcov_sort_topn_counter_arrays): Ditto.
	(dump_one_gcov): Sort indirect_call topn counters.
	* libgcc/libgcov-merge.c (__gcov_merge_icall_topn): New merge
        function.
	* libgcc/libgcov-profiler.c (__gcov_topn_value_profiler_body): New
        utility function.
	(__gcov_indirect_call_topn_profiler): New profiler function.
	* libgcc/libgcov-util.c (__gcov_icall_topn_counter_op): New.
	* libgcc/libgcov.h: New decls.

From-SVN: r215962
2014-10-07 04:02:31 +00:00
Nathan Sidwell cadb2b9689 Makefile.in (LIBGCOV_INTERFACE): Add _gcov_dump from ...
* Makefile.in (LIBGCOV_INTERFACE): Add _gcov_dump from ...
	(LIBGCOV_DRIVER): ... here.
	* libgcov-driver.c (gcov_master): New.
	(gcov_exit): Remove from master chain.
	(__gcov_init): Add to master chain if version compatible.  Don't
	clear the version.
	* libgcov_interface (__gcov_flust): Call gcov_dump_int.
	(gcov_reset_int): Clear master chain, if compatible.
	(gcov_dump_int): New internal interface.  Dump master chain, if
	compatible.
	(gcov_dump): Alias for gcov_dump_int.
	* libgcov.h (struct gcov_root): Add next and prev fields.
	(struct gcov_master): New struct.
	(__gcov_master): New.
	(gcov_dump_int): Declare.

From-SVN: r215337
2014-09-17 20:13:17 +00:00
Nathan Sidwell 4303c58196 Makefile.in (LIBGCOV_INTERFACE): Move _gcov_dump ...
* Makefile.in (LIBGCOV_INTERFACE): Move _gcov_dump ...
	(LIBGCOV_DRIVER): ... to here.
	* libgcov.h (gcov_do_dump): New #define.
	(struct gcov_root): New.
	(__gcov_root): New declaration.
	(__gcov_dump_one): Declare.
	* libgcov-driver.c (gcov_list, gcov_dump_complete,
	run_accounted): Delete.
	(gcov_compute_histogram): Add LIST argument, adjust.
	(compute_summary): Adjust gcov_compute_histogram call.
	(gcov_do_dump): Not hidden, static in libgcov.
	(gcov_clear): Move  to interface.c.
	(__gcov_dump_one): New, broken out of ...
	(gcov_exit): ... here.  Make static.
	(__gcov_root): New.
	(__gcov_init): Adjust.
	* libgcov-interface.c (gcov_clear, gcov_exit): Remove
	declarations.
	(__gcov_flush): Use __gcov_dump_one and __gcov_reset.
	(gcov_clear): Moved from driver.c.   Add LIST argument.
	(__gcov_reset): Adjust for changed interfaces.
	(__gcov_fork): Remove local declaration of __gcov_flush_mx.

From-SVN: r213719
2014-08-07 18:02:06 +00:00
Nathan Sidwell b98a872b22 Makefile.in (LIBGCOV_MERGE, [...]): Reformat.
* Makefile.in (LIBGCOV_MERGE, LIBGCOV_PROFILER,
	LIBGCOV_INTERFACE): Reformat.
	* libgcov-driver.c (gcov_exit, __gcov_init): Disable when
	IN_GCOV_TOOL.
	* libgcov-interface.c: Reformat some comments.
	(__gcov_flush_mx): Add declaration.  Tidy up definition.

From-SVN: r213442
2014-08-01 10:05:42 +00:00
Nathan Sidwell 1992616143 libgcov.h: Move renaming of entry points to lib gcov specific portion.
libgcc/
	* libgcov.h: Move renaming of entry points to lib gcov specific
	portion.
	(gcov_do_dump): New rename.
	(gcov_rewrite): Remove inline, make HIDDEN.
	* libgcov-driver.c (gcov_clear, gcov_exit): Remove declarations.
	(gcov_exit_compute_summary): Rename to ...
	(compute_summary): ... here.  Add LIST argument.
	(gcov_exit_merge_gcda): Rename to ...
	(merge_one_data): ... here.
	(gcov_exit_write_gcda): Rename to ...
	(write_one_data): ... here.
	(gcov_exit_merge_summary): Rename to ...
	(merge_summary): Add RUN_COUNTED argument.
	(gcov_exit_dump_gcov): Rename to ...
	(dump_one_gcov): Add RUN_COUNTED argument.
	(gcov_do_dump): New function, broken out of ...
	(gcov_exit): ... here.  Call it.

	gcc/
	* gcov-io.c (gcov_var): Make hidden.
	* gcov-tool.c (gcov_list, gcov_exit): Remove declarations.
	(gcov_do_dump): Declare.
	(gcov_output_files): Call gcov_do_dump, not gcov_exit).

From-SVN: r213188
2014-07-29 13:48:38 +00:00
Nathan Sidwell 6dc33097cc libgcov-driver.c (struct gcov_filename_aux): Rename ...
* libgcov-driver.c (struct gcov_filename_aux): Rename ...
	(struct gcov_filename): ... here.  Include buffer and max length
	fields.
	(gcov_max_filename): Remove.
	(gi_filename): Remove.
	(gcov_exit_compute_summary): Compute max filename here.
	(gcov_exit_merge_gcda): Add filename parm, adjust.
	(gcov_exit_merge_summary): Likewise.
	(gcov_exit_dump_gcov): Adjust for struct gcov_filename changes.
	(gcov_exit): Likewise.
	(__gcov_init): Don't calculate max length here.
	* libgcov_util.c (max_filename_len): Remove.
	(read_gcda_file): Don't calculate max length here.
	(gcov_read_profile_dir): Don't propagate here.
	* libgcov-driver-system.c (alloc_filename_struct): Adjust for
	struct gcov_filename changes.
	(gcov_exit_open_gcda_file): Likewise.

From-SVN: r213092
2014-07-27 07:22:47 +00:00
Nathan Sidwell 770f687ddb libgcov-driver.c (set_gcov_dump_complete, [...]): Remove global functions polluting user's namespace.
* libgcov-driver.c (set_gcov_dump_complete,
	reset_gcov_dump_complete, get_gcov_dump_complete): Remove global
	functions polluting user's namespace.
	(gcov_exit): Set variable directly.
	(gcov_clear): Reset variable directly.
	* libgcov-interface.c (get_gcov_dymp_complete,
	reset_gov_dump_complete): Remove declarations.
	(__gcov_reset, __gcov_dump): Don't call them.

From-SVN: r213058
2014-07-25 15:02:17 +00:00
Nathan Sidwell d10ee722fd gcov-tool.c (gcov_list): Declare here.
gcc/
	* gcov-tool.c (gcov_list): Declare here.
	(set_gcov_list): Remove.
	(gcov_output_files): Set gcov_list directly.

	libgcc/
	* libgcov-driver.c (set_gcov_list): Remove.
	(gcov_list): Make non-static in GCOV_TOOL.
	* libgcov.h (GCOV_TOOL_LINKAGE): Remove unused #define.

From-SVN: r212931
2014-07-23 12:08:31 +00:00
Rong Xu c77556a5d1 Add gcov-tool: an offline gcda profile processing tool Support.
2014-07-10  Rong Xu  <xur@google.com>

	Add gcov-tool: an offline gcda profile processing tool
	Support.
	* gcc/gcov-io.c (gcov_position): Make avaialble to gcov-tool.
	(gcov_is_error): Ditto.
	(gcov_read_string): Ditto.
	(gcov_read_sync): Ditto.
	* gcc/gcov-io.h: Move counter defines to gcov-counter.def.
	* gcc/gcov-dump.c (tag_counters): Use gcov-counter.def.
	* gcc/coverage.c: Ditto.
	* gcc/gcov-tool.c: Offline gcda profile processing tool.
        (unlink_gcda_file): Remove one gcda file.
	(unlink_profile_dir): Remove gcda files from the profile path.
	(gcov_output_files): Output gcda files to an output dir.
	(profile_merge): Merge two profiles in directory.
	(print_merge_usage_message): Print merge usage.
	(merge_usage): Print merge usage and exit.
	(do_merge): Driver for profile merge sub-command.
	(profile_rewrite): Rewrite profile.
	(print_rewrite_usage_message): Print rewrite usage.
	(rewrite_usage): Print rewrite usage and exit.
	(do_rewrite): Driver for profile rewrite sub-command.
	(print_usage): Print gcov-info usage and exit.
	(print_version): Print gcov-info version.
	(process_args): Process arguments.
	(main): Main routine for gcov-tool.
	* gcc/Makefile.in: Build and install gcov-tool.
	* gcc/gcov-counter.def: New file split from gcov-io.h.
	* libgcc/libgcov-driver.c (gcov_max_filename): Make available
        to gcov-tool.
	* libgcc/libgcov-merge.c (__gcov_merge_add): Replace
        gcov_read_counter() with a Macro.
	(__gcov_merge_ior): Ditto.
	(__gcov_merge_time_profile): Ditto.
	(__gcov_merge_single): Ditto.
	(__gcov_merge_delta): Ditto.
	* libgcc/libgcov-util.c (void gcov_set_verbose): Set the verbose flag
        in the utility functions.
	(set_fn_ctrs): Utility function for reading gcda files to in-memory
        gcov_list object link lists.
	(tag_function): Ditto.
	(tag_blocks): Ditto.
	(tag_arcs): Ditto.
	(tag_lines): Ditto.
	(tag_counters): Ditto.
	(tag_summary): Ditto.
	(read_gcda_finalize): Ditto.
	(read_gcda_file): Ditto.
	(ftw_read_file): Ditto.
	(read_profile_dir_init): Ditto.
	(gcov_read_profile_dir): Ditto.
	(gcov_read_counter_mem): Ditto.
	(gcov_get_merge_weight): Ditto.
	(merge_wrapper): A wrapper function that calls merging handler.
	(gcov_merge): Merge two gcov_info objects with weights.
	(find_match_gcov_info): Find the matched gcov_info in the list.
	(gcov_profile_merge): Merge two gcov_info object lists.
	(__gcov_add_counter_op): Process edge profile counter values.
	(__gcov_ior_counter_op): Process IOR profile counter values.
	(__gcov_delta_counter_op): Process delta profile counter values.
	(__gcov_single_counter_op): Process single  profile counter values.
	(fp_scale): Callback function for float-point scaling.
	(int_scale): Callback function for integer fraction scaling. 
	(gcov_profile_scale): Scaling profile counters.
	(gcov_profile_normalize): Normalize profile counters.
	* libgcc/libgcov.h: Add headers and functions for gcov-tool use.
        (gcov_get_counter): New.
        (gcov_get_counter_target): Ditto.
        (struct gcov_info): Make the functions field mutable in gcov-tool
        compilation.
	* gcc/doc/gcc.texi: Include gcov-tool.texi.
	* gcc/doc/gcov-tool.texi: Document for gcov-tool.

From-SVN: r212448
2014-07-11 05:48:07 +00:00
Teresa Johnson e3f0315f88 gcov-io.c (gcov_position): Use gcov_nonruntime_assert.
2014-05-22  Teresa Johnson  <tejohnson@google.com>

	* gcov-io.c (gcov_position): Use gcov_nonruntime_assert.
	(gcov_is_error): Remove gcc_assert from IN_LIBGCOV code.
	(gcov_rewrite): Use gcov_nonruntime_assert.
	(gcov_open): Ditto.
	(gcov_write_words): Ditto.
	(gcov_write_length): Ditto.
	(gcov_read_words): Use gcov_nonruntime_assert, and remove
	gcc_assert from IN_LIBGCOV code.
	(gcov_read_summary): Use gcov_error to flag profile corruption.
	(gcov_sync): Use gcov_nonruntime_assert.
	(gcov_seek): Remove gcc_assert from IN_LIBGCOV code.
	(gcov_histo_index): Use gcov_nonruntime_assert.
	(static void gcov_histogram_merge): Ditto.
	(compute_working_sets): Ditto.
	* gcov-io.h (gcov_nonruntime_assert): Define.
	(gcov_error): Define for !IN_LIBGCOV


	* libgcov-driver.c (gcov_error): Move declaration before gcov-io.c
	include.

From-SVN: r210805
2014-05-22 14:06:08 +00:00