Skip to content

Instantly share code, notes, and snippets.

@emoon
Last active August 29, 2015 14:20
Show Gist options
  • Save emoon/4dd1476f16c934b239da to your computer and use it in GitHub Desktop.
Save emoon/4dd1476f16c934b239da to your computer and use it in GitHub Desktop.

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:}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment