gcov-tool: fix merge operation for summary

libgcc/ChangeLog:

	* libgcov-driver.c (merge_summary): Remove function as its name
	is misleading and doing something different.
	(dump_one_gcov): Add ATTRIBUTE_UNUSED for 2 args. Take read summary
	in gcov-tool.
	* libgcov-util.c (curr_object_summary): Remove.
	(read_gcda_file): Remove unused curr_object_summary.
	(gcov_merge): Merge summaries.
	* libgcov.h: Add summary argument for gcov_info struct.
This commit is contained in:
Martin Liska 2020-06-25 11:20:52 +02:00
parent a8d8caca0c
commit 88891c5ff0
No known key found for this signature in database
GPG Key ID: 4DC182DC0FA73785
3 changed files with 18 additions and 20 deletions

View File

@ -442,19 +442,6 @@ write_one_data (const struct gcov_info *gi_ptr,
gcov_write_unsigned (0);
}
/* Helper function for merging summary. */
static void
merge_summary (int run_counted, struct gcov_summary *summary,
gcov_type run_max)
{
if (!run_counted)
{
summary->runs++;
summary->sum_max += run_max;
}
}
/* Dump the coverage counts for one gcov_info object. We merge with existing
counts when possible, to avoid growing the .da files ad infinitum. We use
this program's checksum to make sure we only accumulate whole program
@ -464,7 +451,8 @@ merge_summary (int run_counted, struct gcov_summary *summary,
static void
dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
unsigned run_counted, gcov_type run_max)
unsigned run_counted ATTRIBUTE_UNUSED,
gcov_type run_max ATTRIBUTE_UNUSED)
{
struct gcov_summary summary = {};
int error;
@ -492,7 +480,15 @@ dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
gcov_rewrite ();
merge_summary (run_counted, &summary, run_max);
#if !IN_GCOV_TOOL
if (!run_counted)
{
summary.runs++;
summary.sum_max += run_max;
}
#else
summary = gi_ptr->summary;
#endif
write_one_data (gi_ptr, &summary);
/* fall through */

View File

@ -80,8 +80,6 @@ static int k_ctrs_mask[GCOV_COUNTERS];
static struct gcov_ctr_info k_ctrs[GCOV_COUNTERS];
/* Number of kind of counters that have been seen. */
static int k_ctrs_types;
/* The object summary being processed. */
static struct gcov_summary *curr_object_summary;
/* Merge functions for counters. */
#define DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE) __gcov_merge ## FN_TYPE,
@ -225,8 +223,7 @@ tag_counters (unsigned tag, unsigned length)
static void
tag_summary (unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
{
curr_object_summary = (gcov_summary *) xcalloc (sizeof (gcov_summary), 1);
gcov_read_summary (curr_object_summary);
gcov_read_summary (&curr_gcov_info->summary);
}
/* This function is called at the end of reading a gcda file.
@ -300,7 +297,6 @@ read_gcda_file (const char *filename)
obstack_init (&fn_info);
num_fn_info = 0;
curr_fn_info = 0;
curr_object_summary = NULL;
{
size_t len = strlen (filename) + 1;
char *str_dup = (char*) xmalloc (len);
@ -584,6 +580,11 @@ gcov_merge (struct gcov_info *info1, struct gcov_info *info2, int w)
int has_mismatch = 0;
gcc_assert (info2->n_functions == n_functions);
/* Merge summary. */
info1->summary.runs += info2->summary.runs;
info1->summary.sum_max += info2->summary.sum_max;
for (f_ix = 0; f_ix < n_functions; f_ix++)
{
unsigned t_ix;

View File

@ -217,6 +217,7 @@ struct gcov_info
to function information */
#else
struct gcov_fn_info **functions;
struct gcov_summary summary;
#endif /* !IN_GCOV_TOOL */
};