views:

502

answers:

3

Is it possible to use gcov for coverage testing of multi-threaded applications?

I've set some trivial tests of our code-base up, but it would be nice to have some idea of the coverage we're achieving. If gcov isn't appropriate can anyone recommend an alternative tool (possible oprofile), ideally with some good documentation on getting started.

+4  A: 

We've certainly used gcov to get coverage information on our multi-threaded application.

You want to compile with gcc 4.3 which can do coverage on dynamic code.

You compile with the -fprofile-arcs -ftest-coverage options, and the code will generate .gcda files which gcov can then process.

We do a separate build of our product, and collect coverage on that, running unit tests and regression tests.

Finally we use lcov to generate HTML results pages.

Douglas Leeder
A: 

I have not used gcov for multi-threaded coverage work. However, on MacOS the Shark tool from Apple handles multiple threads. It's primarily a profiler, but can do coverage info too.

http://developer.apple.com/tools/sharkoptimize.html

nsanders
+1  A: 

Gcov works fine for multi-threaded apps. The instrumentation architecture is properly serialized so you will get coverage data of good fidelity.

I would suggest using gcov in conjunction with lcov. This will give you great reports scoped from full project down to individual source files.

lcov also gives you a nicely color coded HTML version of your source so you can quickly evaluate your coverage lapses.

Jeremy Mayhew