summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog33
-rw-r--r--gcc/coverage.c9
-rw-r--r--gcc/gcov-dump.c33
-rw-r--r--gcc/gcov-io.c74
-rw-r--r--gcc/gcov-io.h56
-rw-r--r--gcc/gcov.c36
-rw-r--r--gcc/libgcov.c38
7 files changed, 161 insertions, 118 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d5a452fc454..359cf6d79e2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,36 @@
+2003-07-10 Nathan Sidwell <nathan@codesourcery.com>
+
+ * gcov-io.h: Update documentation.
+ (GCOV_UNSIGNED2STRING): New.
+ (GCOV_TAG_FUNCTION_LENGTH, GCOV_TAG_BLOCKS_LENGTH,
+ GCOV_TAG_ARCS_LENGTH, GCOV_TAG_COUNTER_LENGTH,
+ GCOV_TAG_SUMMARY_LENGTH): Adjust.
+ (GCOV_TAG_BLOCKS_NUM, GCOV_TAG_ARCS_NUM,
+ GCOV_TAG_COUNTER_NUM): New.
+ (GCOV_BLOCK_SIZE): Number of words.
+ (gcov_var): Adjust buffer type.
+ * gcov-io.c (gcov_write_bytes, gcov_read_bytes): Rename to ...
+ (gcov_write_words, gcov_read_words): ... here. Take a 4-byte word
+ count, not byte count.
+ (gcov_open): Adjust overread init.
+ (gcov_allocate, gcov_write_unsigned, gcov_write_counter,
+ gcov_write_string, gcov_write_tag, gcov_write_length,
+ gcov_write_tag_length): Adjust.
+ (gcov_read_unsigned, gcov_read_counter, gcov_read_string): Adjust.
+ (gcov_sync, gcov_seek): Adjust.
+ * gcov-dump.c (print_usage): Show gcc version only.
+ (dump_file): Use GCOV_UNSIGNED2STRING.
+ (tag_blocks, tag_arcs, tag_counters): Use GCOV_TAG_*_NUM macros.
+ * gcov.c (print_version): Show gcc version only.
+ (read_graph_file): Use GCOV_UNSIGNED2STRING. Use
+ GCOV_TAG_*_NUM macros.
+ (read_count_file): Use GCOV_UNSIGNED2STRING. Use
+ GCOV_TAG_COUNTER_LENGTH.
+ * coverage.c (read_counts_file): Use GCOV_UNSIGNED2STRING.
+ Use GCOV_TAG_COUNTER_NUM.
+ * libgcov.c (gcov_version): Use GCOV_UNSIGNED2STRING.
+ (__gcov_merge_single, __gcov_merge_delta): Use GCOV_CHECK.
+
2003-07-10 Andreas Schwab <schwab@suse.de>
* gcov-dump.c (dump_file): Fix missing address operator.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 0bc7a26cecb..252331776c4 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -167,10 +167,13 @@ read_counts_file (void)
}
else if ((tag = gcov_read_unsigned ()) != GCOV_VERSION)
{
- gcov_unsigned_t required = GCOV_VERSION;
+ char v[4], e[4];
+
+ GCOV_UNSIGNED2STRING (v, tag);
+ GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
warning ("`%s' is version `%.4s', expected version `%.4s'",
- da_file_name, (const char *)&tag, (const char *)&required);
+ da_file_name, v, e);
gcov_close ();
return;
}
@@ -229,7 +232,7 @@ read_counts_file (void)
else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident)
{
counts_entry_t **slot, *entry, elt;
- unsigned n_counts = length / 8;
+ unsigned n_counts = GCOV_TAG_COUNTER_NUM (length);
unsigned ix;
elt.ident = fn_ident;
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index a3e8a3d3f1d..e0115622ab7 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -117,16 +117,11 @@ print_usage (void)
static void
print_version (void)
{
- char v[4];
- unsigned version = GCOV_VERSION;
- unsigned ix;
-
- for (ix = 4; ix--; version >>= 8)
- v[ix] = version;
- printf ("gcov %.4s (GCC %s)\n", v, version_string);
- printf ("Copyright (C) 2002 Free Software Foundation, Inc.\n");
- printf ("This is free software; see the source for copying conditions. There is NO\n\
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+ printf ("gcov-dump (GCC) %s\n", version_string);
+ printf ("Copyright (C) 2003 Free Software Foundation, Inc.\n");
+ printf ("This is free software; see the source for copying conditions.\n"
+ "There is NO warranty; not even for MERCHANTABILITY or \n"
+ "FITNESS FOR A PARTICULAR PURPOSE.\n\n");
}
static void
@@ -158,6 +153,7 @@ dump_file (const char *filename)
unsigned version;
const char *type = NULL;
int endianness = 0;
+ char m[4], v[4];
if ((endianness = gcov_magic (magic, GCOV_DATA_MAGIC)))
type = "data";
@@ -170,16 +166,17 @@ dump_file (const char *filename)
return;
}
version = gcov_read_unsigned ();
+ GCOV_UNSIGNED2STRING (v, version);
+ GCOV_UNSIGNED2STRING (m, magic);
printf ("%s:%s:magic `%.4s':version `%.4s'%s\n", filename, type,
- (const char *)&magic, (const char *)&version,
- endianness < 0 ? " (swapped endianness)" : "");
+ m, v, endianness < 0 ? " (swapped endianness)" : "");
if (version != GCOV_VERSION)
{
- unsigned expected = GCOV_VERSION;
+ char e[4];
- printf ("%s:warning:current version is `%.4s'\n", filename,
- (const char *)&expected);
+ GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
+ printf ("%s:warning:current version is `%.4s'\n", filename, e);
}
}
@@ -287,7 +284,7 @@ static void
tag_blocks (const char *filename ATTRIBUTE_UNUSED,
unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
{
- unsigned n_blocks = length / 4;
+ unsigned n_blocks = GCOV_TAG_BLOCKS_NUM (length);
printf (" %u blocks", n_blocks);
@@ -312,7 +309,7 @@ static void
tag_arcs (const char *filename ATTRIBUTE_UNUSED,
unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
{
- unsigned n_arcs = (length - 4) / 8;
+ unsigned n_arcs = GCOV_TAG_ARCS_NUM (length);
printf (" %u arcs", n_arcs);
if (flag_dump_contents)
@@ -386,7 +383,7 @@ tag_counters (const char *filename ATTRIBUTE_UNUSED,
unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
{
static const char *const counter_names[] = GCOV_COUNTER_NAMES;
- unsigned n_counts = length / 8;
+ unsigned n_counts = GCOV_TAG_COUNTER_NUM (length);
printf (" %s %u counts",
counter_names[GCOV_COUNTER_FOR_TAG (tag)], n_counts);
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index bce2d04e44a..820b1f61701 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -26,9 +26,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#if !IN_GCOV
static void gcov_write_block (unsigned);
-static gcov_unsigned_t *gcov_write_bytes (unsigned);
+static gcov_unsigned_t *gcov_write_words (unsigned);
#endif
-static const gcov_unsigned_t *gcov_read_bytes (unsigned);
+static const gcov_unsigned_t *gcov_read_words (unsigned);
#if !IN_LIBGCOV
static void gcov_allocate (unsigned);
#endif
@@ -77,7 +77,7 @@ gcov_open (const char *name, int mode)
abort ();
gcov_var.start = 0;
gcov_var.offset = gcov_var.length = 0;
- gcov_var.overread = -4u;
+ gcov_var.overread = -1u;
gcov_var.error = 0;
#if !IN_LIBGCOV
gcov_var.endian = 0;
@@ -164,7 +164,7 @@ gcov_allocate (unsigned length)
new_size *= 2;
gcov_var.alloc = new_size;
- gcov_var.buffer = xrealloc (gcov_var.buffer, new_size);
+ gcov_var.buffer = xrealloc (gcov_var.buffer, new_size << 2);
}
#endif
@@ -174,7 +174,7 @@ gcov_allocate (unsigned length)
static void
gcov_write_block (unsigned size)
{
- if (fwrite (gcov_var.buffer, size, 1, gcov_var.file) != 1)
+ if (fwrite (gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
gcov_var.error = 1;
gcov_var.start += size;
gcov_var.offset -= size;
@@ -184,28 +184,27 @@ gcov_write_block (unsigned size)
pointer to those bytes, or NULL on failure. */
static gcov_unsigned_t *
-gcov_write_bytes (unsigned bytes)
+gcov_write_words (unsigned words)
{
gcov_unsigned_t *result;
GCOV_CHECK_WRITING ();
- GCOV_CHECK (!(bytes & 3));
#if IN_LIBGCOV
if (gcov_var.offset >= GCOV_BLOCK_SIZE)
{
gcov_write_block (GCOV_BLOCK_SIZE);
if (gcov_var.offset)
{
- GCOV_CHECK (gcov_var.offset == 4);
+ GCOV_CHECK (gcov_var.offset == 1);
memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
}
}
#else
- if (gcov_var.offset + bytes > gcov_var.alloc)
- gcov_allocate (gcov_var.offset + bytes);
+ if (gcov_var.offset + words > gcov_var.alloc)
+ gcov_allocate (gcov_var.offset + words);
#endif
- result = (gcov_unsigned_t *)&gcov_var.buffer[gcov_var.offset];
- gcov_var.offset += bytes;
+ result = &gcov_var.buffer[gcov_var.offset];
+ gcov_var.offset += words;
return result;
}
@@ -216,7 +215,7 @@ gcov_write_bytes (unsigned bytes)
GCOV_LINKAGE void
gcov_write_unsigned (gcov_unsigned_t value)
{
- gcov_unsigned_t *buffer = gcov_write_bytes (4);
+ gcov_unsigned_t *buffer = gcov_write_words (1);
buffer[0] = value;
}
@@ -228,7 +227,7 @@ gcov_write_unsigned (gcov_unsigned_t value)
GCOV_LINKAGE void
gcov_write_counter (gcov_type value)
{
- gcov_unsigned_t *buffer = gcov_write_bytes (8);
+ gcov_unsigned_t *buffer = gcov_write_words (2);
buffer[0] = (gcov_unsigned_t) value;
if (sizeof (value) > sizeof (gcov_unsigned_t))
@@ -258,7 +257,7 @@ gcov_write_string (const char *string)
alloc = (length + 4) >> 2;
}
- buffer = gcov_write_bytes (4 + alloc * 4);
+ buffer = gcov_write_words (1 + alloc);
buffer[0] = alloc;
buffer[alloc] = 0;
@@ -274,7 +273,7 @@ GCOV_LINKAGE gcov_position_t
gcov_write_tag (gcov_unsigned_t tag)
{
gcov_position_t result = gcov_var.start + gcov_var.offset;
- gcov_unsigned_t *buffer = gcov_write_bytes (8);
+ gcov_unsigned_t *buffer = gcov_write_words (2);
buffer[0] = tag;
buffer[1] = 0;
@@ -295,10 +294,10 @@ gcov_write_length (gcov_position_t position)
gcov_unsigned_t *buffer;
GCOV_CHECK_WRITING ();
- GCOV_CHECK (position + 8 <= gcov_var.start + gcov_var.offset);
+ GCOV_CHECK (position + 2 <= gcov_var.start + gcov_var.offset);
GCOV_CHECK (position >= gcov_var.start);
offset = position - gcov_var.start;
- length = gcov_var.offset - offset - 8;
+ length = gcov_var.offset - offset - 2;
buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
buffer[1] = length;
if (gcov_var.offset >= GCOV_BLOCK_SIZE)
@@ -312,7 +311,7 @@ gcov_write_length (gcov_position_t position)
GCOV_LINKAGE void
gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
{
- gcov_unsigned_t *buffer = gcov_write_bytes (8);
+ gcov_unsigned_t *buffer = gcov_write_words (2);
buffer[0] = tag;
buffer[1] = length;
@@ -346,20 +345,19 @@ gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
NULL on failure (read past EOF). */
static const gcov_unsigned_t *
-gcov_read_bytes (unsigned bytes)
+gcov_read_words (unsigned words)
{
const gcov_unsigned_t *result;
unsigned excess = gcov_var.length - gcov_var.offset;
GCOV_CHECK_READING ();
- GCOV_CHECK (!(bytes & 3));
- if (excess < bytes)
+ if (excess < words)
{
gcov_var.start += gcov_var.offset;
#if IN_LIBGCOV
if (excess)
{
- GCOV_CHECK (excess == 4);
+ GCOV_CHECK (excess == 1);
memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
}
#else
@@ -368,25 +366,25 @@ gcov_read_bytes (unsigned bytes)
gcov_var.offset = 0;
gcov_var.length = excess;
#if IN_LIBGCOV
- GCOV_CHECK (!gcov_var.length || gcov_var.length == 4);
+ GCOV_CHECK (!gcov_var.length || gcov_var.length == 1);
excess = GCOV_BLOCK_SIZE;
#else
- if (gcov_var.length + bytes > gcov_var.alloc)
- gcov_allocate (gcov_var.length + bytes);
+ if (gcov_var.length + words > gcov_var.alloc)
+ gcov_allocate (gcov_var.length + words);
excess = gcov_var.alloc - gcov_var.length;
#endif
excess = fread (gcov_var.buffer + gcov_var.length,
- 1, excess, gcov_var.file);
+ 1, excess << 2, gcov_var.file) >> 2;
gcov_var.length += excess;
- if (gcov_var.length < bytes)
+ if (gcov_var.length < words)
{
- gcov_var.overread += bytes - gcov_var.length;
+ gcov_var.overread += words - gcov_var.length;
gcov_var.length = 0;
return 0;
}
}
- result = (gcov_unsigned_t *)&gcov_var.buffer[gcov_var.offset];
- gcov_var.offset += bytes;
+ result = &gcov_var.buffer[gcov_var.offset];
+ gcov_var.offset += words;
return result;
}
@@ -397,7 +395,7 @@ GCOV_LINKAGE gcov_unsigned_t
gcov_read_unsigned (void)
{
gcov_unsigned_t value;
- const gcov_unsigned_t *buffer = gcov_read_bytes (4);
+ const gcov_unsigned_t *buffer = gcov_read_words (1);
if (!buffer)
return 0;
@@ -412,7 +410,7 @@ GCOV_LINKAGE gcov_type
gcov_read_counter (void)
{
gcov_type value;
- const gcov_unsigned_t *buffer = gcov_read_bytes (8);
+ const gcov_unsigned_t *buffer = gcov_read_words (2);
if (!buffer)
return 0;
@@ -440,7 +438,7 @@ gcov_read_string (void)
if (!length)
return 0;
- return (const char *) gcov_read_bytes (length);
+ return (const char *) gcov_read_words (length);
}
#endif
@@ -475,8 +473,8 @@ gcov_sync (gcov_position_t base, gcov_unsigned_t length)
else
{
gcov_var.offset = gcov_var.length = 0;
- fseek (gcov_var.file, base, SEEK_SET);
- gcov_var.start = ftell (gcov_var.file);
+ fseek (gcov_var.file, base << 2, SEEK_SET);
+ gcov_var.start = ftell (gcov_var.file) >> 2;
}
}
#endif
@@ -491,8 +489,8 @@ gcov_seek (gcov_position_t base)
GCOV_CHECK_WRITING ();
if (gcov_var.offset)
gcov_write_block (gcov_var.offset);
- fseek (gcov_var.file, base, base ? SEEK_SET : SEEK_END);
- gcov_var.start = ftell (gcov_var.file);
+ fseek (gcov_var.file, base << 2, base ? SEEK_SET : SEEK_END);
+ gcov_var.start = ftell (gcov_var.file) >> 2;
}
#endif
diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h
index 35c31b955fe..018b020ec37 100644
--- a/gcc/gcov-io.h
+++ b/gcc/gcov-io.h
@@ -41,8 +41,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
Numbers are recorded in the 32 bit unsigned binary form of the
endianness of the machine generating the file. 64 bit numbers are
stored as two 32 bit numbers, the low part first. Strings are
- stored as length rounded up to 4 followed by the string and then 1
- to 4 NUL bytes. Zero length and NULL strings are simply stored as
+ padded with 1 to 4 NUL bytes, to bring the length up to a multiple
+ of 4. The number of 4 bytes is stored, followed by the padded
+ string. Zero length and NULL strings are simply stored as
a length of zero (they have no trailing NUL or padding).
int32: byte3 byte2 byte1 byte0 | byte0 byte1 byte2 byte3
@@ -89,16 +90,17 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
Records are not nested, but there is a record hierarchy. Tag
numbers reflect this hierarchy. Tags are unique across note and
data files. Some record types have a varying amount of data. The
- LENGTH is usually used to determine how much data. The tag value
- is split into 4 8-bit fields, one for each of four possible levels.
- The most significant is allocated first. Unused levels are zero.
- Active levels are odd-valued, so that the LSB of the level is one.
- A sub-level incorporates the values of its superlevels. This
- formatting allows you to determine the tag hierarchy, without
- understanding the tags themselves, and is similar to the standard
- section numbering used in technical documents. Level values
- [1..3f] are used for common tags, values [41..9f] for the notes
- file and [a1..ff] for the data file.
+ LENGTH is the number of 4bytes that follow and is usually used to
+ determine how much data. The tag value is split into 4 8-bit
+ fields, one for each of four possible levels. The most significant
+ is allocated first. Unused levels are zero. Active levels are
+ odd-valued, so that the LSB of the level is one. A sub-level
+ incorporates the values of its superlevels. This formatting allows
+ you to determine the tag hierarchy, without understanding the tags
+ themselves, and is similar to the standard section numbering used
+ in technical documents. Level values [1..3f] are used for common
+ tags, values [41..9f] for the notes file and [a1..ff] for the data
+ file.
The basic block graph file contains the following records
note: unit function-graph*
@@ -252,23 +254,33 @@ typedef HOST_WIDEST_INT gcov_type;
*/
#include "gcov-iov.h"
+/* Convert a magic or version number to a 4 character string. */
+#define GCOV_UNSIGNED2STRING(ARRAY,VALUE) \
+ ((ARRAY)[0] = (char)((VALUE) >> 24), \
+ (ARRAY)[1] = (char)((VALUE) >> 16), \
+ (ARRAY)[2] = (char)((VALUE) >> 8), \
+ (ARRAY)[3] = (char)((VALUE) >> 0))
+
/* The record tags. Values [1..3f] are for tags which may be in either
file. Values [41..9f] for those in the note file and [a1..ff] for
the data file. */
#define GCOV_TAG_FUNCTION ((gcov_unsigned_t)0x01000000)
-#define GCOV_TAG_FUNCTION_LENGTH (2 * 4)
+#define GCOV_TAG_FUNCTION_LENGTH (2)
#define GCOV_TAG_BLOCKS ((gcov_unsigned_t)0x01410000)
-#define GCOV_TAG_BLOCKS_LENGTH(NUM) ((NUM) * 4)
+#define GCOV_TAG_BLOCKS_LENGTH(NUM) (NUM)
+#define GCOV_TAG_BLOCKS_NUM(LENGTH) (LENGTH)
#define GCOV_TAG_ARCS ((gcov_unsigned_t)0x01430000)
-#define GCOV_TAG_ARCS_LENGTH(NUM) (1 * 4 + (NUM) * (2 * 4))
+#define GCOV_TAG_ARCS_LENGTH(NUM) (1 + (NUM) * 2)
+#define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2)
#define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000)
#define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000)
-#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 8)
+#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
+#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
#define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000)
#define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
#define GCOV_TAG_SUMMARY_LENGTH \
- (1 * 4 + GCOV_COUNTERS_SUMMABLE * (2 * 4 + 3 * 8))
+ (1 + GCOV_COUNTERS_SUMMABLE * (2 + 3 * 2))
/* Counters that are collected. */
#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
@@ -407,8 +419,8 @@ extern void __gcov_merge_delta (gcov_type *, unsigned);
#if IN_LIBGCOV >= 0
-/* Optimum size read from or written to disk. */
-#define GCOV_BLOCK_SIZE (1 << 12)
+/* Optimum number of gcov_unsigned_t's read from or written to disk. */
+#define GCOV_BLOCK_SIZE (1 << 10)
GCOV_LINKAGE struct gcov_var
{
@@ -416,7 +428,7 @@ GCOV_LINKAGE struct gcov_var
gcov_position_t start; /* Position of first byte of block */
unsigned offset; /* Read/write position within the block. */
unsigned length; /* Read limit in the block. */
- unsigned overread; /* Number of bytes overread. */
+ unsigned overread; /* Number of words overread. */
int error; /* < 0 overflow, > 0 disk error. */
int mode; /* < 0 writing, > 0 reading */
#if IN_LIBGCOV
@@ -424,13 +436,13 @@ GCOV_LINKAGE struct gcov_var
fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
to and from the disk. libgcov never backtracks and only writes 4
or 8 byte objects. */
- char buffer[GCOV_BLOCK_SIZE + 4] __attribute__ ((aligned (4)));
+ gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
#else
int endian; /* Swap endianness. */
/* Holds a variable length block, as the compiler can write
strings and needs to backtrack. */
size_t alloc;
- char *buffer;
+ gcov_unsigned_t *buffer;
#endif
} gcov_var;
diff --git a/gcc/gcov.c b/gcc/gcov.c
index d42cff15b2c..cc15f65fa54 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -417,14 +417,12 @@ print_usage (int error_p)
static void
print_version (void)
{
- unsigned version = GCOV_VERSION;
-
- fnotice (stdout, "gcov %.4s (GCC %s)\n",
- (const char *)&version, version_string);
- fnotice (stdout, "Copyright (C) 2002 Free Software Foundation, Inc.\n");
+ fnotice (stdout, "gcov (GCC) %s\n", version_string);
+ fnotice (stdout, "Copyright (C) 2003 Free Software Foundation, Inc.\n");
fnotice (stdout,
- "This is free software; see the source for copying conditions. There is NO\n\
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+ "This is free software; see the source for copying conditions.\n"
+ "There is NO warranty; not even for MERCHANTABILITY or \n"
+ "FITNESS FOR A PARTICULAR PURPOSE.\n\n");
exit (SUCCESS_EXIT_CODE);
}
@@ -723,13 +721,10 @@ read_graph_file (void)
if (version != GCOV_VERSION)
{
char v[4], e[4];
- unsigned required = GCOV_VERSION;
- for (ix = 4; ix--; required >>= 8, version >>= 8)
- {
- v[ix] = version;
- e[ix] = required;
- }
+ GCOV_UNSIGNED2STRING (v, version);
+ GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
+
fnotice (stderr, "%s:version `%.4s', prefer `%.4s'\n",
bbg_file_name, v, e);
}
@@ -786,7 +781,7 @@ read_graph_file (void)
bbg_file_name, fn->name);
else
{
- unsigned ix, num_blocks = length / 4;
+ unsigned ix, num_blocks = GCOV_TAG_BLOCKS_NUM (length);
fn->num_blocks = num_blocks;
fn->blocks
@@ -798,7 +793,7 @@ read_graph_file (void)
else if (fn && tag == GCOV_TAG_ARCS)
{
unsigned src = gcov_read_unsigned ();
- unsigned num_dests = (length - 4) / 8;
+ unsigned num_dests = GCOV_TAG_ARCS_NUM (length);
if (src >= fn->num_blocks || fn->blocks[src].succ)
goto corrupt;
@@ -857,7 +852,7 @@ read_graph_file (void)
{
unsigned blockno = gcov_read_unsigned ();
unsigned *line_nos
- = (unsigned *)xcalloc ((length - 4) / 4, sizeof (unsigned));
+ = (unsigned *)xcalloc (length - 1, sizeof (unsigned));
if (blockno >= fn->num_blocks || fn->blocks[blockno].u.line.encoding)
goto corrupt;
@@ -991,10 +986,13 @@ read_count_file (void)
version = gcov_read_unsigned ();
if (version != GCOV_VERSION)
{
- unsigned desired = GCOV_VERSION;
+ char v[4], e[4];
+
+ GCOV_UNSIGNED2STRING (v, version);
+ GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
fnotice (stderr, "%s:version `%.4s', prefer version `%.4s'\n",
- da_file_name, (const char *)&version, (const char *)&desired);
+ da_file_name, v, e);
}
tag = gcov_read_unsigned ();
if (tag != bbg_stamp)
@@ -1045,7 +1043,7 @@ read_count_file (void)
}
else if (tag == GCOV_TAG_FOR_COUNTER (GCOV_COUNTER_ARCS) && fn)
{
- if (length != 8 * fn->num_counts)
+ if (length != GCOV_TAG_COUNTER_LENGTH (fn->num_counts))
goto mismatch;
if (!fn->counts)
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index 826617f14b4..140ab05bf1c 100644
--- a/gcc/libgcov.c
+++ b/gcc/libgcov.c
@@ -94,13 +94,16 @@ static gcov_unsigned_t gcov_crc32;
static int
gcov_version (struct gcov_info *ptr, gcov_unsigned_t version)
{
- gcov_unsigned_t expected = GCOV_VERSION;
-
if (version != GCOV_VERSION)
{
+ char v[4], e[4];
+
+ GCOV_UNSIGNED2STRING (v, version);
+ GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
+
fprintf (stderr,
"profiling:%s:Version mismatch - expected %.4s got %.4s\n",
- ptr->filename, (const char *)&expected, (const char *)&version);
+ ptr->filename, e, v);
return 0;
}
return 1;
@@ -478,10 +481,12 @@ __gcov_merge_add (gcov_type *counters, unsigned n_counters)
#endif /* L_gcov_merge_add */
#ifdef L_gcov_merge_single
-/* The profile merging function for choosing the most common value. It is given
- an array COUNTERS of N_COUNTERS old counters and it reads the same number
- of counters from the gcov file. The counters are split into 3-tuples
- where the members of the tuple have meanings:
+/* The profile merging function for choosing the most common value.
+ It is given an array COUNTERS of N_COUNTERS old counters and it
+ reads the same number of counters from the gcov file. The counters
+ are split into 3-tuples where the members of the tuple have
+ meanings:
+
-- the stored candidate on the most common value of the measured entity
-- counter
-- total number of evaluations of the value */
@@ -491,9 +496,7 @@ __gcov_merge_single (gcov_type *counters, unsigned n_counters)
unsigned i, n_measures;
gcov_type value, counter, all;
- if (n_counters % 3)
- abort ();
-
+ GCOV_CHECK (!(n_counters % 3));
n_measures = n_counters / 3;
for (i = 0; i < n_measures; i++, counters += 3)
{
@@ -516,11 +519,12 @@ __gcov_merge_single (gcov_type *counters, unsigned n_counters)
#endif /* L_gcov_merge_single */
#ifdef L_gcov_merge_delta
-/* The profile merging function for choosing the most common difference between
- two consecutive evaluations of the value. It is given an array COUNTERS of
- N_COUNTERS old counters and it reads the same number of counters from the
- gcov file. The counters are split into 4-tuples where the members of the
- tuple have meanings:
+/* The profile merging function for choosing the most common
+ difference between two consecutive evaluations of the value. It is
+ given an array COUNTERS of N_COUNTERS old counters and it reads the
+ same number of counters from the gcov file. The counters are split
+ into 4-tuples where the members of the tuple have meanings:
+
-- the last value of the measured entity
-- the stored candidate on the most common difference
-- counter
@@ -531,9 +535,7 @@ __gcov_merge_delta (gcov_type *counters, unsigned n_counters)
unsigned i, n_measures;
gcov_type last, value, counter, all;
- if (n_counters % 4)
- abort ();
-
+ GCOV_CHECK (!(n_counters % 4));
n_measures = n_counters / 4;
for (i = 0; i < n_measures; i++, counters += 4)
{