From 42fa384f7f1d12e02987b17d2650e2136b38fa00 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 6 Jul 2003 14:51:48 +0000 Subject: * gcov-io.h: Add a local time stamp. (struct gcov_info): Add stamp field. (gcov_truncate): New. * coverage.c (read_counts_file): Skip the stamp. (coverage_begin_output): Write the stamp. (build_gcov_info): Declare and init the stamp. (coverage_finish): Only unlink data file, if stamp is zero. * gcov-dump.c (dump_file): Dump the stamp. * gcov.c (bbg_stamp): New. (release_structures): Clear bbg_stamp. (read_graph_file): Read stamp. (read_count_file): Check stamp. * libgcov.c (gcov_exit): Check stamp and truncate if needed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69006 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/libgcov.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'gcc/libgcov.c') diff --git a/gcc/libgcov.c b/gcc/libgcov.c index 74d830dc1b0..72126466f66 100644 --- a/gcc/libgcov.c +++ b/gcc/libgcov.c @@ -167,8 +167,10 @@ gcov_exit (void) gcov_unsigned_t tag, length; gcov_position_t summary_pos = 0; - /* Totals for this object file. */ memset (&this_object, 0, sizeof (this_object)); + memset (&object, 0, sizeof (object)); + + /* Totals for this object file. */ for (t_ix = c_ix = 0, ci_ptr = gi_ptr->counts, cs_ptr = this_object.ctrs; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++, cs_ptr++) @@ -223,6 +225,15 @@ gcov_exit (void) gcov_version_mismatch (gi_ptr, length); goto read_fatal; } + + length = gcov_read_unsigned (); + if (length != gi_ptr->stamp) + { + /* Read from a different compilation. Overwrite the + file. */ + gcov_truncate (); + goto rewrite; + } /* Merge execution counts for each function. */ for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; @@ -298,8 +309,6 @@ gcov_exit (void) rewrite:; gcov_rewrite (); } - else - memset (&object, 0, sizeof (object)); if (!summary_pos) memset (&program, 0, sizeof (program)); @@ -355,6 +364,7 @@ gcov_exit (void) /* Write out the data. */ gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION); + gcov_write_unsigned (gi_ptr->stamp); /* Write execution counts for each function. */ for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--; -- cgit v1.2.1