interpret gcov output to identify basic blocks

人盡茶涼 提交于 2019-12-07 23:08:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/18534339/interpret-gcov-output-to-identify-basic-blocks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!