'Generating an in-memory coverage report using Clang Source-based Code Coverage

I followed The Clang manual and used __llvm_profile_write_buffer to collect coverage cprofile data inside the instrumented program.

This works well, but to actually generate a coverage report the recommended way is to use the llvm-cov tool like this:

llvm-cov show ./foo -instr-profile=foo.profdata

This tool needs access to the binary which does not play well with __llvm_profile_write_buffer .

Is there a way to generate a coverage report similar to what llvm-cov does, but inside the process, from the buffer updated by __llvm_profile_write_buffer ? I guess this would involve accessing the symbol table from within the process, which I think is doable?

Use case : I would like to upload the coverage report from within the process to a remote server without having to execute an external tool.

Thanks for your help,

Antoine



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source