aboutsummaryrefslogtreecommitdiff
path: root/gcc/libgcov.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-05-14 16:01:20 +0000
committerNathan Sidwell <nathan@codesourcery.com>2003-05-14 16:01:20 +0000
commit8404adb21310e224c4840c9562312a879929c033 (patch)
tree1253c5f7880fe8708b5e0666b848785f27dcd9cc /gcc/libgcov.c
parent28c793c8dbae944cb04c9f1c216e3031382c60c5 (diff)
* gcov-io.h (gcov_write_bytes, gcov_read_bytes): Remove here.
(GCOV_TAG_*) Force type to gcov_unsigned_t. (GCOV_CHECK, GCOV_CHECK_READING, GCOV_CHECK_WRITING): New. (struct gcov_var): Remove modified. Add start, length, offset, overread. Have buffer array for libgcov. (gcov_sync, gcov_seek): Definitions moved to gcov-io.c. (gcov_position, gcov_rewrite, gcov_is_eof): Adjust. * gcov-io.c (gcov_open): Set mode, do not read anything. (gcov_close): Write final block. (gcov_write_block, gcov_allocate): New. (gcov_write_bytes): Make static. Write or allocate buffer. (gcov_write_unsigned, gcov_write_counter): Buffer can never be null. (gcov_write_string): Adjust. (gcov_write_tag) (gcov_write_length): Adjust. Flush the block. (gcov_write_tag_length): Buffer can never be null. (gcov_read_bytes): Make static. Read in block. (gcov_sync): Moved here. Adjust. (gcov_seek): Moved here. Adjust. * coverage.c (read_counts_file): Adjust. * gcov-dump.c (print_prefix): Add position parameter. (flag_dump_positions): New flag. (options, main, print_usage): Add it. (dump_file, tag_blocks, tag_arcs, tag_lines, tag_counters, tag_summary): Adjust. * gcov.c (read_graph_file, read_count_file): Adjust. * libgcov.c (gcov_exit): Adjust. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@66805 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r--gcc/libgcov.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index 221eae47498..ba54281e585 100644
--- a/gcc/libgcov.c
+++ b/gcc/libgcov.c
@@ -152,10 +152,10 @@ gcov_exit (void)
const struct gcov_ctr_info *ci_ptr;
struct gcov_ctr_summary *cs_ptr;
struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
- int error;
+ int error = 0;
int merging;
gcov_unsigned_t tag, length;
- gcov_position_t summary_pos = ~(gcov_position_t)0;
+ gcov_position_t summary_pos = 0;
/* Totals for this object file. */
memset (&this_object, 0, sizeof (this_object));
@@ -256,12 +256,14 @@ gcov_exit (void)
}
/* Check program & object summary */
- while (!gcov_is_eof ())
+ while (1)
{
gcov_position_t base = gcov_position ();
int is_program;
tag = gcov_read_unsigned ();
+ if (!tag)
+ break;
length = gcov_read_unsigned ();
is_program = tag == GCOV_TAG_PROGRAM_SUMMARY;
if (length != GCOV_TAG_SUMMARY_LENGTH
@@ -269,24 +271,26 @@ gcov_exit (void)
goto read_mismatch;
gcov_read_summary (is_program ? &program : &object);
if ((error = gcov_is_error ()))
+ goto read_error;
+ if (is_program && program.checksum == gcov_crc32)
{
- read_error:;
- fprintf (stderr, error < 0 ?
- "profiling:%s:Overflow merging\n" :
- "profiling:%s:Error merging\n", gi_ptr->filename);
- goto read_fatal;
+ summary_pos = base;
+ goto rewrite;
}
-
- if (!is_program || program.checksum != gcov_crc32)
- continue;
- summary_pos = base;
- break;
}
+ 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 ();
}
else
memset (&object, 0, sizeof (object));
- if (!(summary_pos + 1))
+ if (!summary_pos)
memset (&program, 0, sizeof (program));
/* Merge the summaries. */