cargo-fuzz icon indicating copy to clipboard operation
cargo-fuzz copied to clipboard

cargo-cov doesn't work

Open stasos24 opened this issue 3 years ago • 7 comments

Command:

cargo cov -- show fuzz/target/<target triple>/release/my_compiler \
    --format=html \
    -instr-profile=fuzz/coverage/my_compiler/coverage.profdata \
    > index.html

Error response:

error: no such subcommand: `cov`

        Did you mean `c`?

stasos24 avatar Jun 14 '22 09:06 stasos24

I "solved" this by running llvm-cov manually, like so (also install rustfilt):

/Users/user/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/llvm-cov show fuzz/target/x86_64-apple-darwin/release/my_compiler \
                                         --format=html \
                                         -Xdemangler=rustfilt \
                                         --ignore-filename-regex="\.cargo" \
                                         -instr-profile=fuzz/coverage/my_compiler/coverage.profdata \
                                         > index.html

Use the llvm-cov binary you made the coverage with.

madig avatar Sep 24 '22 13:09 madig

hmm, that didn't work for me.

; llvm-cov show --instr-profile=/Users/jyn/src/inventory/fuzz/coverage/my_fuzz_target/coverage.profdata  --format=html -Xdemangler=rustfilt /Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target
error: Failed to load coverage: '/Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target': No coverage data found
; file /Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target
/Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target: Mach-O 64-bit executable arm64

jyn514 avatar Jun 29 '23 17:06 jyn514

I was also getting the No coverage data found error, and it seems that the binary compiled with fuzzing instrumentation is at a different path from the main fuzzing binary now, but the documentation was never updated.

For me I had to change target/x86_64-unknown-linux-gnu/release/target_name to target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/release/target_name (yes that includes the target triple twice) to make llvm-cov work, which makes sense when only the latter is compiled with coverage instrumentation.

jix avatar Jul 08 '23 12:07 jix

I tried:

llvm-cov show target/x86_64-unknown-linux-gnu/release/fuzz_target_1 --format=html -Xdemangler=rustfilt -instr-profile=coverage/fuzz_target_1/coverage.profdata > index.html

And I get:

error: Failed to load coverage: 'coverage/fuzz_target_1/coverage.profdata': unsupported instrumentation profile format version

DJDuque avatar May 03 '24 01:05 DJDuque