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> 2003-02-26 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa.c (compute_frame_size): Don't assume PREFERRED_STACK_BOUNDARY * pa.c (compute_frame_size): Don't assume PREFERRED_STACK_BOUNDARY
......
...@@ -131,7 +131,7 @@ print_prefix (filename, depth) ...@@ -131,7 +131,7 @@ print_prefix (filename, depth)
{ {
static const char prefix[] = " "; static const char prefix[] = " ";
printf ("%s:%.*s", filename, depth, prefix); printf ("%s:%.*s", filename, (int) depth, prefix);
} }
static void static void
......
...@@ -216,16 +216,33 @@ struct gcov_summary ...@@ -216,16 +216,33 @@ struct gcov_summary
gcov_type arc_sum_max; /* sum of max_one */ gcov_type arc_sum_max; /* sum of max_one */
}; };
#if IN_LIBGCC2
/* Structures embedded in coveraged program. The structures generated /* Structures embedded in coveraged program. The structures generated
by write_profile must match these. */ 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. */ /* Information about a single function. */
struct function_info struct function_info
{ {
const char *name; /* (mangled) name of function */ const char *name; /* (mangled) name of function */
unsigned checksum; /* function checksum */ 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. */ /* Information about a single object file. */
...@@ -237,11 +254,12 @@ struct gcov_info ...@@ -237,11 +254,12 @@ struct gcov_info
const char *filename; /* output file name */ const char *filename; /* output file name */
long wkspc; /* libgcc workspace */ long wkspc; /* libgcc workspace */
const struct function_info *functions; /* table of functions */
unsigned n_functions; /* number 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_counter_sections; /* Number of types of counters */
unsigned n_arc_counts; /* number of arc counts */ const struct counter_section_data *counter_sections;
/* The data to be put into the sections. */
}; };
/* Register a new object file module. */ /* Register a new object file module. */
......
...@@ -112,14 +112,35 @@ gcov_exit (void) ...@@ -112,14 +112,35 @@ gcov_exit (void)
int merging = 0; int merging = 0;
long base; long base;
const struct function_info *fn_info; const struct function_info *fn_info;
gcov_type **counters;
gcov_type *count_ptr; gcov_type *count_ptr;
gcov_type object_max_one = 0; 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; ptr->wkspc = 0;
if (!ptr->filename) if (!ptr->filename)
continue; 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++; gcov_type count = *count_ptr++;
...@@ -155,7 +176,6 @@ gcov_exit (void) ...@@ -155,7 +176,6 @@ gcov_exit (void)
if (merging) if (merging)
{ {
/* Merge data from file. */ /* Merge data from file. */
unsigned tag, length;
if (gcov_read_unsigned (da_file, &tag) || tag != GCOV_DATA_MAGIC) if (gcov_read_unsigned (da_file, &tag) || tag != GCOV_DATA_MAGIC)
{ {
...@@ -173,7 +193,6 @@ gcov_exit (void) ...@@ -173,7 +193,6 @@ gcov_exit (void)
} }
/* Merge execution counts for each function. */ /* Merge execution counts for each function. */
count_ptr = ptr->arc_counts;
for (ix = ptr->n_functions, fn_info = ptr->functions; for (ix = ptr->n_functions, fn_info = ptr->functions;
ix--; fn_info++) ix--; fn_info++)
{ {
...@@ -194,8 +213,6 @@ gcov_exit (void) ...@@ -194,8 +213,6 @@ gcov_exit (void)
ptr->filename, fn_info->name); ptr->filename, fn_info->name);
goto read_fatal; goto read_fatal;
} }
{
unsigned flength, checksum;
if (gcov_read_unsigned (da_file, &flength) if (gcov_read_unsigned (da_file, &flength)
|| gcov_skip_string (da_file, flength) || gcov_skip_string (da_file, flength)
...@@ -204,22 +221,31 @@ gcov_exit (void) ...@@ -204,22 +221,31 @@ gcov_exit (void)
if (flength != strlen (fn_info->name) if (flength != strlen (fn_info->name)
|| checksum != fn_info->checksum) || checksum != fn_info->checksum)
goto read_mismatch; goto read_mismatch;
}
/* Check arc counts */ /* Counters. */
for (f_sect_index = 0;
f_sect_index < fn_info->n_counter_sections;
f_sect_index++)
{
if (gcov_read_unsigned (da_file, &tag) if (gcov_read_unsigned (da_file, &tag)
|| gcov_read_unsigned (da_file, &length)) || gcov_read_unsigned (da_file, &length))
goto read_error; goto read_error;
if (tag != GCOV_TAG_ARC_COUNTS for (sect_index = 0;
|| length / 8 != fn_info->n_arc_counts) 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; goto read_mismatch;
{
gcov_type count;
for (jx = fn_info->n_arc_counts; jx--; count_ptr++) for (jx = fn_info->counter_sections[f_sect_index].n_counters;
jx--; counters[sect_index]++)
if (gcov_read_counter (da_file, &count)) if (gcov_read_counter (da_file, &count))
goto read_error; goto read_error;
else else
*count_ptr += count; *counters[sect_index] += count;
} }
} }
...@@ -279,7 +305,7 @@ gcov_exit (void) ...@@ -279,7 +305,7 @@ gcov_exit (void)
} }
object.runs++; object.runs++;
object.arcs = ptr->n_arc_counts; object.arcs = ptr->counter_sections[arc_data_index].n_counters;
object.arc_sum = 0; object.arc_sum = 0;
if (object.arc_max_one < object_max_one) if (object.arc_max_one < object_max_one)
object.arc_max_one = object_max_one; object.arc_max_one = object_max_one;
...@@ -299,7 +325,8 @@ gcov_exit (void) ...@@ -299,7 +325,8 @@ gcov_exit (void)
} }
/* Write execution counts for each function. */ /* 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++) for (ix = ptr->n_functions, fn_info = ptr->functions; ix--; fn_info++)
{ {
/* Announce function. */ /* Announce function. */
...@@ -313,24 +340,41 @@ gcov_exit (void) ...@@ -313,24 +340,41 @@ gcov_exit (void)
|| gcov_write_length (da_file, base)) || gcov_write_length (da_file, base))
goto write_error; goto write_error;
/* arc counts. */ /* counters. */
if (gcov_write_unsigned (da_file, GCOV_TAG_ARC_COUNTS) for (f_sect_index = 0;
f_sect_index < fn_info->n_counter_sections;
f_sect_index++)
{
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))) || !(base = gcov_reserve_length (da_file)))
goto write_error; goto write_error;
for (jx = fn_info->n_arc_counts; jx--;) for (jx = fn_info->counter_sections[f_sect_index].n_counters; jx--;)
{ {
gcov_type count = *count_ptr++; gcov_type count = *counters[sect_index]++;
if (tag == GCOV_TAG_ARC_COUNTS)
{
object.arc_sum += count; object.arc_sum += count;
if (object.arc_max_sum < count) if (object.arc_max_sum < count)
object.arc_max_sum = count; object.arc_max_sum = count;
}
if (gcov_write_counter (da_file, count)) if (gcov_write_counter (da_file, count))
goto write_error; /* RIP Edsger Dijkstra */ goto write_error; /* RIP Edsger Dijkstra */
} }
if (gcov_write_length (da_file, base)) if (gcov_write_length (da_file, base))
goto write_error; goto write_error;
} }
}
/* Object file summary. */ /* Object file summary. */
if (gcov_write_summary (da_file, GCOV_TAG_OBJECT_SUMMARY, &object)) if (gcov_write_summary (da_file, GCOV_TAG_OBJECT_SUMMARY, &object))
...@@ -367,11 +411,12 @@ gcov_exit (void) ...@@ -367,11 +411,12 @@ gcov_exit (void)
} }
else else
{ {
program_arcs += ptr->n_arc_counts; program_arcs += ptr->counter_sections[arc_data_index].n_counters;
program_sum += object.arc_sum; program_sum += object.arc_sum;
if (program_max_sum < object.arc_max_sum) if (program_max_sum < object.arc_max_sum)
program_max_sum = object.arc_max_sum; program_max_sum = object.arc_max_sum;
} }
free(counters);
} }
/* Generate whole program statistics. */ /* Generate whole program statistics. */
...@@ -465,9 +510,10 @@ __gcov_flush (void) ...@@ -465,9 +510,10 @@ __gcov_flush (void)
gcov_exit (); gcov_exit ();
for (ptr = gcov_list; ptr; ptr = ptr->next) for (ptr = gcov_list; ptr; ptr = ptr->next)
{ {
unsigned i; unsigned i, j;
for (i = ptr->n_arc_counts; i--;) for (j = 0; j < ptr->n_counter_sections; j++)
ptr->arc_counts[i] = 0; for (i = ptr->counter_sections[j].n_counters; i--;)
ptr->counter_sections[j].counters[i] = 0;
} }
} }
...@@ -21,17 +21,24 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -21,17 +21,24 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_PROFILE_H #ifndef GCC_PROFILE_H
#define 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 struct profile_info
{ {
/* Used by final, for allocating the proper amount of storage for the /* Information about numbers of counters in counter sections, for
instrumented arc execution counts. */ allocating the storage and storing the sizes. */
unsigned n_sections;
int count_instrumented_edges; struct section_info section_info[MAX_COUNTER_SECTIONS];
/* Used by final, for writing correct # of instrumented edges
in this function. */
int count_edges_instrumented_now;
/* Checksum of the cfg. Used for 'identification' of code. /* Checksum of the cfg. Used for 'identification' of code.
Used by final. */ Used by final. */
...@@ -46,9 +53,10 @@ struct profile_info ...@@ -46,9 +53,10 @@ struct profile_info
/* The number of profiles merged to form the profile data for the current /* The number of profiles merged to form the profile data for the current
function. */ function. */
int count_profiles_merged; int count_profiles_merged;
}; };
extern struct profile_info profile_info; extern struct profile_info profile_info;
struct section_info *find_counters_section PARAMS ((unsigned));
#endif #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