gcov tutorial

阅读更多

tmp.c

#include 

int main(int argc, const char *argv[]) {
	int i, j;

	for (i = 0; i < 10; i++)
		if (i > 100)
			j += 3;
		else
			j += 2;

	return 0;
}

 

Steps to run gcov:

 

jing@jingguolin:~/code/coverage$ gcc -fprofile-arcs -ftest-coverage tmp.c
jing@jingguolin:~/code/coverage$ ls
a.out  tmp.c  tmp.gcno
jing@jingguolin:~/code/coverage$ ./a.out 
jing@jingguolin:~/code/coverage$ gcov tmp.c
File 'tmp.c'
Lines executed:83.33% of 6
tmp.c:creating 'tmp.c.gcov'
 

你可能感兴趣的:(gcov tutorial)