Miss code lines when get code coverage of rust compiler

I followed this blog to get the code coverage data on the rust compiler itself, and it worked, but the results were problematic.

In the results, most of the code in the compiler directory is not counted. For example, the coverage rate of rustc_abi is 55/86, but in fact the code in rustc_abi is more than 2k lines.

Is this because these codes are not linked into the binary? Is there any way to include them in the results?

@Surfer as you tried this before

@SparrowLii How do you specify the binary directory for grcov, i.e., the directory following the -b option? The directory specified with the -b option must include the complete Rust installation directory, not just the rustc binary.

@Surfer I used grcov *.profraw -s /home/liyuan/para-rust/rust/compiler -b /usr/local/bin/ --llvm-path /home/liyuan/para-rust/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin -t html -o cov This is a screenshot of my results:

And the size of each of my profraw files is 1k or 37M.

Could you please provide me an html screenshot of your code coverage results?

And thanks for the reply!

Ah, thanks very much for your reminder, I changed -b /usr/local/bin to -b /usr/local and now it seems to show the correct results!

image Does this match your results? If so, I think the problem has been solved!

Yes, in addition to the bin directory, the lib directory must also be included. I am using the entire installation directory, and based on the lines of code, it appears to be roughly the same.

1 Like