hello.c:
#include <stdio.h>
static int t = 1;
int main()
{
if (t)
printf("on this line\n");
else
printf("but not here\n");
return 0;
}
clang -coverage -O0 hello.c -o hello
./hello
gcov hello.c
now a hello.c.gcov is generated:
-: 0:Source:hello.c
-: 0:Graph:hello.gcno
-: 0:Data:hello.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include <stdio.h>
-: 2:
-: 3:static int t = 1;
-: 4:
-: 5:int main()
-: 6:{
1: 7: if (t)
1: 8: printf("on this line\n");
-: 9: else
#####: 10: printf("but not here\n");
-: 11:
1: 12: return 0;
-: 13:}