开发者

Anyone written a script that turns gcov branch coverage output into compiler warning format?

Most code editors know how to take a reasonably stan开发者_StackOverflowdard 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