Monday, February 20, 2012

GCC - coverage and gprof

A friendly reminder - how to generate a good looking code coverage graph. 1. Coverage
-lgcov to linker, --coverage to compiler

part of makefile:
RM=@rm -fr
CP=@cp
MV=@mv
FIND=find
GCOV=gcov
LCOV=lcov
GENHTML=genhtml

gcov:
$(FIND) . -name "*.c" -print -exec $(GCOV) -o$(OBJ_DIR) {} \;
$(MV) -f ./*.gcov ./tests/coverage

lcov:
$(MV) $(OBJ_DIR)/*.gc* .
$(LCOV) --directory . --capture --output-file ./tests/coverage/vp.info
$(MV) ./*.gc* $(OBJ_DIR)

html: lcov
$(GENHTML) -o ./tests/coverage/html ./tests/coverage/vp.info
${RM} .#include#*



2. Great graphical tool for gcc profiler:

http://code.google.com/p/jrfonseca/wiki/Gprof2Dot

No comments: