Pergunta

I am using gcov with the option -a (--all-blocks) which from the manual:

When you use the -a option, you will get individual block counts

The original file:

#include <stdio.h>
#include "file1.h"

int max(int a , int b)
{
  int k = 0;
  if (a > b)
    return a;
  else
    return b;
}

The gcov file is the following:

    -:    0:Source:file1.c
    -:    0:Graph:file1.gcno
    -:    0:Data:file1.gcda
    -:    0:Runs:1
    -:    0:Programs:1
    -:    1:#include <stdio.h>
    -:    2:#include "file1.h"
    -:    3:
    -:    4:int max(int a , int b)
    1:    5:{
    1:    6:  int k = 0;
    1:    7:  if (a > b)
    1:    7-block  0
    1:    8:    return a;
    1:    8-block  0
    -:    9:  else
    1:   10:    return b;
$$$$$:   10-block  0
    1:   10-block  1
    -:   11:}
    -:   12:
    -:   13:

I couldn't find any information about the format of the output of the gcov. From the original code I can identify 3 basic blocks but gcov only numbers two and also in line 10 it identifies two blocks.

Foi útil?

Solução

Block numbers are local to a line. block 0 on line 7 means "block 0 of line 7" etc. You have block 1 only when a line has two or more blocks, as is the case with line 10.

The block number is shown on the last line of that block only.

Thus, your program has 4 blocks, two of them on line 10.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top