Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gcov support #345

Open
Jaakkonen opened this issue Sep 1, 2021 · 2 comments
Open

Gcov support #345

Jaakkonen opened this issue Sep 1, 2021 · 2 comments

Comments

@Jaakkonen
Copy link

Jaakkonen commented Sep 1, 2021

Is your feature request related to a problem? Please describe.
Currently it's not possible to see coverage of programs written in C.

Describe the solution you'd like
Add support for formats used by gcov (.gcna, .gcno) and llvm profiling (.profdata).

Describe alternatives you've considered

https://github.com/JacquesLucke/gcov-viewer but that doesn't have same kind of auto detection and less-obstructing UI that coverage-gutters has.
One option is to use CLI/TUI programs to do this but it's really nice to be able to edit code and see coverage at the same time.

Additional context
Guide for getting coverage with LLVM: https://releases.llvm.org/12.0.1/tools/clang/docs/SourceBasedCodeCoverage.html
Gcov trivial example: https://github.com/shenxianpeng/gcov-example
Ok-ish explanation how gcov works: https://www.tutorialspoint.com/unix_commands/gcov.htm
https://llvm.org/docs/CommandGuide/llvm-profdata.html

@ryanluker
Copy link
Owner

@Jaakkonen Thanks for the issue! I am unfamiliar with the coverage landscape for C programs but gcov looks to be one popular standard 🤔 but we do not currently support it (as you alluded to above).

I believe people have used the expension with gcov by using lcov to convert the coverage?

So here we will use lcov tool to check line coverage and generate html reports . For this command is as shown below.
lcov --coverage --directory . --output-file main_coverage.info
This will create a coverage report by taking .gcno and .gcda files from ‘.’ i.e. current folder where these files are present and generate an output file with coverage info in file called main_coverage.info .
Now we have coverage info lets display it in html file using below command.

https://medium.com/@naveen.maltesh/generating-code-coverage-report-using-gnu-gcov-lcov-ee54a4de3f11

Let me know if that helps any in the meantime but we could consider gcov support in the future (or if there is already a javscript / typescript package that can convert gcov -> lcov then that would make this addition even easier)!

@Ali-Amir
Copy link

Ali-Amir commented Jan 4, 2023

You can generate xml with gcvor today and that worked for me without having to do format conversion.

Note that you may have issues with relative paths depending on how your coverage was generated. You can fix that with remotePathResolve though. For example, in my coverage xml I'm getting <source>..</source> and had to do setup remotePathResolve:

"coverage-gutters.remotePathResolve": [
    "../src",
    "./src",
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants