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
This commit is contained in:
Nathan Sidwell 2014-08-07 18:02:06 +00:00 committed by Nathan Sidwell
parent 8bd8ef50e4
commit 4303c58196
5 changed files with 97 additions and 70 deletions

View file

@ -42,8 +42,7 @@ void __gcov_dump (void) {}
#else
extern void gcov_clear (void) ATTRIBUTE_HIDDEN;
extern void gcov_exit (void) ATTRIBUTE_HIDDEN;
extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
#ifdef L_gcov_flush
@ -77,8 +76,8 @@ __gcov_flush (void)
init_mx_once ();
__gthread_mutex_lock (&__gcov_flush_mx);
gcov_exit ();
gcov_clear ();
__gcov_dump_one (&__gcov_root);
__gcov_reset ();
__gthread_mutex_unlock (&__gcov_flush_mx);
}
@ -87,31 +86,61 @@ __gcov_flush (void)
#ifdef L_gcov_reset
/* Reset all counters to zero. */
static void
gcov_clear (const struct gcov_info *list)
{
const struct gcov_info *gi_ptr;
for (gi_ptr = list; gi_ptr; gi_ptr = gi_ptr->next)
{
unsigned f_ix;
for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
{
unsigned t_ix;
const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix];
if (!gfi_ptr || gfi_ptr->key != gi_ptr)
continue;
const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
{
if (!gi_ptr->merge[t_ix])
continue;
memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
ci_ptr++;
}
}
}
}
/* Function that can be called from application to reset counters to zero,
in order to collect profile in region of interest. */
void
__gcov_reset (void)
{
gcov_clear ();
gcov_clear (__gcov_root.list);
__gcov_root.dumped = 0;
}
#endif /* L_gcov_reset */
#ifdef L_gcov_dump
/* Function that can be called from application to write profile collected
so far, in order to collect profile in region of interest. */
void
__gcov_dump (void)
{
gcov_exit ();
__gcov_dump_one (&__gcov_root);
}
#endif /* L_gcov_dump */
#ifdef L_gcov_fork
/* A wrapper for the fork function. Flushes the accumulated profiling data, so
that they are not counted twice. */
@ -120,7 +149,6 @@ pid_t
__gcov_fork (void)
{
pid_t pid;
extern __gthread_mutex_t __gcov_flush_mx;
__gcov_flush ();
pid = fork ();
if (pid == 0)