aboutsummaryrefslogtreecommitdiff
path: root/gcc/libgcov.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-07-09 12:12:29 +0000
committerNathan Sidwell <nathan@codesourcery.com>2003-07-09 12:12:29 +0000
commit375797a55a73840203bc5c5244c3baa17537cb0e (patch)
tree5a33b5396c3ed82380adfbc9d86b6c3c8ad3bb59 /gcc/libgcov.c
parentc58195fb11127fccfe97a5ffa709aee41a2bfdee (diff)
* 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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@69137 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r--gcc/libgcov.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index 72126466f66..826617f14b4 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;