aboutsummaryrefslogtreecommitdiff
path: root/libgcc/libgcov.c
diff options
context:
space:
mode:
authorSharad Singhai <singhai@google.com>2011-12-16 22:33:27 +0000
committerSharad Singhai <singhai@google.com>2011-12-16 22:33:27 +0000
commit96753532fe9a452989011a9272ffce64ee796323 (patch)
tree7867841dd094b81cec8d37bf987c12f92819698c /libgcc/libgcov.c
parente2489aff67d7c3d27b8912bb01364a25863e59db (diff)
Merged revisions 180235-180237,180239-180240,180242-180252,180254-180258,180261-180262,180264,180266-180268,180270-180272,180276-180278,180282-180284,180287,180289,180292,180294-180296,180299-180302,180304-180305,180307-180314,180316,180320-180321,180323-180325,180327-180329,180333-180336,180340-180354,180358-180364,180367-180377,180380-180381,180383-180385,180388,180397,180400-180402,180405,180407-180408,180410-180411,180417-180421,180423-180427,180429-180430,180432,180434-180435,180437-180442,180444-180446,180448-180459,180464-180468,180517-180526,180528,180531-180532,180536-180546,180549-180552,180556,180558-180560,180562-180565,180567-180569,180572,180574-180580,180588-180590,180600-180613,180617-180618,180620,180622-180627,180632-180634,180639-180642,180646-180657,180659-180660,180669-180670,180673-180675,180677-180682,180684-180687,180694-180705,180707-180709,180712-180717,180721,180723-180729,180731-180739,180741-180743,180745-180748,180750,180752,180756-180758,180760-180765,180767-180771,180773-180776,180778-180780,180783-180788,180791,180793-180796,180799-180800,180802-180803,180805,180810,180814,180818-180822,180825-180833,180837,180839-180840,180842-180862,180864-180870,180872-180875,180877-180895,180897-180911,180913,180916-180922,180928-180936,180938-180957,180959-180967,180970,180972,180974,180976,180978,180982-180983,180986,180992,180996,180999-181003,181005-181007,181009-181017,181021-181024,181026-181027,181030-181031,181037-181042,181044-181049,181053-181056,181062-181065,181068-181072,181074-181082,181084-181087,181089-181107,181111-181112,181114,181116,181118-181120,181122,181124-181125,181127-181128,181131-181132,181134,181138-181139,181141-181143,181145,181147,181149-181166,181168-181175,181179-181183,181187-181200,181202-181241,181245-181246,181248,181250-181263,181265-181267,181269-181273,181278-181292,181296-181301,181306-181312,181315,181317-181327,181331-181335,181338-181341,181345-181350,181353,181355,181357-181361,181363-181372,181376-181381,181383-181384,181387-181388,181390-181395,181399-181400,181403,181405,181407-181411,181414,181416-181417,181419-181423,181425-181426,181431,181434,181436,181438,181441-181446,181451-181460,181464-181470,181473-181478,181480-181482,181489-181493,181495-181496,181501,181503,181505-181509,181511-181513,181517,181521,181523-181535,181537-181539,181543-181552,181555-181559,181561-181570,181572-181573,181575-181576,181579-181582,181584,181587-181588,181590,181592-181602,181606-181608,181610-181620,181623-181629,181631,181633-181634,181638-181640,181642-181643,181648,181653-181670,181674-181677,181683-181685,181690-181691,181694,181696-181698,181700-181702,181706-181707,181709,181713,181715,181718,181721-181725,181727-181728,181730-181731,181735,181738-181750,181754-181766,181770-181773,181775,181778-181779,181782,181784-181789,181793-181816,181818-181819,181821,181823-181825,181829-181833,181836-181837,181842-181843,181848-181849,181851-181857,181859-181863,181867-181870,181872,181874-181877,181879-181887,181889-181897,181901-181902,181906,181908,181912-181920,181922,181924,181926-181933,181937-181939,181949,181951,181955,181959,181964-181968,181970-181975,181979-181987,181990-181995,181999-182002,182004-182017,182020-182021,182023-182031,182033,182037-182039,182041-182045,182048-182056,182058-182061,182063-182068,182072-182077,182082-182086,182088-182092,182096-182097,182100,182102,182105,182107-182110,182115-182117,182119,182121,182123,182127,182131-182134,182136,182140-182144,182148,182151-182152,182154-182156,182158-182170,182174-182175,182177-182179,182183-182194,182198-182206,182208,182210-182212,182217-182221,182224-182235,182237-182242,182244,182246-182247,182249-182252,182256-182258,182262-182266,182270-182271,182275-182276,182278-182302,182306-182310,182313-182315,182319-182322,182324,182326-182332,182336-182338,182342-182343,182345-182347 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/integration@182413 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc/libgcov.c')
-rw-r--r--libgcc/libgcov.c440
1 files changed, 254 insertions, 186 deletions
diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c
index b39ef49343f..f7691df967c 100644
--- a/libgcc/libgcov.c
+++ b/libgcc/libgcov.c
@@ -1,7 +1,7 @@
/* Routines required for instrumenting a program. */
/* Compile this one with gcc. */
/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010
+ 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
@@ -29,6 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "tsystem.h"
#include "coretypes.h"
#include "tm.h"
+#include "libgcc_tm.h"
#if defined(inhibit_libc)
#define IN_LIBGCOV (-1)
@@ -77,6 +78,14 @@ void __gcov_merge_delta (gcov_type *counters __attribute__ ((unused)),
#ifdef L_gcov
#include "gcov-io.c"
+struct gcov_fn_buffer
+{
+ struct gcov_fn_buffer *next;
+ unsigned fn_ix;
+ struct gcov_fn_info info;
+ /* note gcov_fn_info ends in a trailing array. */
+};
+
/* Chain of per-object gcov structures. */
static struct gcov_info *gcov_list;
@@ -134,6 +143,64 @@ create_file_directory (char *filename)
#endif
}
+static struct gcov_fn_buffer **
+buffer_fn_data (struct gcov_info *gi_ptr, struct gcov_fn_buffer **end_ptr,
+ unsigned fn_ix)
+{
+ unsigned n_ctrs = 0, ix;
+ struct gcov_fn_buffer *fn_buffer;
+
+ for (ix = GCOV_COUNTERS; ix--;)
+ if (gi_ptr->merge[ix])
+ n_ctrs++;
+
+ fn_buffer = (struct gcov_fn_buffer *)malloc
+ (sizeof (*fn_buffer) + sizeof (fn_buffer->info.ctrs[0]) * n_ctrs);
+
+ if (!fn_buffer)
+ return 0; /* We'll horribly fail. */
+
+ fn_buffer->next = 0;
+ fn_buffer->fn_ix = fn_ix;
+ fn_buffer->info.ident = gcov_read_unsigned ();
+ fn_buffer->info.lineno_checksum = gcov_read_unsigned ();
+ fn_buffer->info.cfg_checksum = gcov_read_unsigned ();
+
+ for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++)
+ {
+ gcov_unsigned_t length;
+ gcov_type *values;
+
+ if (!gi_ptr->merge[ix])
+ continue;
+
+ if (gcov_read_unsigned () != GCOV_TAG_FOR_COUNTER (ix))
+ goto fail;
+
+ length = GCOV_TAG_COUNTER_NUM (gcov_read_unsigned ());
+ values = (gcov_type *)malloc (length * sizeof (gcov_type));
+ if (!values)
+ {
+ while (n_ctrs--)
+ free (fn_buffer->info.ctrs[n_ctrs].values);
+ goto fail;
+ }
+ fn_buffer->info.ctrs[n_ctrs].num = length;
+ fn_buffer->info.ctrs[n_ctrs].values = values;
+
+ while (length--)
+ *values++ = gcov_read_counter ();
+ n_ctrs++;
+ }
+
+ *end_ptr = fn_buffer;
+ return &fn_buffer->next;
+
+ fail:
+ free (fn_buffer);
+ return 0;
+}
+
/* Check if VERSION of the info block PTR matches libgcov one.
Return 1 on success, or zero in case of versions mismatch.
If FILENAME is not NULL, its value used for reporting purposes
@@ -169,39 +236,46 @@ static void
gcov_exit (void)
{
struct gcov_info *gi_ptr;
- struct gcov_summary this_program;
- struct gcov_summary all;
+ const struct gcov_fn_info *gfi_ptr;
+ struct gcov_summary this_prg; /* summary for program. */
+ struct gcov_summary all_prg; /* summary for all instances of program. */
struct gcov_ctr_summary *cs_ptr;
const struct gcov_ctr_info *ci_ptr;
- unsigned t_ix;
+ unsigned t_ix, f_ix;
gcov_unsigned_t c_num;
const char *gcov_prefix;
int gcov_prefix_strip = 0;
size_t prefix_length;
char *gi_filename, *gi_filename_up;
- memset (&all, 0, sizeof (all));
+ memset (&all_prg, 0, sizeof (all_prg));
/* Find the totals for this execution. */
- memset (&this_program, 0, sizeof (this_program));
+ memset (&this_prg, 0, sizeof (this_prg));
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
- {
- ci_ptr = gi_ptr->counts;
- for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
- {
- if (!((1 << t_ix) & gi_ptr->ctr_mask))
- continue;
+ for (f_ix = 0; f_ix != gi_ptr->n_functions; f_ix++)
+ {
+ gfi_ptr = gi_ptr->functions[f_ix];
+
+ if (!gfi_ptr || gfi_ptr->key != gi_ptr)
+ continue;
+
+ ci_ptr = gfi_ptr->ctrs;
+ for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
+ {
+ if (!gi_ptr->merge[t_ix])
+ continue;
- cs_ptr = &this_program.ctrs[t_ix];
- cs_ptr->num += ci_ptr->num;
- for (c_num = 0; c_num < ci_ptr->num; c_num++)
- {
- cs_ptr->sum_all += ci_ptr->values[c_num];
- if (cs_ptr->run_max < ci_ptr->values[c_num])
- cs_ptr->run_max = ci_ptr->values[c_num];
- }
- ci_ptr++;
- }
- }
+ cs_ptr = &this_prg.ctrs[t_ix];
+ cs_ptr->num += ci_ptr->num;
+ for (c_num = 0; c_num < ci_ptr->num; c_num++)
+ {
+ cs_ptr->sum_all += ci_ptr->values[c_num];
+ if (cs_ptr->run_max < ci_ptr->values[c_num])
+ cs_ptr->run_max = ci_ptr->values[c_num];
+ }
+ ci_ptr++;
+ }
+ }
{
/* Check if the level of dirs to strip off specified. */
@@ -214,6 +288,7 @@ gcov_exit (void)
gcov_prefix_strip = 0;
}
}
+
/* Get file name relocation prefix. Non-absolute values are ignored. */
gcov_prefix = getenv("GCOV_PREFIX");
if (gcov_prefix)
@@ -243,24 +318,20 @@ gcov_exit (void)
/* Now merge each file. */
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
{
- struct gcov_summary this_object;
- struct gcov_summary object, program;
- gcov_type *values[GCOV_COUNTERS];
- const struct gcov_fn_info *fi_ptr;
- unsigned fi_stride;
- unsigned c_ix, f_ix, n_counts;
- struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
+ unsigned n_counts;
+ struct gcov_summary prg; /* summary for this object over all
+ program. */
+ struct gcov_ctr_summary *cs_prg, *cs_tprg, *cs_all;
int error = 0;
gcov_unsigned_t tag, length;
gcov_position_t summary_pos = 0;
gcov_position_t eof_pos = 0;
const char *fname, *s;
+ struct gcov_fn_buffer *fn_buffer = 0;
+ struct gcov_fn_buffer **fn_tail = &fn_buffer;
fname = gi_ptr->filename;
- memset (&this_object, 0, sizeof (this_object));
- memset (&object, 0, sizeof (object));
-
/* Avoid to add multiple drive letters into combined path. */
if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
fname += 2;
@@ -282,6 +353,7 @@ gcov_exit (void)
level++;
}
}
+
/* Update complete filename with stripped original. */
if (prefix_length != 0 && !IS_DIR_SEPARATOR (*fname))
{
@@ -292,42 +364,6 @@ gcov_exit (void)
else
strcpy (gi_filename_up, fname);
- /* Totals for this object file. */
- ci_ptr = gi_ptr->counts;
- for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
- {
- if (!((1 << t_ix) & gi_ptr->ctr_mask))
- continue;
-
- cs_ptr = &this_object.ctrs[t_ix];
- cs_ptr->num += ci_ptr->num;
- for (c_num = 0; c_num < ci_ptr->num; c_num++)
- {
- cs_ptr->sum_all += ci_ptr->values[c_num];
- if (cs_ptr->run_max < ci_ptr->values[c_num])
- cs_ptr->run_max = ci_ptr->values[c_num];
- }
-
- ci_ptr++;
- }
-
- c_ix = 0;
- for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
- if ((1 << t_ix) & gi_ptr->ctr_mask)
- {
- values[c_ix] = gi_ptr->counts[c_ix].values;
- c_ix++;
- }
-
- /* Calculate the function_info stride. This depends on the
- number of counter types being measured. */
- fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned);
- if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned))
- {
- fi_stride += __alignof__ (struct gcov_fn_info) - 1;
- fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1);
- }
-
if (!gcov_open (gi_filename))
{
/* Open failed likely due to missed directory.
@@ -363,83 +399,98 @@ gcov_exit (void)
/* Read from a different compilation. Overwrite the file. */
goto rewrite;
- /* Merge execution counts for each function. */
- for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
+ /* Look for program summary. */
+ for (f_ix = ~0u;;)
{
- fi_ptr = (const struct gcov_fn_info *)
- ((const char *) gi_ptr->functions + f_ix * fi_stride);
+ struct gcov_summary tmp;
+
+ eof_pos = gcov_position ();
tag = gcov_read_unsigned ();
+ if (tag != GCOV_TAG_PROGRAM_SUMMARY)
+ break;
+
+ length = gcov_read_unsigned ();
+ if (length != GCOV_TAG_SUMMARY_LENGTH)
+ goto read_mismatch;
+ gcov_read_summary (&tmp);
+ if ((error = gcov_is_error ()))
+ goto read_error;
+ if (!summary_pos && tmp.checksum == gcov_crc32)
+ {
+ prg = tmp;
+ summary_pos = eof_pos;
+ }
+ }
+
+ /* Merge execution counts for each function. */
+ for (f_ix = 0; f_ix != gi_ptr->n_functions;
+ f_ix++, tag = gcov_read_unsigned ())
+ {
+ gfi_ptr = gi_ptr->functions[f_ix];
+
+ if (tag != GCOV_TAG_FUNCTION)
+ goto read_mismatch;
length = gcov_read_unsigned ();
- /* Check function. */
- if (tag != GCOV_TAG_FUNCTION
- || length != GCOV_TAG_FUNCTION_LENGTH
- || gcov_read_unsigned () != fi_ptr->ident
- || gcov_read_unsigned () != fi_ptr->lineno_checksum
- || gcov_read_unsigned () != fi_ptr->cfg_checksum)
+ if (!length)
+ /* This function did not appear in the other program.
+ We have nothing to merge. */
+ continue;
+
+ if (length != GCOV_TAG_FUNCTION_LENGTH)
+ goto read_mismatch;
+
+ if (!gfi_ptr || gfi_ptr->key != gi_ptr)
{
- read_mismatch:;
- fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
- gi_filename,
- f_ix + 1 ? "function" : "summaries");
- goto read_fatal;
+ /* This function appears in the other program. We
+ need to buffer the information in order to write
+ it back out -- we'll be inserting data before
+ this point, so cannot simply keep the data in the
+ file. */
+ fn_tail = buffer_fn_data (gi_ptr, fn_tail, f_ix);
+ if (!fn_tail)
+ goto read_mismatch;
+ continue;
}
- c_ix = 0;
+ if (gcov_read_unsigned () != gfi_ptr->ident
+ || gcov_read_unsigned () != gfi_ptr->lineno_checksum
+ || gcov_read_unsigned () != gfi_ptr->cfg_checksum)
+ goto read_mismatch;
+
+ ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
{
- gcov_merge_fn merge;
+ gcov_merge_fn merge = gi_ptr->merge[t_ix];
- if (!((1 << t_ix) & gi_ptr->ctr_mask))
+ if (!merge)
continue;
- n_counts = fi_ptr->n_ctrs[c_ix];
- merge = gi_ptr->counts[c_ix].merge;
-
tag = gcov_read_unsigned ();
length = gcov_read_unsigned ();
if (tag != GCOV_TAG_FOR_COUNTER (t_ix)
- || length != GCOV_TAG_COUNTER_LENGTH (n_counts))
+ || length != GCOV_TAG_COUNTER_LENGTH (ci_ptr->num))
goto read_mismatch;
- (*merge) (values[c_ix], n_counts);
- values[c_ix] += n_counts;
- c_ix++;
+ (*merge) (ci_ptr->values, ci_ptr->num);
+ ci_ptr++;
}
if ((error = gcov_is_error ()))
goto read_error;
}
- f_ix = ~0u;
- /* Check program & object summary */
- while (1)
+ if (tag)
{
- int is_program;
-
- eof_pos = gcov_position ();
- tag = gcov_read_unsigned ();
- if (!tag)
- break;
-
- length = gcov_read_unsigned ();
- is_program = tag == GCOV_TAG_PROGRAM_SUMMARY;
- if (length != GCOV_TAG_SUMMARY_LENGTH
- || (!is_program && tag != GCOV_TAG_OBJECT_SUMMARY))
- goto read_mismatch;
- gcov_read_summary (is_program ? &program : &object);
- if ((error = gcov_is_error ()))
- goto read_error;
- if (is_program && program.checksum == gcov_crc32)
- {
- summary_pos = eof_pos;
- goto rewrite;
- }
+ read_mismatch:;
+ fprintf (stderr, "profiling:%s:Merge mismatch for %s\n",
+ gi_filename, f_ix + 1 ? "function" : "summaries");
+ goto read_fatal;
}
}
goto rewrite;
read_error:;
- fprintf (stderr, error < 0 ? "profiling:%s:Overflow merging\n"
- : "profiling:%s:Error merging\n", gi_filename);
+ fprintf (stderr, "profiling:%s:%s merging\n", gi_filename,
+ error < 0 ? "Overflow": "Error");
read_fatal:;
gcov_close ();
@@ -448,29 +499,20 @@ gcov_exit (void)
rewrite:;
gcov_rewrite ();
if (!summary_pos)
- memset (&program, 0, sizeof (program));
+ {
+ memset (&prg, 0, sizeof (prg));
+ summary_pos = eof_pos;
+ }
/* Merge the summaries. */
- f_ix = ~0u;
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
{
- cs_obj = &object.ctrs[t_ix];
- cs_tobj = &this_object.ctrs[t_ix];
- cs_prg = &program.ctrs[t_ix];
- cs_tprg = &this_program.ctrs[t_ix];
- cs_all = &all.ctrs[t_ix];
+ cs_prg = &prg.ctrs[t_ix];
+ cs_tprg = &this_prg.ctrs[t_ix];
+ cs_all = &all_prg.ctrs[t_ix];
- if ((1 << t_ix) & gi_ptr->ctr_mask)
+ if (gi_ptr->merge[t_ix])
{
- if (!cs_obj->runs++)
- cs_obj->num = cs_tobj->num;
- else if (cs_obj->num != cs_tobj->num)
- goto read_mismatch;
- cs_obj->sum_all += cs_tobj->sum_all;
- if (cs_obj->run_max < cs_tobj->run_max)
- cs_obj->run_max = cs_tobj->run_max;
- cs_obj->sum_max += cs_tobj->run_max;
-
if (!cs_prg->runs++)
cs_prg->num = cs_tprg->num;
else if (cs_prg->num != cs_tprg->num)
@@ -480,78 +522,94 @@ gcov_exit (void)
cs_prg->run_max = cs_tprg->run_max;
cs_prg->sum_max += cs_tprg->run_max;
}
- else if (cs_obj->num || cs_prg->num)
+ else if (cs_prg->runs)
goto read_mismatch;
if (!cs_all->runs && cs_prg->runs)
memcpy (cs_all, cs_prg, sizeof (*cs_all));
- else if (!all.checksum
+ else if (!all_prg.checksum
&& (!GCOV_LOCKED || cs_all->runs == cs_prg->runs)
&& memcmp (cs_all, cs_prg, sizeof (*cs_all)))
{
- fprintf (stderr, "profiling:%s:Invocation mismatch - some data files may have been removed%s",
+ fprintf (stderr, "profiling:%s:Invocation mismatch - some data files may have been removed%s\n",
gi_filename, GCOV_LOCKED
- ? "" : " or concurrent update without locking support");
- all.checksum = ~0u;
+ ? "" : " or concurrently updated without locking support");
+ all_prg.checksum = ~0u;
}
}
- c_ix = 0;
- for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
- if ((1 << t_ix) & gi_ptr->ctr_mask)
- {
- values[c_ix] = gi_ptr->counts[c_ix].values;
- c_ix++;
- }
-
- program.checksum = gcov_crc32;
+ prg.checksum = gcov_crc32;
/* Write out the data. */
- gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
- gcov_write_unsigned (gi_ptr->stamp);
+ if (!eof_pos)
+ {
+ gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
+ gcov_write_unsigned (gi_ptr->stamp);
+ }
+
+ if (summary_pos)
+ gcov_seek (summary_pos);
+
+ /* Generate whole program statistics. */
+ gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &prg);
+
+ if (summary_pos < eof_pos)
+ gcov_seek (eof_pos);
/* Write execution counts for each function. */
for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
{
- fi_ptr = (const struct gcov_fn_info *)
- ((const char *) gi_ptr->functions + f_ix * fi_stride);
+ unsigned buffered = 0;
- /* Announce function. */
- gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH);
- gcov_write_unsigned (fi_ptr->ident);
- gcov_write_unsigned (fi_ptr->lineno_checksum);
- gcov_write_unsigned (fi_ptr->cfg_checksum);
+ if (fn_buffer && fn_buffer->fn_ix == f_ix)
+ {
+ /* Buffered data from another program. */
+ buffered = 1;
+ gfi_ptr = &fn_buffer->info;
+ length = GCOV_TAG_FUNCTION_LENGTH;
+ }
+ else
+ {
+ gfi_ptr = gi_ptr->functions[f_ix];
+ if (gfi_ptr && gfi_ptr->key == gi_ptr)
+ length = GCOV_TAG_FUNCTION_LENGTH;
+ else
+ length = 0;
+ }
+
+ gcov_write_tag_length (GCOV_TAG_FUNCTION, length);
+ if (!length)
+ continue;
+
+ gcov_write_unsigned (gfi_ptr->ident);
+ gcov_write_unsigned (gfi_ptr->lineno_checksum);
+ gcov_write_unsigned (gfi_ptr->cfg_checksum);
- c_ix = 0;
+ ci_ptr = gfi_ptr->ctrs;
for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
{
- gcov_type *c_ptr;
-
- if (!((1 << t_ix) & gi_ptr->ctr_mask))
+ if (!gi_ptr->merge[t_ix])
continue;
- n_counts = fi_ptr->n_ctrs[c_ix];
-
+ n_counts = ci_ptr->num;
gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix),
GCOV_TAG_COUNTER_LENGTH (n_counts));
- c_ptr = values[c_ix];
+ gcov_type *c_ptr = ci_ptr->values;
while (n_counts--)
gcov_write_counter (*c_ptr++);
-
- values[c_ix] = c_ptr;
- c_ix++;
+ if (buffered)
+ free (ci_ptr->values);
+ ci_ptr++;
+ }
+ if (buffered)
+ {
+ struct gcov_fn_buffer *tmp = fn_buffer;
+ fn_buffer = fn_buffer->next;
+ free (tmp);
}
}
- /* Object file summary. */
- gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, &object);
-
- /* Generate whole program statistics. */
- if (eof_pos)
- gcov_seek (eof_pos);
- gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &program);
- if (!summary_pos)
- gcov_write_unsigned (0);
+ gcov_write_unsigned (0);
if ((error = gcov_close ()))
fprintf (stderr, error < 0 ?
"profiling:%s:Overflow writing\n" :
@@ -617,15 +675,25 @@ __gcov_flush (void)
gcov_exit ();
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
{
- unsigned t_ix;
- const struct gcov_ctr_info *ci_ptr;
+ unsigned f_ix;
- for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++)
- if ((1 << t_ix) & gi_ptr->ctr_mask)
- {
- memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
- ci_ptr++;
- }
+ for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
+ {
+ unsigned t_ix;
+ const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix];
+
+ if (!gfi_ptr || gfi_ptr->key != gi_ptr)
+ continue;
+ const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
+ for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
+ {
+ if (!gi_ptr->merge[t_ix])
+ continue;
+
+ memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
+ ci_ptr++;
+ }
+ }
}
}