I know how to use GCOV and LCOV to get code coverage on GCC.
But This time i need to use clang and get instrumented binaries and code
Please help (not able to find much info yet). Tried using -fprofile-arcs and
-ftest-coverage. code is compiling fine but giving link errors.
Thanks in Advance,
The profiling library in gcc is called "libgcov", but clang has its own
named "libprofile_rt" and you need to link against that. The --coverage
flag implies -lprofile_rt when linking, or you can pass -lprofile_rt
The code for libprofile_rt is part of compiler-rt:
http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/profile/ . If you
don't have libprofile_rt, you'll need to build it.
Note that the default coverage information format is for llvm-cov. If
you want to use gcov for some reason, you'll need to specify the
options "-Xclang -coverage-cfg-checksum -Xclang
-coverage-no-function-names-in-data -Xclang -coverage-version='407*'"
gcov doesn't have a single fixed format. If you're using the gcov from
gcc-4.7 then yes you use those flags mentioned. The default that clang
emits should be gcc-4.2 compatible, which is supposed to work with llvm-cov
or with a gcov binary from gcc 4.2
Thanks for the help.
using libprofile_rt, the code is compiling and linking now and I am getting
.so but no .gcno file is there. is that needed or am I missing something?
The .gcno is emitted at compile time (the -ftest-coverage flag) while the
.gcda is emitted when the instrumented program runs. You'll need both files.
Sorry, May be I am asking dumb question, I am very very new to clang and C++
1. we are creating an android app and to build ndk c++ part, we are using
clang as our compiler. We are using windows for our OS choice, will it cause
2. We got *.gcno, it was generating in temp folder (not with shared lib :
a. compile flags used: -fprofile-arcs -ftest-coverage
b. link flags used: -lprofile_rt -lgcc
3. where do I get llvm-cov. which binaries should I download from
http://llvm.org/releases/download.html. As suggested we are using windows as
our build machine. Do we need to switch to ubuntu?
4. How to get html report for codecoverage(as lcov does for gcc). will
llvm-cov would help there?
Let me phrase questions in simple words:
1. I need llvm-cov.exe to generate code coverage reports (using generated
*.gcno & *.gcda).
2. I tried using one present in
clang+llvm-3.2-x86-mingw32-EXPERIMENTAL\bin\llvm-cov.exe (downloaded from
http://llvm.org/releases/download.html). but it is not working, giving error
- "pthreadGC2.dll is missing"