How To Use llvm-cov
How To Use llvm-cov
Instrumenting your code for llvm-cov
See also: https://llvm.org/docs/CommandGuide/llvm-cov.html
- Build the code with code coverage turned on:
Compile with the -fprofile-arcs and -ftest-coverage options to add the instrumentation.
- Run your program, this creates a default.profraw file:
% ./program
- Run llvm-profdata to create a default.profdata file:
% llvm-profdata merge -sparse default.profraw -o default.profdata
- Run llvm-cov show for the module you care about:
% llvm-cov show -output-dir=output --format=html -instr-profile=./default.profdata ./program /full/path/to/source/module
- Now in the output directory you will find an index.txt file, the coverage numbers are in there.
- If you want to get coverage for a directory like player or media, you need to specify the .cpp and .hpp files:
% llvm-cov show -use-color=0 -output-dir=output -instr-profile=./default.profdata ./program /full/paht/to/source/module/*.[ch]pp
Comments
Post a Comment