Commit Graph

9 Commits

Author SHA1 Message Date
Teresa Johnson 4e8ee9cbf7 This patch adds functionality to libgcov to enable user applications to collect...
This patch adds functionality to libgcov to enable user applications to
collect profile data only in regions of interest. This is useful, for
example, to collect profile data from a long-running server only
during the time when it is serving requests.

Specifically, the new routines __gcov_reset will clear all profile counters
to zero and __gcov_dump will write out the profile information collected so
far. A global variable is used to prevent writing out the profile a
second time during exit.

2012-05-08   Teresa Johnson  <tejohnson@google.com>

	* libgcc/libgcov.c (gcov_clear, __gcov_reset): New functions.
	(__gcov_dump): Ditto.
	(gcov_dump_complete): New global variable.
	(gcov_exit): Export hidden to enable use in L_gcov_dump.
	(__gcov_flush): Outline functionality now in gcov_clear.
	* libgcc/Makefile.in (L_gcov_reset, L_gcov_dump): Define.
	* gcc/gcov-io.h (__gcov_reset, __gcov_dump): Declare.
	* gcc/doc/gcov.texi: Add note on using __gcov_reset and __gcov_dump.

From-SVN: r187297
2012-05-08 21:22:28 +00:00
Richard Guenther b260a8c034 re PR gcov-profile/52627 (Build of libgcc fails w/o __GTHREAD_MUTEX_INIT: error: 'mx' undeclared)
2012-03-20  Richard Guenther  <rguenther@suse.de>

	PR gcov-profile/52627
	* libgcov.c (init_mx): Fix mutex name.

From-SVN: r185569
2012-03-20 11:18:57 +00:00
Richard Guenther 5bef73a14e libgcov.c: Remove stdio.h include and NULL un-define.
2012-03-13  Richard Guenther  <rguenther@suse.de>

	* libgcov.c: Remove stdio.h include and NULL un-define.

From-SVN: r185324
2012-03-13 10:18:38 +00:00
Richard Guenther 33e3e24d74 re PR gcov-profile/49484 (gcov crash if two(or more) forks happen at the same time)
2012-03-12  Richard Guenther  <rguenther@suse.de>

	* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
	* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
	(__gthread_mutex_init_function): New function.
	* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.

	PR gcov/49484
	* libgcov.c: Include gthr.h.
	(__gcov_flush_mx): New global variable.
	(init_mx, init_mx_once): New functions.
	(__gcov_flush): Protect self with a mutex.
	(__gcov_fork): Re-initialize mutex after forking.
	* unwind-dw2-fde.c: Change condition under which to use
	__GTHREAD_MUTEX_INIT_FUNCTION.

From-SVN: r185231
2012-03-12 14:23:27 +00:00
Nathan Sidwell 2cd8b32cb9 * libgcov.c (__gcov_init): Ignore objects with no functions.
From-SVN: r183103
2012-01-11 18:50:21 +00:00
Nathan Sidwell 04dbc287a6 libgcov.c (gcov_crc32): Remove global var.
* libgcov.c (gcov_crc32): Remove global var.
	(free_fn_data): New function.
	(buffer_fn_data): Pass in filename, more robust error recovery.
	(crc32_unsigned): New function.
	(gcov_exit): More robust detection of new program. More robust
	error recovery.
	(__gcov_init): Do not update program's crc here.

From-SVN: r182743
2011-12-30 18:08:56 +00:00
Nathan Sidwell 5366b18679 libgcov.c (struct gcov_fn_buffer): New struct.
libgcc/
	* libgcov.c (struct gcov_fn_buffer): New struct.
	(buffer_fn_data): New helper.
	(gcov_exit): Rework for new gcov data structures.

	gcc/
	* gcov.c (object_summary): Replace with ...
	(object_runs): ... this.
	(process_file): Remove functions with no data.
	(generate_results): Ignore files with no lines.
	(release_function): New helper, broken out of ...
	(release_structures): ... here.  Use it.
	(read_count_file): Adjust for new data file format.
	(output_lines): Use object_runs.
	* gcov-io.h (GCOV_TAG_OBJECT_SUMMARY): Obsolete.
	(struct gcov_ctr_info): Move definition.
	(struct gcov_fn_info): Add key field, use gcov_ctr_info for
	trailing array.
	(struct gcov_info): Add merge function array, remove mask and
	counts.  Trailing array is array of pointers to function info.
	* coverage.c (struct function_list): Replace counter numbers with
	counter arrays.  Add fndecl field.  GTYify.
	(counts_entry): Remove chain workspace.
	(functions_head): GTYify.
	(prg_n_ctrs): Remove.
	(fn_v_ctrs): New.
	(tree_ctr_tables): Remove.
	(read_counts_file): Cope with blank entries and expect program
	summaries before functions.  Don't warn on missing entries.
	(coverage_counter_alloc): Allocate individual function arrays.
	(tree_coverage_counter_ref, tree_coverage_counter_addr): Adjust
	for individual function arrays.
	(coverage_end_function): GTYify function list object. Finalize
	function's counter arrays.
	(build_var): New.  Create a counter-related variable with
	appropriate linkage.
	(build_fn_info_type): Adjust for new runtime structure.
	(build_fn_info_value): Rename to ...
	(build_fn_info): ... here.  Build new format data.
	(build_ctr_info_type, build_ctr_info_value): Remove.
	(build_info_type): New. Build new format data structure.
	(build_info): Adjust for new format data.
	(create_coverage): Likewise.
	* gcov-dump.c (tag_function): Recognize placeholders.

	gcc/testsuite/
	* gcc.dg/profile-dir-1.c: Adjust final scan.
	* gcc.dg/profile-dir-2.c: Adjust final scan.
	* gcc.dg/profile-dir-3.c: Adjust final scan.
	* gcc.misc-tests/gcov.exp: Adjust regexp.
	* gcc.misc-tests/gcov-12.c: New.
	* gcc.misc-tests/gcov-13.c: New.
	* gcc.misc-tests/gcovpart-13b.c: New.
	* gcc.misc-tests/gcov-14.c: New.

