Generate gcov coverage data
It would be nice to know what our test coverage looks like. I believe this depends on #689.
Depends on #237.
Should this issue be tagged with "debuginfo"?
Yes
According to a comment in #2234, this bug is unblocked now.
This is definitely blocked again on functioning debug info.
revisiting for triage. this would be especially great to have in the concurrency tests, where covering all the branches is a function of scheduling rather than input values.
i was already here, but now i am here again
This would be super-interesting to dig into now, since we have quite functional debug symbols after this summer's GSOC.
Would be awesome, but not 1.0
On a related note, I found this project today: https://github.com/SimonKagstrom/kcov
kcov uses the DWARF debug-info to generate coverage data, I've verified that it appears to work with test crates. It also generates cobertura xml files of the coverage data. Might be a nice stop gap for getting coverage numbers on rust itself.
kcov looks much nicer than gcov overall.
I'm not sure how relevant this is, but Go did it in a pretty interesting way: http://blog.golang.org/cover Not sure if everyone wants to do it the way they did.
I was recently looking at this. llvm has built-in gcov generation passes.
On Mon, Feb 3, 2014 at 12:54 AM, Michael Darakananda < [email protected]> wrote:
I'm not sure how relevant this is, but Go did it in a pretty interesting way: http://blog.golang.org/cover Not sure if everyone wants to do it the way they did.
— Reply to this email directly or view it on GitHubhttps://github.com/mozilla/rust/issues/690#issuecomment-33926365 .
I tested kcov, it seems to (mostly) just work with -Z extra-debug-info (~~output for extratest~~).
stdtest hits runtime aborts when running under kcov (possibly threading stuff, haven't had a chance to test) and it doesn't seem to understand our debug-info perfectly (or we have slightly misaligned/mislabeled debug-info) since sometimes lines inside ifs are marked as executed while the condition is, apparently, never run.
However, all-in-all kcov seems pretty good.
(drive-by-triage)
LLVM's gcov pass requires some runtime support in the form of compiler-rt. We're currently bundling compiler-rt with rust, but it doesn't have gcov support compiled into it. It's plausible that we could add a first-class flag to generate gcov information which would link to this special library.
/cc me
Tinkered with insert-gcov-profiling a bit. If you add it as a pass:
-C passes=insert-gcov-profiling
it fails to find the appropriate runtime support (llvm_gcda_start_file, llvm_gcda_emit_function, etc.). So I tried adding those from clang's compiler-rt:
-C link-args=/usr/lib/clang/3.4/lib/linux/libclang_rt.profile-x86_64.a
Fails with
undefined reference to `atexit'
Well, at that point I just linked everything to -lc as well :smile: and surprisingly that compiled and the binary works.
Now the problem is that those two binaries have different timestamps:
% hexdump -e '"%x\n"' -s8 -n4 test.gcno
9ad3f7b9
% hexdump -e '"%x\n"' -s8 -n4 test.gcda
4c4c564d
Any ideas what to do with that?
@farcaller do they need to have the same timestamp?
Yes, that's how they check that gcda output corresponds to gcno provided by complier. It might be because of some differences in clang's libclang_rt.profile-x86_64.a and whatever llvm generates in there at compile time, I'm rebuilding rustc with matching version of compiler-rt's profile now to verify.
With matching profile part of compiler-rt:
make -C $RUST_SRC/src/compiler-rt" ProjSrcRoot="$RUST_SRC/src/compiler-rt" ProjObjRoot="$RUST_SRC/x86_64-apple-darwin/rt/compiler-rt" CC="clang" AR="ar" RANLIB="ar s" CFLAGS="-Wall -Werror -g -fPIC -Qunused-arguments" TargetTriple=x86_64-apple-darwin clang_darwin-profile_osx
you can get gcov profiling generated by
-C passes=insert-gcov-profiling -C link-args=$RUST_SRC/x86_64-apple-darwin/rt/compiler-rt/clang_darwin/profile_osx/libcompiler_rt.a
Now, there are two more problems.
The compiler can't find __morestack_allocate_stack_space symbol. Not sure if this is directly related to the gcov though.
The bigger issue is that the file is still not parseable:
% gcov lib.gcda
Function identifiers do not match: 2 != 0 (in _ZN4zinc7drivers3lcd4test11TestLCD.LCD5clearE).
Invalid .gcda File!