Commit cb9e4555 by Zdenek Dvorak Committed by Zdenek Dvorak

gcov-dump.c (print_prefix): Fix signedness warning.

	* gcov-dump.c (print_prefix): Fix signedness warning.
	* gcov-io.h (struct counter_section, struct counter_section_data): New.
	(struct function_info): n_arc_counts field removed, n_counter_sections,
	counter_sections fields added.
	(struct gcov_info): arc_counts, n_arc_counts fields removed,
	n_counter_sections, counter_sections fields added.
	* libgcov.c (gcov_exit, __gcov_flush): Add support for multiple
	profile sections.
	* profile.h (MAX_COUNTER_SECTIONS): New.
	(struct section_info): New.
	(struct profile_info): count_instrumented_edges,
	count_edges_instrumented_now fields removed, n_sections, section_info
	fields added.
	(find_counters_section): Declare.
	* profile.c (struct function_list): count_edges field removed,
	n_counter_sections, counter_sections fields added.
	(set_purpose, label_for_tag, build_counter_section_fields,
	build_counter_section_value, build_counter_section_data_fields,
	build_counter_section_data_value, build_function_info_fields,
	build_function_info_value, build_gcov_info_fields,
	build_gcov_info_value): New static functions.
	(find_counters_section): New function.
	(instrument_edges, get_exec_counts, compute_branch_probabilities,
	branch_prob, create_profiler): Modified to support multiple profile
	sections.

