bool has_block (block_t *needle);
gcov_type count; /* execution count */
- union
- {
- arc_t *branches; /* branches from blocks that end on this
- line. Used for branch-counts when not
- all-blocks mode. */
- block_t *blocks; /* blocks which start on this line. Used
- in all-blocks mode. */
- } u;
+ arc_t *branches; /* branches from blocks that end on this line. */
+ block_t *blocks; /* blocks which start on this line.
+ Used in all-blocks mode. */
unsigned exists : 1;
unsigned unexceptional : 1;
} line_t;
bool
line_t::has_block (block_t *needle)
{
- for (block_t *n = u.blocks; n; n = n->chain)
+ for (block_t *n = blocks; n; n = n->chain)
if (n == needle)
return true;
loop_type result = NO_LOOP;
gcov_type count = 0;
- for (block_t *block = linfo.u.blocks; block; block = block->chain)
+ for (block_t *block = linfo.blocks; block; block = block->chain)
{
arc_vector_t path;
block_vector_t blocked;
fprintf (gcov_file, "lcount:%u,%s\n", line_num,
format_gcov (line->count, 0, -1));
if (flag_branches)
- for (arc = line->u.branches; arc; arc = arc->line_next)
+ for (arc = line->branches; arc; arc = arc->line_next)
{
if (!arc->is_unconditional && !arc->is_call_non_return)
{
/* Resort the name map. */
qsort (names, n_names, sizeof (*names), name_sort);
-
+
check_date:
if (sources[idx].file_time > bbg_file_time)
{
static void
add_line_counts (coverage_t *coverage, function_t *fn)
{
- unsigned ix;
- line_t *line = NULL; /* This is propagated from one iteration to the
- next. */
-
+ bool has_any_line = false;
/* Scan each basic block. */
- for (ix = 0; ix != fn->blocks.size (); ix++)
+ for (unsigned ix = 0; ix != fn->blocks.size (); ix++)
{
+ line_t *line = NULL;
block_t *block = &fn->blocks[ix];
if (block->count && ix && ix + 1 != fn->blocks.size ())
fn->blocks_executed++;
}
block->cycle.arc = NULL;
block->cycle.ident = ~0U;
+ has_any_line = true;
if (!ix || ix + 1 == fn->blocks.size ())
/* Entry or exit block */;
- else if (flag_all_blocks)
+ else if (line != NULL)
{
- line_t *block_line = line;
-
- if (!block_line)
- block_line = &sources[fn->src].lines[fn->line];
+ block->chain = line->blocks;
+ line->blocks = block;
- block->chain = block_line->u.blocks;
- block_line->u.blocks = block;
- }
- else if (flag_branches)
- {
- arc_t *arc;
-
- for (arc = block->succ; arc; arc = arc->succ_next)
+ if (flag_branches)
{
- arc->line_next = line->u.branches;
- line->u.branches = arc;
- if (coverage && !arc->is_unconditional)
- add_branch_counts (coverage, arc);
+ arc_t *arc;
+
+ for (arc = block->succ; arc; arc = arc->succ_next)
+ {
+ arc->line_next = line->branches;
+ line->branches = arc;
+ if (coverage && !arc->is_unconditional)
+ add_branch_counts (coverage, arc);
+ }
}
}
}
- if (!line)
+
+ if (!has_any_line)
fnotice (stderr, "%s:no lines for '%s'\n", bbg_file_name, fn->name);
}
for (ix = src->num_lines, line = src->lines; ix--; line++)
{
- if (!flag_all_blocks)
- {
- arc_t *arc, *arc_p, *arc_n;
-
- /* Total and reverse the branch information. */
- for (arc = line->u.branches, arc_p = NULL; arc;
- arc_p = arc, arc = arc_n)
- {
- arc_n = arc->line_next;
- arc->line_next = arc_p;
-
- add_branch_counts (&src->coverage, arc);
- }
- line->u.branches = arc_p;
- }
- else if (line->u.blocks)
+ if (line->blocks)
{
/* The user expects the line count to be the number of times
a line has been executed. Simply summing the block count
gcov_type count = 0;
/* Reverse the block information. */
- for (block = line->u.blocks, block_p = NULL; block;
+ for (block = line->blocks, block_p = NULL; block;
block_p = block, block = block_n)
{
block_n = block->chain;
block->chain = block_p;
block->cycle.ident = ix;
}
- line->u.blocks = block_p;
+ line->blocks = block_p;
/* Sum the entry arcs. */
- for (block = line->u.blocks; block; block = block->chain)
+ for (block = line->blocks; block; block = block->chain)
{
arc_t *arc;
}
/* Cycle detection. */
- for (block = line->u.blocks; block; block = block->chain)
+ for (block = line->blocks; block; block = block->chain)
{
for (arc_t *arc = block->pred; arc; arc = arc->pred_next)
if (!line->has_block (arc->src))
arc_t *arc;
int ix, jx;
- for (ix = jx = 0, block = line->u.blocks; block;
+ for (ix = jx = 0, block = line->blocks; block;
block = block->chain)
{
if (!block->is_call_return)
int ix;
arc_t *arc;
- for (ix = 0, arc = line->u.branches; arc; arc = arc->line_next)
+ for (ix = 0, arc = line->branches; arc; arc = arc->line_next)
ix += output_branch_count (gcov_file, ix, arc);
}
}
name_differs = !prev_file_name || filename_cmp (file_name, prev_file_name);
line_differs = prev_line != line;
- if (name_differs || line_differs)
+ if (!*offset)
{
- if (!*offset)
- {
- *offset = gcov_write_tag (GCOV_TAG_LINES);
- gcov_write_unsigned (bb->index);
- name_differs = line_differs=true;
- }
+ *offset = gcov_write_tag (GCOV_TAG_LINES);
+ gcov_write_unsigned (bb->index);
+ name_differs = line_differs = true;
+ }
- /* If this is a new source file, then output the
- file's name to the .bb file. */
- if (name_differs)
- {
- prev_file_name = file_name;
- gcov_write_unsigned (0);
- gcov_write_string (prev_file_name);
- }
- if (line_differs)
- {
- gcov_write_unsigned (line);
- prev_line = line;
- }
- }
+ /* If this is a new source file, then output the
+ file's name to the .bb file. */
+ if (name_differs)
+ {
+ prev_file_name = file_name;
+ gcov_write_unsigned (0);
+ gcov_write_string (prev_file_name);
+ }
+ if (line_differs)
+ {
+ gcov_write_unsigned (line);
+ prev_line = line;
+ }
}
/* Instrument and/or analyze program behavior based on program the CFG.