Commit 796621e8 by Nathan Sidwell Committed by Nathan Sidwell

New GCOV_TAG_FUNCTION layout

	New GCOV_TAG_FUNCTION layout
	* coverage.c (struct function_list): Replace name with ident.
	(struct counts_entry): Likewise.
	(fn_ident): New.
	(htab_counts_entry_hash, htab_counts_entry_eq,
	htab_counts_entry_del): Adjust.
	(reads_count_file, get_coverage_counts,
	coverage_begin_output, coverage_end_function): Adjust.
	(build_fn_info_type, build_fn_info_value): Likewise.
	* gcov-dump.c (tag_function): Adjust.
	* gcov-io.c (gcov_write_string, gcov_read_string): Not in LIBGCOV.
	* gcov-io.h (gcov_write_string, gcov_read_string): Not in LIBGCOV.
	* gcov.c (struct function_info): Add ident.
	(read_graph_file, read_count_file): Adjust.
	* libgcov.c (gcov_exit): Adjust.

From-SVN: r66035
parent 374ca7f7
2003-04-24 Nathan Sidwell <nathan@codesourcery.com>
New GCOV_TAG_FUNCTION layout
* coverage.c (struct function_list): Replace name with ident.
(struct counts_entry): Likewise.
(fn_ident): New.
(htab_counts_entry_hash, htab_counts_entry_eq,
htab_counts_entry_del): Adjust.
(reads_count_file, get_coverage_counts,
coverage_begin_output, coverage_end_function): Adjust.
(build_fn_info_type, build_fn_info_value): Likewise.
* gcov-dump.c (tag_function): Adjust.
* gcov-io.c (gcov_write_string, gcov_read_string): Not in LIBGCOV.
* gcov-io.h (gcov_write_string, gcov_read_string): Not in LIBGCOV.
* gcov.c (struct function_info): Add ident.
(read_graph_file, read_count_file): Adjust.
* libgcov.c (gcov_exit): Adjust.
2003-04-23 Richard Henderson <rth@redhat.com> 2003-04-23 Richard Henderson <rth@redhat.com>
PR opt/8300 PR opt/8300
......
...@@ -50,7 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -50,7 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
struct function_list struct function_list
{ {
struct function_list *next; /* next function */ struct function_list *next; /* next function */
const char *name; /* function name */ unsigned ident; /* function ident */
unsigned checksum; /* function checksum */ unsigned checksum; /* function checksum */
unsigned n_ctrs[GCOV_COUNTERS];/* number of counters. */ unsigned n_ctrs[GCOV_COUNTERS];/* number of counters. */
}; };
...@@ -59,7 +59,7 @@ struct function_list ...@@ -59,7 +59,7 @@ struct function_list
typedef struct counts_entry typedef struct counts_entry
{ {
/* We hash by */ /* We hash by */
char *function_name; unsigned ident;
unsigned ctr; unsigned ctr;
/* Store */ /* Store */
...@@ -72,6 +72,7 @@ typedef struct counts_entry ...@@ -72,6 +72,7 @@ typedef struct counts_entry
} counts_entry_t; } counts_entry_t;
static unsigned fn_ident = 1;
static struct function_list *functions_head = 0; static struct function_list *functions_head = 0;
static struct function_list **functions_tail = &functions_head; static struct function_list **functions_tail = &functions_head;
...@@ -118,7 +119,7 @@ htab_counts_entry_hash (of) ...@@ -118,7 +119,7 @@ htab_counts_entry_hash (of)
{ {
const counts_entry_t *entry = of; const counts_entry_t *entry = of;
return htab_hash_string (entry->function_name) ^ entry->ctr; return entry->ident * GCOV_COUNTERS + entry->ctr;
} }
static int static int
...@@ -129,8 +130,7 @@ htab_counts_entry_eq (of1, of2) ...@@ -129,8 +130,7 @@ htab_counts_entry_eq (of1, of2)
const counts_entry_t *entry1 = of1; const counts_entry_t *entry1 = of1;
const counts_entry_t *entry2 = of2; const counts_entry_t *entry2 = of2;
return !strcmp (entry1->function_name, entry2->function_name) return entry1->ident == entry2->ident && entry1->ctr == entry2->ctr;
&& entry1->ctr == entry2->ctr;
} }
static void static void
...@@ -139,7 +139,6 @@ htab_counts_entry_del (of) ...@@ -139,7 +139,6 @@ htab_counts_entry_del (of)
{ {
counts_entry_t *entry = of; counts_entry_t *entry = of;
free (entry->function_name);
free (entry->counts); free (entry->counts);
free (entry); free (entry);
} }
...@@ -149,7 +148,7 @@ htab_counts_entry_del (of) ...@@ -149,7 +148,7 @@ htab_counts_entry_del (of)
static void static void
read_counts_file () read_counts_file ()
{ {
char *function_name_buffer = NULL; unsigned fn_ident = 0;
unsigned version, ix, checksum = -1; unsigned version, ix, checksum = -1;
counts_entry_t *summaried = NULL; counts_entry_t *summaried = NULL;
unsigned seen_summary = 0; unsigned seen_summary = 0;
...@@ -193,9 +192,7 @@ read_counts_file () ...@@ -193,9 +192,7 @@ read_counts_file ()
offset = gcov_position (); offset = gcov_position ();
if (tag == GCOV_TAG_FUNCTION) if (tag == GCOV_TAG_FUNCTION)
{ {
const char *string = gcov_read_string (); fn_ident = gcov_read_unsigned ();
free (function_name_buffer);
function_name_buffer = string ? xstrdup (string) : NULL;
checksum = gcov_read_unsigned (); checksum = gcov_read_unsigned ();
if (seen_summary) if (seen_summary)
{ {
...@@ -231,13 +228,13 @@ read_counts_file () ...@@ -231,13 +228,13 @@ read_counts_file ()
entry->summary.sum_max += csum->sum_max; entry->summary.sum_max += csum->sum_max;
} }
} }
else if (GCOV_TAG_IS_COUNTER (tag) && function_name_buffer) else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident)
{ {
counts_entry_t **slot, *entry, elt; counts_entry_t **slot, *entry, elt;
unsigned n_counts = length / 8; unsigned n_counts = length / 8;
unsigned ix; unsigned ix;
elt.function_name = function_name_buffer; elt.ident = fn_ident;
elt.ctr = GCOV_COUNTER_FOR_TAG (tag); elt.ctr = GCOV_COUNTER_FOR_TAG (tag);
slot = (counts_entry_t **) htab_find_slot slot = (counts_entry_t **) htab_find_slot
...@@ -246,7 +243,7 @@ read_counts_file () ...@@ -246,7 +243,7 @@ read_counts_file ()
if (!entry) if (!entry)
{ {
*slot = entry = xcalloc (1, sizeof (counts_entry_t)); *slot = entry = xcalloc (1, sizeof (counts_entry_t));
entry->function_name = xstrdup (elt.function_name); entry->ident = elt.ident;
entry->ctr = elt.ctr; entry->ctr = elt.ctr;
entry->checksum = checksum; entry->checksum = checksum;
entry->summary.num = n_counts; entry->summary.num = n_counts;
...@@ -255,7 +252,7 @@ read_counts_file () ...@@ -255,7 +252,7 @@ read_counts_file ()
else if (entry->checksum != checksum else if (entry->checksum != checksum
|| entry->summary.num != n_counts) || entry->summary.num != n_counts)
{ {
warning ("profile mismatch for `%s'", function_name_buffer); warning ("coverage mismatch for function %u", fn_ident);
htab_delete (counts_hash); htab_delete (counts_hash);
break; break;
} }
...@@ -281,7 +278,6 @@ read_counts_file () ...@@ -281,7 +278,6 @@ read_counts_file ()
} }
} }
free (function_name_buffer);
gcov_close (); gcov_close ();
} }
...@@ -304,24 +300,24 @@ get_coverage_counts (unsigned counter, unsigned expected, ...@@ -304,24 +300,24 @@ get_coverage_counts (unsigned counter, unsigned expected,
return NULL; return NULL;
} }
elt.function_name elt.ident = fn_ident;
= (char *) IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl));
elt.ctr = counter; elt.ctr = counter;
entry = htab_find (counts_hash, &elt); entry = htab_find (counts_hash, &elt);
if (!entry) if (!entry)
{ {
warning ("No profile for function '%s' found.", elt.function_name); warning ("no coverage for function '%s' found.", IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl)));
return 0; return 0;
} }
if (expected != entry->summary.num if (expected != entry->summary.num
|| compute_checksum () != entry->checksum) || compute_checksum () != entry->checksum)
{ {
warning ("profile mismatch for `%s'", elt.function_name); warning ("coverage mismatch for `%s'", IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl)));
return NULL; return NULL;
} }
if (summary) if (summary)
*summary = &entry->summary; *summary = &entry->summary;
...@@ -426,9 +422,10 @@ coverage_begin_output () ...@@ -426,9 +422,10 @@ coverage_begin_output ()
/* Announce function */ /* Announce function */
offset = gcov_write_tag (GCOV_TAG_FUNCTION); offset = gcov_write_tag (GCOV_TAG_FUNCTION);
gcov_write_unsigned (fn_ident);
gcov_write_unsigned (compute_checksum ());
gcov_write_string (IDENTIFIER_POINTER gcov_write_string (IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl))); (DECL_ASSEMBLER_NAME (current_function_decl)));
gcov_write_unsigned (compute_checksum ());
gcov_write_string (file); gcov_write_string (file);
gcov_write_unsigned (line); gcov_write_unsigned (line);
gcov_write_length (offset); gcov_write_length (offset);
...@@ -456,15 +453,14 @@ coverage_end_function () ...@@ -456,15 +453,14 @@ coverage_end_function ()
{ {
struct function_list *item; struct function_list *item;
/* ??? Probably should re-use the existing struct function. */
item = xmalloc (sizeof (struct function_list)); item = xmalloc (sizeof (struct function_list));
*functions_tail = item; *functions_tail = item;
functions_tail = &item->next; functions_tail = &item->next;
item->next = 0; item->next = 0;
item->name = xstrdup (IDENTIFIER_POINTER /* It would be nice to use the unique source location. */
(DECL_ASSEMBLER_NAME (current_function_decl))); item->ident = fn_ident;
item->checksum = compute_checksum (); item->checksum = compute_checksum ();
for (i = 0; i != GCOV_COUNTERS; i++) for (i = 0; i != GCOV_COUNTERS; i++)
{ {
...@@ -476,6 +472,7 @@ coverage_end_function () ...@@ -476,6 +472,7 @@ coverage_end_function ()
fn_ctr_mask = 0; fn_ctr_mask = 0;
} }
bbg_function_announced = 0; bbg_function_announced = 0;
fn_ident++;
} }
/* Creates the gcov_fn_info RECORD_TYPE. */ /* Creates the gcov_fn_info RECORD_TYPE. */
...@@ -486,13 +483,10 @@ build_fn_info_type (counters) ...@@ -486,13 +483,10 @@ build_fn_info_type (counters)
{ {
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE); tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
tree field, fields; tree field, fields;
tree string_type =
build_pointer_type (build_qualified_type (char_type_node,
TYPE_QUAL_CONST));
tree array_type; tree array_type;
/* name */ /* ident */
fields = build_decl (FIELD_DECL, NULL_TREE, string_type); fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
/* checksum */ /* checksum */
field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
...@@ -523,20 +517,13 @@ build_fn_info_value (function, type) ...@@ -523,20 +517,13 @@ build_fn_info_value (function, type)
{ {
tree value = NULL_TREE; tree value = NULL_TREE;
tree fields = TYPE_FIELDS (type); tree fields = TYPE_FIELDS (type);
size_t name_len = strlen (function->name);
tree fname = build_string (name_len + 1, function->name);
tree string_type =
build_pointer_type (build_qualified_type (char_type_node,
TYPE_QUAL_CONST));
unsigned ix; unsigned ix;
tree array_value = NULL_TREE; tree array_value = NULL_TREE;
/* name */ /* ident */
TREE_TYPE (fname) =
build_array_type (char_type_node,
build_index_type (build_int_2 (name_len, 0)));
value = tree_cons (fields, value = tree_cons (fields,
build1 (ADDR_EXPR, string_type, fname), convert (unsigned_type_node,
build_int_2 (function->ident, 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
...@@ -854,16 +841,17 @@ coverage_init (filename) ...@@ -854,16 +841,17 @@ coverage_init (filename)
{ {
int len = strlen (filename); int len = strlen (filename);
/* Name of da file. */
da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1); da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1);
strcpy (da_file_name, filename); strcpy (da_file_name, filename);
strcat (da_file_name, GCOV_DATA_SUFFIX); strcat (da_file_name, GCOV_DATA_SUFFIX);
read_counts_file (); /* Name of bbg file. */
/* Open the bbg output file. */
bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1); bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1);
strcpy (bbg_file_name, filename); strcpy (bbg_file_name, filename);
strcat (bbg_file_name, GCOV_GRAPH_SUFFIX); strcat (bbg_file_name, GCOV_GRAPH_SUFFIX);
read_counts_file ();
} }
/* Performs file-level cleanup. Close graph file, generate coverage /* Performs file-level cleanup. Close graph file, generate coverage
......
...@@ -254,15 +254,17 @@ tag_function (filename, tag, length) ...@@ -254,15 +254,17 @@ tag_function (filename, tag, length)
unsigned tag ATTRIBUTE_UNUSED; unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED; unsigned length ATTRIBUTE_UNUSED;
{ {
const char *name;
unsigned long pos = gcov_position (); unsigned long pos = gcov_position ();
name = gcov_read_string (); printf (" ident=%u", gcov_read_unsigned ());
printf (" `%s'", name ? name : "NULL"); printf (", checksum=0x%08x", gcov_read_unsigned ());
printf (" checksum=0x%08x", gcov_read_unsigned ());
if (gcov_position () - pos < length) if (gcov_position () - pos < length)
{ {
const char *name;
name = gcov_read_string ();
printf (", `%s'", name ? name : "NULL");
name = gcov_read_string (); name = gcov_read_string ();
printf (" %s", name ? name : "NULL"); printf (" %s", name ? name : "NULL");
printf (":%u", gcov_read_unsigned ()); printf (":%u", gcov_read_unsigned ());
......
...@@ -222,6 +222,7 @@ gcov_write_counter (gcov_type value) ...@@ -222,6 +222,7 @@ gcov_write_counter (gcov_type value)
} }
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
#if !IN_LIBGCOV
/* Write STRING to coverage file. Sets error flag on file /* Write STRING to coverage file. Sets error flag on file
error, overflow flag on overflow */ error, overflow flag on overflow */
...@@ -254,6 +255,7 @@ gcov_write_string (const char *string) ...@@ -254,6 +255,7 @@ gcov_write_string (const char *string)
memcpy (buffer + 4 + length, &pad, rem); memcpy (buffer + 4 + length, &pad, rem);
} }
} }
#endif
/* Write a tag TAG and reserve space for the record length. Return a /* Write a tag TAG and reserve space for the record length. Return a
value to be used for gcov_write_length. */ value to be used for gcov_write_length. */
...@@ -396,6 +398,7 @@ gcov_read_counter () ...@@ -396,6 +398,7 @@ gcov_read_counter ()
buffer, or NULL on empty string. You must copy the string before buffer, or NULL on empty string. You must copy the string before
calling another gcov function. */ calling another gcov function. */
#if !IN_LIBGCOV
GCOV_LINKAGE const char * GCOV_LINKAGE const char *
gcov_read_string () gcov_read_string ()
{ {
...@@ -407,6 +410,7 @@ gcov_read_string () ...@@ -407,6 +410,7 @@ gcov_read_string ()
length += 4 - (length & 3); length += 4 - (length & 3);
return (const char *) gcov_read_bytes (length); return (const char *) gcov_read_bytes (length);
} }
#endif
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_read_summary (struct gcov_summary *summary) gcov_read_summary (struct gcov_summary *summary)
......
...@@ -95,10 +95,11 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -95,10 +95,11 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
file and [a1..ff] for the counter file. file and [a1..ff] for the counter file.
The basic block graph file contains the following records The basic block graph file contains the following records
bbg: function-graph* bbg: unit function-graph*
unit: header int32:checksum string:source
function-graph: announce_function basic_blocks {arcs | lines}* function-graph: announce_function basic_blocks {arcs | lines}*
announce_function: header string:name int32:checksum announce_function: header int32:ident int32:checksum
string:source int32:lineno string:name string:source int32:lineno
basic_block: header int32:flags* basic_block: header int32:flags*
arcs: header int32:block_no arc* arcs: header int32:block_no arc*
arc: int32:dest_block int32:flags arc: int32:dest_block int32:flags
...@@ -123,9 +124,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -123,9 +124,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
blocks they are for. blocks they are for.
The data file contains the following records. The data file contains the following records.
da: {function-data* summary:object summary:program*}* da: {unit function-data* summary:object summary:program*}*
unit: header int32:checksum
function-data: announce_function arc_counts function-data: announce_function arc_counts
announce_function: header string:name int32:checksum announce_function: header int32:ident int32:checksum
arc_counts: header int64:count* arc_counts: header int64:count*
summary: int32:checksum {count-summary}GCOV_COUNTERS summary: int32:checksum {count-summary}GCOV_COUNTERS
count-summary: int32:num int32:runs int64:sum count-summary: int32:num int32:runs int64:sum
...@@ -279,7 +281,7 @@ struct gcov_summary ...@@ -279,7 +281,7 @@ struct gcov_summary
explicitly calculate the correct array stride. */ explicitly calculate the correct array stride. */
struct gcov_fn_info struct gcov_fn_info
{ {
const char *name; /* (mangled) name of function */ unsigned ident; /* unique ident of function */
unsigned checksum; /* function checksum */ unsigned checksum; /* function checksum */
unsigned n_ctrs[0]; /* instrumented counters */ unsigned n_ctrs[0]; /* instrumented counters */
}; };
...@@ -339,8 +341,9 @@ GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned); ...@@ -339,8 +341,9 @@ GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned);
GCOV_LINKAGE void gcov_write_unsigned (unsigned); GCOV_LINKAGE void gcov_write_unsigned (unsigned);
#if IN_LIBGCOV #if IN_LIBGCOV
GCOV_LINKAGE void gcov_write_counter (gcov_type); GCOV_LINKAGE void gcov_write_counter (gcov_type);
#endif #else
GCOV_LINKAGE void gcov_write_string (const char *); GCOV_LINKAGE void gcov_write_string (const char *);
#endif
GCOV_LINKAGE unsigned long gcov_write_tag (unsigned); GCOV_LINKAGE unsigned long gcov_write_tag (unsigned);
GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/); GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/);
#if IN_LIBGCOV #if IN_LIBGCOV
...@@ -350,9 +353,10 @@ GCOV_LINKAGE void gcov_write_summary (unsigned, const struct gcov_summary *); ...@@ -350,9 +353,10 @@ GCOV_LINKAGE void gcov_write_summary (unsigned, const struct gcov_summary *);
GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned); GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned);
GCOV_LINKAGE unsigned gcov_read_unsigned (void); GCOV_LINKAGE unsigned gcov_read_unsigned (void);
GCOV_LINKAGE gcov_type gcov_read_counter (void); GCOV_LINKAGE gcov_type gcov_read_counter (void);
#if !IN_LIBGCOV
GCOV_LINKAGE const char *gcov_read_string (void); GCOV_LINKAGE const char *gcov_read_string (void);
#endif
GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *); GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *);
static unsigned long gcov_position (void); static unsigned long gcov_position (void);
static void gcov_seek (unsigned long /*base*/, unsigned /*length */); static void gcov_seek (unsigned long /*base*/, unsigned /*length */);
static unsigned long gcov_seek_end (void); static unsigned long gcov_seek_end (void);
......
...@@ -168,6 +168,7 @@ typedef struct function_info ...@@ -168,6 +168,7 @@ typedef struct function_info
{ {
/* Name of function. */ /* Name of function. */
char *name; char *name;
unsigned ident;
unsigned checksum; unsigned checksum;
/* Array of basic blocks. */ /* Array of basic blocks. */
...@@ -744,21 +745,23 @@ read_graph_file () ...@@ -744,21 +745,23 @@ read_graph_file ()
unsigned tag = gcov_read_unsigned (); unsigned tag = gcov_read_unsigned ();
unsigned length = gcov_read_unsigned (); unsigned length = gcov_read_unsigned ();
unsigned long base = gcov_position (); unsigned long base = gcov_position ();
if (tag == GCOV_TAG_FUNCTION) if (tag == GCOV_TAG_FUNCTION)
{ {
char *function_name; char *function_name;
unsigned checksum, lineno; unsigned ident, checksum, lineno;
source_t *src; source_t *src;
function_t *probe, *prev; function_t *probe, *prev;
function_name = xstrdup (gcov_read_string ()); ident = gcov_read_unsigned ();
checksum = gcov_read_unsigned (); checksum = gcov_read_unsigned ();
function_name = xstrdup (gcov_read_string ());
src = find_source (gcov_read_string ()); src = find_source (gcov_read_string ());
lineno = gcov_read_unsigned (); lineno = gcov_read_unsigned ();
fn = (function_t *)xcalloc (1, sizeof (function_t)); fn = (function_t *)xcalloc (1, sizeof (function_t));
fn->name = function_name; fn->name = function_name;
fn->ident = ident;
fn->checksum = checksum; fn->checksum = checksum;
fn->src = src; fn->src = src;
fn->line = lineno; fn->line = lineno;
...@@ -1015,7 +1018,7 @@ read_count_file () ...@@ -1015,7 +1018,7 @@ read_count_file ()
program_count++; program_count++;
else if (tag == GCOV_TAG_FUNCTION) else if (tag == GCOV_TAG_FUNCTION)
{ {
const char *function_name = gcov_read_string (); unsigned ident = gcov_read_unsigned ();
struct function_info *fn_n = functions; struct function_info *fn_n = functions;
for (fn = fn ? fn->next : NULL; ; fn = fn->next) for (fn = fn ? fn->next : NULL; ; fn = fn->next)
...@@ -1026,11 +1029,11 @@ read_count_file () ...@@ -1026,11 +1029,11 @@ read_count_file ()
fn_n = NULL; fn_n = NULL;
else else
{ {
fnotice (stderr, "%s:unknown function `%s'\n", fnotice (stderr, "%s:unknown function `%u'\n",
da_file_name, function_name); da_file_name, ident);
break; break;
} }
if (!strcmp (fn->name, function_name)) if (fn->ident == ident)
break; break;
} }
......
...@@ -203,7 +203,8 @@ gcov_exit (void) ...@@ -203,7 +203,8 @@ gcov_exit (void)
} }
/* Merge execution counts for each function. */ /* Merge execution counts for each function. */
for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--; for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions;
f_ix--;
fi_ptr = (const struct gcov_fn_info *) fi_ptr = (const struct gcov_fn_info *)
((const char *) fi_ptr + fi_stride)) ((const char *) fi_ptr + fi_stride))
{ {
...@@ -211,19 +212,17 @@ gcov_exit (void) ...@@ -211,19 +212,17 @@ gcov_exit (void)
length = gcov_read_unsigned (); length = gcov_read_unsigned ();
/* Check function */ /* Check function */
if (tag != GCOV_TAG_FUNCTION) if (tag != GCOV_TAG_FUNCTION
|| gcov_read_unsigned () != fi_ptr->ident
|| gcov_read_unsigned () != fi_ptr->checksum)
{ {
read_mismatch:; read_mismatch:;
fprintf (stderr, "profiling:%s:Merge mismatch for %s\n", fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
gi_ptr->filename, gi_ptr->filename,
fi_ptr ? fi_ptr->name : "summaries"); f_ix + 1 ? "function" : "summaries");
goto read_fatal; goto read_fatal;
} }
if (strcmp (gcov_read_string (), fi_ptr->name)
|| gcov_read_unsigned () != fi_ptr->checksum)
goto read_mismatch;
for (c_ix = t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++) for (c_ix = t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
if ((1 << t_ix) & gi_ptr->ctr_mask) if ((1 << t_ix) & gi_ptr->ctr_mask)
{ {
...@@ -284,9 +283,8 @@ gcov_exit (void) ...@@ -284,9 +283,8 @@ gcov_exit (void)
if (!summary_pos) if (!summary_pos)
memset (&program, 0, sizeof (program)); memset (&program, 0, sizeof (program));
fi_ptr = 0;
/* Merge the summaries. */ /* Merge the summaries. */
f_ix = ~0u;
for (t_ix = c_ix = 0, for (t_ix = c_ix = 0,
cs_obj = object.ctrs, cs_tobj = this_object.ctrs, cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
cs_prg = program.ctrs, cs_tprg = this_program.ctrs, cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
...@@ -346,7 +344,7 @@ gcov_exit (void) ...@@ -346,7 +344,7 @@ gcov_exit (void)
{ {
/* Announce function. */ /* Announce function. */
base = gcov_write_tag (GCOV_TAG_FUNCTION); base = gcov_write_tag (GCOV_TAG_FUNCTION);
gcov_write_string (fi_ptr->name); gcov_write_unsigned (fi_ptr->ident);
gcov_write_unsigned (fi_ptr->checksum); gcov_write_unsigned (fi_ptr->checksum);
gcov_write_length (base); gcov_write_length (base);
......
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