diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-07-09 12:12:29 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-07-09 12:12:29 +0000 |
commit | 160e2e4f2361da06d8cd73afea7b527b29d4c6a7 (patch) | |
tree | 5a33b5396c3ed82380adfbc9d86b6c3c8ad3bb59 /gcc/libgcov.c | |
parent | 83599948cd3ebd43bccc33de73edda68cb48d354 (diff) | |
download | gcc-160e2e4f2361da06d8cd73afea7b527b29d4c6a7.zip gcc-160e2e4f2361da06d8cd73afea7b527b29d4c6a7.tar.gz gcc-160e2e4f2361da06d8cd73afea7b527b29d4c6a7.tar.bz2 |
gcov-io.h: Update documentation.
* gcov-io.h: Update documentation.
(GCOV_GRAPH_SUFFIX, GCOV_GRAPH_MAGIC): Rename to GCOV_NOTE_SUFFIX,
GCOV_NOTE_MAGIC.
(GCOV_DATA_SUFFIX, GCOV_NOTE_SUFFIX): Update.
(GCOV_DATA_MAGIC, GCOV_NOTE_MAGIC): Make non-palindromic.
(struct gcov_var): Change buffer's type. Add endian flag.
(gcov_open): Remove mode in libgcov.
(gcov_magic): Prototype.
* gcov-io.c (from_file): New.
(gcov_open): Clear endian flag.
(gcov_magic): New.
(gcov_write_bytes, gcov_read_bytes): Return gcov_unsigned_t
pointers.
(gcov_write_unsigned, gcov_write_counter, gcov_write_string,
gcov_write_tag, gcov_write_length, gcov_write_tag_length): Update.
(gcov_read_unsigned, gcov_read_counter, gcov_read_string): Update.
* gcov-iov.c (main): Correct cast.
* coverage.c (read_counts_file): Use gcov_magic. Remove endianness
conversion.
(gcov_begin_output): Use GCOV_NOTE_MAGIC.
(coverage_init): Use GCOV_NOTE_SUFFIX.
* libgcov.c (gcov_version_mismatch): Remove endianness conversion.
Rename to gcov_version, and return flag.
(gcov_exit): Use gcov_version.
(__gcov_init): Use gcov_version.
* Makefile.in (coverageexts): Update.
* gcov.c (print_version): Remove endianness conversion.
(create_file_names): Use GCOV_NOTE_SUFFIX.
(read_graph_file): Use gcov_magic.
(read_count_file): Likewise.
* gcov-dump.c (dump_file): Remove endianness conversion, use
gcov_magic.
From-SVN: r69137
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r-- | gcc/libgcov.c | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c index 7212646..826617f 100644 --- a/gcc/libgcov.c +++ b/gcc/libgcov.c @@ -91,22 +91,19 @@ static struct gcov_info *gcov_list; object file included in multiple programs. */ static gcov_unsigned_t gcov_crc32; -static void -gcov_version_mismatch (struct gcov_info *ptr, gcov_unsigned_t version) +static int +gcov_version (struct gcov_info *ptr, gcov_unsigned_t version) { gcov_unsigned_t expected = GCOV_VERSION; - unsigned ix; - char e[4], v[4]; - for (ix = 4; ix--; expected >>= 8, version >>= 8) + if (version != GCOV_VERSION) { - e[ix] = expected; - v[ix] = version; + fprintf (stderr, + "profiling:%s:Version mismatch - expected %.4s got %.4s\n", + ptr->filename, (const char *)&expected, (const char *)&version); + return 0; } - - fprintf (stderr, - "profiling:%s:Version mismatch - expected %.4s got %.4s\n", - ptr->filename, e, v); + return 1; } /* Dump the coverage counts. We merge with existing counts when @@ -163,7 +160,6 @@ gcov_exit (void) struct gcov_ctr_summary *cs_ptr; struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all; int error = 0; - int merging; gcov_unsigned_t tag, length; gcov_position_t summary_pos = 0; @@ -200,18 +196,17 @@ gcov_exit (void) fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1); } - /* Open for modification, if possible */ - merging = gcov_open (gi_ptr->filename, 0); - if (!merging) + if (!gcov_open (gi_ptr->filename)) { fprintf (stderr, "profiling:%s:Cannot open\n", gi_ptr->filename); continue; } - - if (merging > 0) + + tag = gcov_read_unsigned (); + if (tag) { /* Merge data from file. */ - if (gcov_read_unsigned () != GCOV_DATA_MAGIC) + if (tag != GCOV_DATA_MAGIC) { fprintf (stderr, "profiling:%s:Not a gcov data file\n", gi_ptr->filename); @@ -220,11 +215,8 @@ gcov_exit (void) continue; } length = gcov_read_unsigned (); - if (length != GCOV_VERSION) - { - gcov_version_mismatch (gi_ptr, length); - goto read_fatal; - } + if (!gcov_version (gi_ptr, length)) + goto read_fatal; length = gcov_read_unsigned (); if (length != gi_ptr->stamp) @@ -299,16 +291,17 @@ gcov_exit (void) goto rewrite; } } - if (!gcov_is_eof ()) - { - read_error:; - fprintf (stderr, error < 0 ? "profiling:%s:Overflow merging\n" - : "profiling:%s:Error merging\n", gi_ptr->filename); - goto read_fatal; - } - rewrite:; - gcov_rewrite (); } + + if (!gcov_is_eof ()) + { + read_error:; + fprintf (stderr, error < 0 ? "profiling:%s:Overflow merging\n" + : "profiling:%s:Error merging\n", gi_ptr->filename); + goto read_fatal; + } + rewrite:; + gcov_rewrite (); if (!summary_pos) memset (&program, 0, sizeof (program)); @@ -414,9 +407,7 @@ __gcov_init (struct gcov_info *info) { if (!info->version) return; - if (info->version != GCOV_VERSION) - gcov_version_mismatch (info, info->version); - else + if (gcov_version (info, info->version)) { const char *ptr = info->filename; gcov_unsigned_t crc32 = gcov_crc32; |