views:

161

answers:

1

Most code editors know how to take a reasonably standard format of file_path, line_number, message_text and hyperlink into code. They know how because that's how they display compiler warnings. Visual Studio does it, and Source Insight is trivial to configure for that. If I have to I will write the script myself, but maybe someone has done so already.

Looking for a script that takes gcc's gcov branch coverage output and translates it into that format.

+1  A: 

You can process the output of gcov with a simple awk script:

/.*:.*:/ {
    split($2,tokens,":");
    LINE=tokens[1];
}

/#####:/ { print FILENAME ":" LINE ": warning: Line not executed"}

/branch/ {
    if ($4 == 0)
    print FILENAME ":" LINE ": warning: " $0;
}

Run with awk -f warn.awk main.c.gcov and it will convert the output to:

main.c.gcov:35: warning: branch 0 taken 0 (fallthrough)
main.c.gcov:37: warning: Line not executed

Steve
Very nice! Thanks!
talkaboutquality