Tuesday, October 12, 2010

Free code coverage analyzer tools

gcov opensource code coverage for gcc compilers.


Use gcov in concert with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program. 


How to install gcov and lcov
------------------------------
lcov- apt-get install lcov


gcov - apt-get install gcov (or) from synaptic package manager,look for ggcov.


lcov is an extension of GCOV,


gcov is a test coverage program.



Profiling tools help you analyze your code's performance. Using a profiler such as gcovor gprof, you can find out some basic performance statistics, such as:


  • * how often each line of code executes
  • * what lines of code are actually executed
  • *how much computing time each section of code uses
gcov creates a logfile called sourcefile.gcov which indicates how many times each line of a source file sourcefile.c has executed. You can use these logfiles along with gprof to aid in fine-tuning the performance of your programs. gprof gives timing information you can use along with the information you get from gcov. gcov works only on code compiled with GCC . It is not compatible with any other profiling or test coverage mechanism. For Qt projects declare in the .pro file
QMAKE_LFLAGS_DEBUG += -lgcov -fprofile-arcs -ftest-coverage
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_LIBS     += -lgcov -Wl,-rpath
QMAKE_CLEAN    += *.gcno *.gcda
LIBS  += -lgcov

No comments:

Post a Comment