diff options
author | Nathan Sidwell <nathan@acm.org> | 2014-08-07 18:02:06 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2014-08-07 18:02:06 +0000 |
commit | 4303c581960b6069e8893d88da5461d9286c37e8 (patch) | |
tree | 96f601ae4d1e3bbc82671ac85806d78d72ba85a0 /libgcc/libgcov-interface.c | |
parent | 8bd8ef50e46874632c6cbd5f1446f7a6712f979c (diff) | |
download | gcc-4303c581960b6069e8893d88da5461d9286c37e8.zip gcc-4303c581960b6069e8893d88da5461d9286c37e8.tar.gz gcc-4303c581960b6069e8893d88da5461d9286c37e8.tar.bz2 |
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
Diffstat (limited to 'libgcc/libgcov-interface.c')
-rw-r--r-- | libgcc/libgcov-interface.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/libgcc/libgcov-interface.c b/libgcc/libgcov-interface.c index d4a7f50..f73666c 100644 --- a/libgcc/libgcov-interface.c +++ b/libgcc/libgcov-interface.c @@ -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) |