From-SVN: r181105
2011-11-07 18:14:46 +00:00
Rainer Orth 852b75ed97 Move libgcc_tm_file to toplevel libgcc
gcc:
	* configure.ac (libgcc_tm_file_list, libgcc_tm_include_list):
	Remove.
	* configure: Regenerate.
	* Makefile.in (libgcc_tm_file_list, libgcc_tm_include_list): Remove.
	(TM_H): Remove libgcc_tm.h, $(libgcc_tm_file_list).
	(libgcc_tm.h, cs-libgcc_tm.h): Remove.
	(clean): Remove libgcc_tm.h
	* mkconfig.sh: Don't include libgcc_tm.h in tm.h.
	* config.gcc (libgcc_tm_file): Remove.
	(arm*-*-linux*): Remove libgcc_tm_file for arm*-*-linux-*eabi.
	(arm*-*-uclinux*): Remove libgcc_tm_file for arm*-*-uclinux*eabi.
	(arm*-*-eabi*, arm*-*-symbianelf*): Remove libgcc_tm_file.
	(avr-*-rtems*): Likewise.
	(avr-*-*): Likewise.
	(frv-*-elf): Likewise.
	(frv-*-*linux*): Likewise.
	(h8300-*-rtems*): Likewise.
	(h8300-*-elf*): Likewise.
	(i[34567]86-*-darwin*): Likewise.
	(x86_64-*-darwin*): Likewise.
	(rx-*-elf*): Likewise.
	(tic6x-*-elf): Likewise.
	(tic6x-*-uclinux): Likewise.
	(i[34567]86-*-linux*, x86_64-*-linux*): Likewise.

	libgcc:
	* configure.ac (tm_file_): New variable.
	Determine from tm_file.
	(tm_file, tm_defines): Substitute.
	* configure: Regenerate.
	* mkheader.sh: New file.
	* Makefile.in (clean): Remove libgcc_tm.h.
	($(objects)): Depend on libgcc_tm.h.
	(libgcc_tm_defines, libgcc_tm_file): New variables.
	(libgcc_tm.h, libgcc_tm.stamp): New targets.
	($(libgcc-objects), $(libgcc-s-objects), $(libgcc-eh-objects))
	($(libgcov-objects), $(libunwind-objects), $(libunwind-s-objects))
	($(extra-parts)): Depend on libgcc_tm.h.
	* config.host (tm_defines, tm_file): New variable.
	(arm*-*-linux*): Set tm_file for arm*-*-linux-*eabi.
	(arm*-*-uclinux*): Set tm_file for arm*-*-uclinux*eabi.
	(arm*-*-eabi*, arm*-*-symbianelf*): Set tm_file.
	(avr-*-rtems*): Likewise.
	(avr-*-*): Likewise.
	(frv-*-elf): Likewise.
	(frv-*-*linux*): Likewise.
	(h8300-*-rtems*): Likewise.
	(h8300-*-elf*): Likewise.
	(i[34567]86-*-darwin*): Likewise.
	(x86_64-*-darwin*): Likewise.
	(rx-*-elf): Likewise.
	(tic6x-*-uclinux): Likewise.
	(tic6x-*-elf): Likewise.
	(i[34567]86-*-linux*, x86_64-*-linux*): Likewise.
	* config/alpha/gthr-posix.c: Include libgcc_tm.h.
	* config/i386/cygming-crtbegin.c: Likewise.
	* config/i386/cygming-crtend.c: Likewise.
	* config/ia64/fde-vms.c: Likewise.
	* config/ia64/unwind-ia64.c: Likewise.
	* config/libbid/bid_gcc_intrinsics.h: Likewise.
	* config/rs6000/darwin-fallback.c: Likewise.
	* config/stormy16/lib2funcs.c: Likewise.
	* config/xtensa/unwind-dw2-xtensa.c: Likewise.
	* crtstuff.c: Likewise.
	* dfp-bit.h: Likewise.
	* emutls.c: Likewise.
	* fixed-bit.c: Likewise.
	* fp-bit.c: Likewise.
	* generic-morestack-thread.c: Likewise.
	* generic-morestack.c: Likewise.
	* libgcc2.c: Likewise.
	* libgcov.c: Likewise.
	* unwind-dw2-fde-dip.c: Likewise.
	* unwind-dw2-fde.c: Likewise.
	* unwind-dw2.c: Likewise.
	* unwind-sjlj.c: Likewise.

Co-Authored-By: Paolo Bonzini <bonzini@gnu.org>

From-SVN: r180775
2011-11-02 15:26:35 +00:00
Rainer Orth 2c50b2c366 Makefile.in (LIBGCOV): Remove.
gcc:
	* Makefile.in (LIBGCOV): Remove.
	(libgcc.mvars): Remove LIBGCOV.
	* libgov.c: Move to ../libgcc.

	libgcc:
	* Makfile.in (LIBGCOV): New variable.
	($(libgcov-objects)): Use $(srcdir) to refer to libgcov.c.
	* libgcov.c: New file.

From-SVN: r176037
2011-07-08 11:43:54 +00:00