mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-10 16:00:55 +08:00
gcov-io.h: Allow zero tag as EOF indicator.
* gcov-io.h: Allow zero tag as EOF indicator. (gcov_is_eof): Remove. (gcov_truncate): Remove. * gcov-io.c (gcov_seek): Always SEEK_SET. * libgcov.c (gcov_exit): Don't use gcov_truncate. Write explicit EOF tag. * coverage.c (read_counts_file): Don't use gcov_is_eof. * gcov-dump.c (dump_file): Likewise. * gcov.c (read_graph_file, read_count_file): Likewise. From-SVN: r85291
This commit is contained in:
parent
d815ea49f6
commit
00cf2913f8
@ -1,5 +1,15 @@
|
||||
2004-07-29 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* gcov-io.h: Allow zero tag as EOF indicator.
|
||||
(gcov_is_eof): Remove.
|
||||
(gcov_truncate): Remove.
|
||||
* gcov-io.c (gcov_seek): Always SEEK_SET.
|
||||
* libgcov.c (gcov_exit): Don't use gcov_truncate. Write explicit
|
||||
EOF tag.
|
||||
* coverage.c (read_counts_file): Don't use gcov_is_eof.
|
||||
* gcov-dump.c (dump_file): Likewise.
|
||||
* gcov.c (read_graph_file, read_count_file): Likewise.
|
||||
|
||||
* c-decl.c (complete_array_type): Don't gratuitously copy
|
||||
maxindex. Check it always has a type.
|
||||
|
||||
|
@ -292,14 +292,12 @@ read_counts_file (void)
|
||||
}
|
||||
gcov_sync (offset, length);
|
||||
if ((is_error = gcov_is_error ()))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!gcov_is_eof ())
|
||||
{
|
||||
error (is_error < 0 ? "`%s' has overflowed" : "`%s' is corrupted",
|
||||
da_file_name);
|
||||
htab_delete (counts_hash);
|
||||
{
|
||||
error (is_error < 0 ? "`%s' has overflowed" : "`%s' is corrupted",
|
||||
da_file_name);
|
||||
htab_delete (counts_hash);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gcov_close ();
|
||||
|
@ -254,8 +254,6 @@ dump_file (const char *filename)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!gcov_is_eof ())
|
||||
printf ("%s:early end of file\n", filename);
|
||||
gcov_close ();
|
||||
}
|
||||
|
||||
|
@ -514,8 +514,7 @@ gcov_sync (gcov_position_t base, gcov_unsigned_t length)
|
||||
#endif
|
||||
|
||||
#if IN_LIBGCOV
|
||||
/* Move to the a set position in a gcov file. BASE is zero to move to
|
||||
the end, and nonzero to move to that position. */
|
||||
/* Move to the a set position in a gcov file. */
|
||||
|
||||
GCOV_LINKAGE void
|
||||
gcov_seek (gcov_position_t base)
|
||||
@ -523,7 +522,7 @@ gcov_seek (gcov_position_t base)
|
||||
GCOV_CHECK_WRITING ();
|
||||
if (gcov_var.offset)
|
||||
gcov_write_block (gcov_var.offset);
|
||||
fseek (gcov_var.file, base << 2, base ? SEEK_SET : SEEK_END);
|
||||
fseek (gcov_var.file, base << 2, SEEK_SET);
|
||||
gcov_var.start = ftell (gcov_var.file) >> 2;
|
||||
}
|
||||
#endif
|
||||
|
@ -29,22 +29,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
the executable file might be covered by the GNU General Public License. */
|
||||
|
||||
/* Coverage information is held in two files. A notes file, which is
|
||||
generated by the compiler, and a data file, which is generated
|
||||
by the program under test. Both files use a similar structure. We
|
||||
do not attempt to make these files backwards compatible with
|
||||
previous versions, as you only need coverage information when
|
||||
developing a program. We do hold version information, so that
|
||||
mismatches can be detected, and we use a format that allows tools
|
||||
to skip information they do not understand or are not interested
|
||||
in.
|
||||
generated by the compiler, and a data file, which is generated by
|
||||
the program under test. Both files use a similar structure. We do
|
||||
not attempt to make these files backwards compatible with previous
|
||||
versions, as you only need coverage information when developing a
|
||||
program. We do hold version information, so that mismatches can be
|
||||
detected, and we use a format that allows tools to skip information
|
||||
they do not understand or are not interested in.
|
||||
|
||||
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
|
||||
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).
|
||||
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
|
||||
int64: int32:low int32:high
|
||||
@ -243,7 +242,6 @@ typedef HOST_WIDEST_INT gcov_type;
|
||||
#define gcov_seek __gcov_seek
|
||||
#define gcov_rewrite __gcov_rewrite
|
||||
#define gcov_is_error __gcov_is_error
|
||||
#define gcov_is_eof __gcov_is_eof
|
||||
#define gcov_write_unsigned __gcov_write_unsigned
|
||||
#define gcov_write_counter __gcov_write_counter
|
||||
#define gcov_write_summary __gcov_write_summary
|
||||
@ -284,7 +282,8 @@ typedef HOST_WIDEST_INT gcov_type;
|
||||
|
||||
/* 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. */
|
||||
the data file. The tag value zero is used as an explicit end of
|
||||
file marker -- it is not required to be present. */
|
||||
|
||||
#define GCOV_TAG_FUNCTION ((gcov_unsigned_t)0x01000000)
|
||||
#define GCOV_TAG_FUNCTION_LENGTH (2)
|
||||
@ -510,7 +509,6 @@ GCOV_LINKAGE int gcov_close (void);
|
||||
/* Available everywhere. */
|
||||
static gcov_position_t gcov_position (void);
|
||||
static int gcov_is_error (void);
|
||||
static int gcov_is_eof (void);
|
||||
|
||||
GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void);
|
||||
GCOV_LINKAGE gcov_type gcov_read_counter (void);
|
||||
@ -522,7 +520,6 @@ GCOV_LINKAGE void gcov_write_counter (gcov_type);
|
||||
GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t);
|
||||
GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
|
||||
const struct gcov_summary *);
|
||||
static void gcov_truncate (void);
|
||||
static void gcov_rewrite (void);
|
||||
GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/);
|
||||
#else
|
||||
@ -567,14 +564,6 @@ gcov_position (void)
|
||||
return gcov_var.start + gcov_var.offset;
|
||||
}
|
||||
|
||||
/* Return nonzero if we read to end of file. */
|
||||
|
||||
static inline int
|
||||
gcov_is_eof (void)
|
||||
{
|
||||
return !gcov_var.overread;
|
||||
}
|
||||
|
||||
/* Return nonzero if the error flag is set. */
|
||||
|
||||
static inline int
|
||||
@ -595,15 +584,6 @@ gcov_rewrite (void)
|
||||
gcov_var.offset = 0;
|
||||
fseek (gcov_var.file, 0L, SEEK_SET);
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define ftruncate _chsize
|
||||
#endif
|
||||
static inline void
|
||||
gcov_truncate (void)
|
||||
{
|
||||
ftruncate (fileno (gcov_var.file), 0L);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IN_LIBGCOV >= 0 */
|
||||
|
27
gcc/gcov.c
27
gcc/gcov.c
@ -896,14 +896,12 @@ read_graph_file (void)
|
||||
}
|
||||
gcov_sync (base, length);
|
||||
if (gcov_is_error ())
|
||||
break;
|
||||
}
|
||||
if (!gcov_is_eof ())
|
||||
{
|
||||
corrupt:;
|
||||
fnotice (stderr, "%s:corrupted\n", bbg_file_name);
|
||||
gcov_close ();
|
||||
return 1;
|
||||
{
|
||||
corrupt:;
|
||||
fnotice (stderr, "%s:corrupted\n", bbg_file_name);
|
||||
gcov_close ();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
gcov_close ();
|
||||
|
||||
@ -1055,14 +1053,11 @@ read_count_file (void)
|
||||
}
|
||||
gcov_sync (base, length);
|
||||
if ((error = gcov_is_error ()))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!gcov_is_eof ())
|
||||
{
|
||||
fnotice (stderr, error < 0 ? "%s:overflowed\n" : "%s:corrupted\n",
|
||||
da_file_name);
|
||||
goto cleanup;
|
||||
{
|
||||
fnotice (stderr, error < 0 ? "%s:overflowed\n" : "%s:corrupted\n",
|
||||
da_file_name);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
gcov_close ();
|
||||
|
@ -164,6 +164,7 @@ gcov_exit (void)
|
||||
int error = 0;
|
||||
gcov_unsigned_t tag, length;
|
||||
gcov_position_t summary_pos = 0;
|
||||
gcov_position_t eof_pos = 0;
|
||||
|
||||
memset (&this_object, 0, sizeof (this_object));
|
||||
memset (&object, 0, sizeof (object));
|
||||
@ -218,9 +219,7 @@ gcov_exit (void)
|
||||
{
|
||||
fprintf (stderr, "profiling:%s:Not a gcov data file\n",
|
||||
gi_ptr->filename);
|
||||
read_fatal:;
|
||||
gcov_close ();
|
||||
continue;
|
||||
goto read_fatal;
|
||||
}
|
||||
length = gcov_read_unsigned ();
|
||||
if (!gcov_version (gi_ptr, length))
|
||||
@ -228,12 +227,8 @@ gcov_exit (void)
|
||||
|
||||
length = gcov_read_unsigned ();
|
||||
if (length != gi_ptr->stamp)
|
||||
{
|
||||
/* Read from a different compilation. Overwrite the
|
||||
file. */
|
||||
gcov_truncate ();
|
||||
goto rewrite;
|
||||
}
|
||||
/* Read from a different compilation. Overwrite the file. */
|
||||
goto rewrite;
|
||||
|
||||
/* Merge execution counts for each function. */
|
||||
for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
|
||||
@ -284,12 +279,13 @@ gcov_exit (void)
|
||||
/* Check program & object summary */
|
||||
while (1)
|
||||
{
|
||||
gcov_position_t base = gcov_position ();
|
||||
int is_program;
|
||||
|
||||
eof_pos = gcov_position ();
|
||||
tag = gcov_read_unsigned ();
|
||||
if (!tag)
|
||||
break;
|
||||
|
||||
length = gcov_read_unsigned ();
|
||||
is_program = tag == GCOV_TAG_PROGRAM_SUMMARY;
|
||||
if (length != GCOV_TAG_SUMMARY_LENGTH
|
||||
@ -300,19 +296,21 @@ gcov_exit (void)
|
||||
goto read_error;
|
||||
if (is_program && program.checksum == gcov_crc32)
|
||||
{
|
||||
summary_pos = base;
|
||||
summary_pos = eof_pos;
|
||||
goto rewrite;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
read_error:;
|
||||
fprintf (stderr, error < 0 ? "profiling:%s:Overflow merging\n"
|
||||
: "profiling:%s:Error merging\n", gi_ptr->filename);
|
||||
|
||||
read_fatal:;
|
||||
gcov_close ();
|
||||
continue;
|
||||
|
||||
rewrite:;
|
||||
gcov_rewrite ();
|
||||
if (!summary_pos)
|
||||
@ -414,8 +412,11 @@ gcov_exit (void)
|
||||
gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, &object);
|
||||
|
||||
/* Generate whole program statistics. */
|
||||
gcov_seek (summary_pos);
|
||||
if (eof_pos)
|
||||
gcov_seek (eof_pos);
|
||||
gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &program);
|
||||
if (!summary_pos)
|
||||
gcov_write_unsigned (0);
|
||||
if ((error = gcov_close ()))
|
||||
fprintf (stderr, error < 0 ?
|
||||
"profiling:%s:Overflow writing\n" :
|
||||
|
Loading…
x
Reference in New Issue
Block a user