This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gcov] improve error diagnostics
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Dec 2003 01:00:40 +0100
- Subject: [gcov] improve error diagnostics
Hi,
it is better to have more infromative error messages in coverage reading code.
I am getting some bugreports about the profiling and it is always better to have
some extra info. I've also changed the warnings to errors. I see no point in
reading in bogus profile and produce code using it.
Bootstrapped/regtested i686, will commit it unless someone objects tomorrow.
Honza
2003-12-28 Jan Hubicka <jh@suse.cz>
* coverage.c (read_counts_file): Better error messages; cause corrupted profiles
to produce hard errors, not just warnings
(get_coverage_counts): Similarly.
Index: coverage.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.c,v
retrieving revision 1.24
diff -c -3 -p -r1.24 coverage.c
*** coverage.c 13 Dec 2003 00:24:39 -0000 1.24
--- coverage.c 28 Dec 2003 16:28:06 -0000
*************** read_counts_file (void)
*** 154,160 ****
counts_entry_t *summaried = NULL;
unsigned seen_summary = 0;
gcov_unsigned_t tag;
! int error = 0;
if (!gcov_open (da_file_name, 1))
return;
--- 154,160 ----
counts_entry_t *summaried = NULL;
unsigned seen_summary = 0;
gcov_unsigned_t tag;
! int is_error = 0;
if (!gcov_open (da_file_name, 1))
return;
*************** read_counts_file (void)
*** 250,266 ****
entry->summary.num = n_counts;
entry->counts = xcalloc (n_counts, sizeof (gcov_type));
}
! else if (entry->checksum != checksum
! || entry->summary.num != n_counts)
{
! warning ("coverage mismatch for function %u", fn_ident);
htab_delete (counts_hash);
break;
}
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
{
! warning ("cannot merge separate %s counters for function %u",
! ctr_names[elt.ctr], fn_ident);
goto skip_merge;
}
--- 250,275 ----
entry->summary.num = n_counts;
entry->counts = xcalloc (n_counts, sizeof (gcov_type));
}
! else if (entry->checksum != checksum)
{
! error ("coverage mismatch for function %u while reading execution counters.",
! fn_ident);
! error ("checksum is %x instead of %x", entry->checksum, checksum);
! htab_delete (counts_hash);
! break;
! }
! else if (entry->summary.num != n_counts)
! {
! error ("coverage mismatch for function %u while reading execution counters.",
! fn_ident);
! error ("number of counters is %d instead of %d", entry->summary.num, n_counts);
htab_delete (counts_hash);
break;
}
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
{
! error ("cannot merge separate %s counters for function %u",
! ctr_names[elt.ctr], fn_ident);
goto skip_merge;
}
*************** read_counts_file (void)
*** 278,291 ****
skip_merge:;
}
gcov_sync (offset, length);
! if ((error = gcov_is_error ()))
break;
}
if (!gcov_is_eof ())
{
! warning (error < 0 ? "`%s' has overflowed" : "`%s' is corrupted",
! da_file_name);
htab_delete (counts_hash);
}
--- 287,300 ----
skip_merge:;
}
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);
}
*************** get_coverage_counts (unsigned counter, u
*** 299,304 ****
--- 308,314 ----
const struct gcov_ctr_summary **summary)
{
counts_entry_t *entry, elt;
+ gcov_unsigned_t checksum = -1;
/* No hash table, no counts. */
if (!counts_hash)
*************** get_coverage_counts (unsigned counter, u
*** 321,332 ****
return 0;
}
! if (expected != entry->summary.num
! || compute_checksum () != entry->checksum)
{
! warning ("coverage mismatch for `%s'", IDENTIFIER_POINTER
! (DECL_ASSEMBLER_NAME (current_function_decl)));
! return NULL;
}
if (summary)
--- 331,352 ----
return 0;
}
! checksum = compute_checksum ();
! if (entry->checksum != checksum)
{
! error ("coverage mismatch for function '%s' while reading counter '%s'.",
! IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)),
! ctr_names[counter]);
! error ("checksum is %x instead of %x", entry->checksum, checksum);
! return 0;
! }
! else if (entry->summary.num != expected)
! {
! error ("coverage mismatch for function '%s' while reading counter '%s'.",
! IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)),
! ctr_names[counter]);
! error ("number of counters is %d instead of %d", entry->summary.num, expected);
! return 0;
}
if (summary)