<p>Is it possible to use gcov for coverage testing of multi-threaded applications? </p>

<p>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.</p>

[{'answer_id': 38317, 'author': 'Douglas Leeder', 'author_id': 3978, 'author_profile': 'https://Stackoverflow.com/users/3978', 'pm_score': 4, 'selected': True, 'text': "<p>We've certainly used gcov to get coverage information on our multi-threaded application.</p>\n\n<p>You want to compile with gcc 4.3 which can do coverage on dynamic code.</p>\n\n<p>You compile with the <code>-fprofile-arcs -ftest-coverage</code> options, and the code will generate .gcda files which gcov can then process.</p>\n\n<p>We do a separate build of our product, and collect coverage on that, running unit tests and regression tests.</p>\n\n<p>Finally we use lcov to generate HTML results pages.</p>\n"}, {'answer_id': 38324, 'author': 'nsanders', 'author_id': 1244, 'author_profile': 'https://Stackoverflow.com/users/1244', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n\n<p><a href="http://developer.apple.com/tools/sharkoptimize.html" rel="nofollow noreferrer">http://developer.apple.com/tools/sharkoptimize.html</a></p>\n'}, {'answer_id': 1001006, 'author': 'Jeremy Mayhew', 'author_id': 123240, 'author_profile': 'https://Stackoverflow.com/users/123240', 'pm_score': 1, 'selected': False, 'text': '<p>Gcov works fine for multi-threaded apps. The instrumentation architecture is properly serialized so you will get coverage data of good fidelity. </p>\n\n<p>I would suggest using gcov in conjunction with <a href="http://ltp.sourceforge.net/coverage/lcov.php" rel="nofollow noreferrer">lcov</a>. This will give you great reports scoped from full project down to individual source files. </p>\n\n<p>lcov also gives you a nicely color coded HTML version of your source so you can quickly evaluate your coverage lapses. </p>\n'}]
['https://Stackoverflow.com/questions/37799', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2246/']