From-SVN: r63474
parent b0d7ef9a
2003-02-26 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* gcov-dump.c (print_prefix): Fix signedness warning.
* gcov-io.h (struct counter_section, struct counter_section_data): New.
(struct function_info): n_arc_counts field removed, n_counter_sections,
counter_sections fields added.
(struct gcov_info): arc_counts, n_arc_counts fields removed,
n_counter_sections, counter_sections fields added.
* libgcov.c (gcov_exit, __gcov_flush): Add support for multiple
profile sections.
* profile.h (MAX_COUNTER_SECTIONS): New.
(struct section_info): New.
(struct profile_info): count_instrumented_edges,
count_edges_instrumented_now fields removed, n_sections, section_info
fields added.
(find_counters_section): Declare.
* profile.c (struct function_list): count_edges field removed,
n_counter_sections, counter_sections fields added.
(set_purpose, label_for_tag, build_counter_section_fields,
build_counter_section_value, build_counter_section_data_fields,
build_counter_section_data_value, build_function_info_fields,
build_function_info_value, build_gcov_info_fields,
build_gcov_info_value): New static functions.
(find_counters_section): New function.
(instrument_edges, get_exec_counts, compute_branch_probabilities,
branch_prob, create_profiler): Modified to support multiple profile
sections.
2003-02-26 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa.c (compute_frame_size): Don't assume PREFERRED_STACK_BOUNDARY
......
......@@ -131,7 +131,7 @@ print_prefix (filename, depth)
{
static const char prefix[] = " ";
printf ("%s:%.*s", filename, depth, prefix);
printf ("%s:%.*s", filename, (int) depth, prefix);
}
static void
......
......@@ -216,16 +216,33 @@ struct gcov_summary
gcov_type arc_sum_max; /* sum of max_one */
};
#if IN_LIBGCC2
/* Structures embedded in coveraged program. The structures generated
by write_profile must match these. */
/* Information about section of counters for a function. */
struct counter_section
{
unsigned tag; /* Tag of the section. */
unsigned n_counters; /* Number of counters in the section. */
};
#if IN_LIBGCC2
/* Information about section of counters for an object file. */
struct counter_section_data
{
unsigned tag; /* Tag of the section. */
unsigned n_counters; /* Number of counters in the section. */
gcov_type *counters; /* The data. */
};
/* Information about a single function. */
struct function_info
{
const char *name; /* (mangled) name of function */
unsigned checksum; /* function checksum */
unsigned n_arc_counts; /* number of instrumented arcs */
unsigned n_counter_sections; /* Number of types of counters */
const struct counter_section *counter_sections;
/* The section descriptions */
};
/* Information about a single object file. */
......@@ -237,11 +254,12 @@ struct gcov_info
const char *filename; /* output file name */
long wkspc; /* libgcc workspace */
const struct function_info *functions; /* table of functions */
unsigned n_functions; /* number of functions */
const struct function_info *functions; /* table of functions */
gcov_type *arc_counts; /* table of arc counts */
unsigned n_arc_counts; /* number of arc counts */
unsigned n_counter_sections; /* Number of types of counters */
const struct counter_section_data *counter_sections;
/* The data to be put into the sections. */
};
/* Register a new object file module. */
......
......@@ -112,14 +112,35 @@ gcov_exit (void)
int merging = 0;
long base;
const struct function_info *fn_info;
gcov_type **counters;
gcov_type *count_ptr;
gcov_type object_max_one = 0;
gcov_type count;
unsigned tag, length, flength, checksum;
unsigned arc_data_index, f_sect_index, sect_index;
ptr->wkspc = 0;
if (!ptr->filename)
continue;
for (ix = ptr->n_arc_counts, count_ptr = ptr->arc_counts; ix--;)
counters = malloc (sizeof (gcov_type *) * ptr->n_counter_sections);
for (ix = 0; ix < ptr->n_counter_sections; ix++)
counters[ix] = ptr->counter_sections[ix].counters;
for (arc_data_index = 0;
arc_data_index < ptr->n_counter_sections
&& ptr->counter_sections[arc_data_index].tag != GCOV_TAG_ARC_COUNTS;
arc_data_index++)
continue;
if (arc_data_index == ptr->n_counter_sections)
{
/* For now; later we may want to just measure other profiles,
but now I am lazy to check for all consequences. */
abort ();
}
for (ix = ptr->counter_sections[arc_data_index].n_counters,
count_ptr = ptr->counter_sections[arc_data_index].counters; ix--;)
{
gcov_type count = *count_ptr++;
......@@ -155,7 +176,6 @@ gcov_exit (void)
if (merging)
{
/* Merge data from file. */
unsigned tag, length;
if (gcov_read_unsigned (da_file, &tag) || tag != GCOV_DATA_MAGIC)
{
......@@ -173,7 +193,6 @@ gcov_exit (void)
}
/* Merge execution counts for each function. */
count_ptr = ptr->arc_counts;
for (ix = ptr->n_functions, fn_info = ptr->functions;
ix--; fn_info++)
{
......@@ -194,33 +213,40 @@ gcov_exit (void)
ptr->filename, fn_info->name);
goto read_fatal;
}
{
unsigned flength, checksum;
if (gcov_read_unsigned (da_file, &flength)
|| gcov_skip_string (da_file, flength)
|| gcov_read_unsigned (da_file, &checksum))
goto read_error;
if (flength != strlen (fn_info->name)
|| checksum != fn_info->checksum)
goto read_mismatch;
}
/* Check arc counts */
if (gcov_read_unsigned (da_file, &tag)
|| gcov_read_unsigned (da_file, &length))
if (gcov_read_unsigned (da_file, &flength)
|| gcov_skip_string (da_file, flength)
|| gcov_read_unsigned (da_file, &checksum))
goto read_error;
if (tag != GCOV_TAG_ARC_COUNTS
|| length / 8 != fn_info->n_arc_counts)
if (flength != strlen (fn_info->name)
|| checksum != fn_info->checksum)
goto read_mismatch;
{
gcov_type count;
for (jx = fn_info->n_arc_counts; jx--; count_ptr++)
if (gcov_read_counter (da_file, &count))
/* Counters. */
for (f_sect_index = 0;
f_sect_index < fn_info->n_counter_sections;
f_sect_index++)
{
if (gcov_read_unsigned (da_file, &tag)
|| gcov_read_unsigned (da_file, &length))
goto read_error;
else
*count_ptr += count;
}
for (sect_index = 0;
sect_index < ptr->n_counter_sections;
sect_index++)
if (ptr->counter_sections[sect_index].tag == tag)
break;
if (fn_info->counter_sections[f_sect_index].tag != tag
|| sect_index == ptr->n_counter_sections
|| length / 8 != fn_info->counter_sections[f_sect_index].n_counters)
goto read_mismatch;
for (jx = fn_info->counter_sections[f_sect_index].n_counters;
jx--; counters[sect_index]++)
if (gcov_read_counter (da_file, &count))
goto read_error;
else
*counters[sect_index] += count;
}
}
/* Check object summary */
......@@ -279,7 +305,7 @@ gcov_exit (void)
}
object.runs++;
object.arcs = ptr->n_arc_counts;
object.arcs = ptr->counter_sections[arc_data_index].n_counters;
object.arc_sum = 0;
if (object.arc_max_one < object_max_one)
object.arc_max_one = object_max_one;
......@@ -299,7 +325,8 @@ gcov_exit (void)
}
/* Write execution counts for each function. */
count_ptr = ptr->arc_counts;
for (ix = 0; ix < ptr->n_counter_sections; ix++)
counters[ix] = ptr->counter_sections[ix].counters;
for (ix = ptr->n_functions, fn_info = ptr->functions; ix--; fn_info++)
{
/* Announce function. */
......@@ -312,24 +339,41 @@ gcov_exit (void)
|| gcov_write_unsigned (da_file, fn_info->checksum)
|| gcov_write_length (da_file, base))
goto write_error;
/* arc counts. */
if (gcov_write_unsigned (da_file, GCOV_TAG_ARC_COUNTS)
|| !(base = gcov_reserve_length (da_file)))
goto write_error;
for (jx = fn_info->n_arc_counts; jx--;)
/* counters. */
for (f_sect_index = 0;
f_sect_index < fn_info->n_counter_sections;
f_sect_index++)
{
gcov_type count = *count_ptr++;
tag = fn_info->counter_sections[f_sect_index].tag;
for (sect_index = 0;
sect_index < ptr->n_counter_sections;
sect_index++)
if (ptr->counter_sections[sect_index].tag == tag)
break;
if (sect_index == ptr->n_counter_sections)
abort ();
if (gcov_write_unsigned (da_file, tag)
|| !(base = gcov_reserve_length (da_file)))
goto write_error;
for (jx = fn_info->counter_sections[f_sect_index].n_counters; jx--;)
{
gcov_type count = *counters[sect_index]++;
object.arc_sum += count;
if (object.arc_max_sum < count)
object.arc_max_sum = count;
if (gcov_write_counter (da_file, count))
goto write_error; /* RIP Edsger Dijkstra */
if (tag == GCOV_TAG_ARC_COUNTS)
{
object.arc_sum += count;
if (object.arc_max_sum < count)
object.arc_max_sum = count;
}
if (gcov_write_counter (da_file, count))
goto write_error; /* RIP Edsger Dijkstra */
}
if (gcov_write_length (da_file, base))
goto write_error;
}
if (gcov_write_length (da_file, base))
goto write_error;
}
/* Object file summary. */
......@@ -367,11 +411,12 @@ gcov_exit (void)
}
else
{
program_arcs += ptr->n_arc_counts;
program_arcs += ptr->counter_sections[arc_data_index].n_counters;
program_sum += object.arc_sum;
if (program_max_sum < object.arc_max_sum)
program_max_sum = object.arc_max_sum;
}
free(counters);
}
/* Generate whole program statistics. */
......@@ -465,9 +510,10 @@ __gcov_flush (void)
gcov_exit ();
for (ptr = gcov_list; ptr; ptr = ptr->next)
{
unsigned i;
unsigned i, j;
for (i = ptr->n_arc_counts; i--;)
ptr->arc_counts[i] = 0;
for (j = 0; j < ptr->n_counter_sections; j++)
for (i = ptr->counter_sections[j].n_counters; i--;)
ptr->counter_sections[j].counters[i] = 0;
}
}
......@@ -21,18 +21,25 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_PROFILE_H
#define GCC_PROFILE_H
/* The number of different counter sections. */
#define MAX_COUNTER_SECTIONS 1
/* Info about number of counters in the section. */
struct section_info
{
unsigned tag; /* Section tag. */
int present; /* Are the data from this section read into gcc? */
int n_counters; /* Total number of counters. */
int n_counters_now; /* Number of counters in the current function. */
};
struct profile_info
{
/* Used by final, for allocating the proper amount of storage for the
instrumented arc execution counts. */
int count_instrumented_edges;
/* Used by final, for writing correct # of instrumented edges
in this function. */
int count_edges_instrumented_now;
/* Information about numbers of counters in counter sections, for
allocating the storage and storing the sizes. */
unsigned n_sections;
struct section_info section_info[MAX_COUNTER_SECTIONS];
/* Checksum of the cfg. Used for 'identification' of code.
Used by final. */
......@@ -46,9 +53,10 @@ struct profile_info
/* The number of profiles merged to form the profile data for the current
function. */
int count_profiles_merged;
};
extern struct profile_info profile_info;
struct section_info *find_counters_section PARAMS ((unsigned));
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment