dawn-cmake/tools/src/cmd/turbo-cov
Ben Clayton 98bd83a8fc tools: More CTS coverage fixes
* Use common_compile_options(turbo-cov) to fix RTTI linker errors on macOS + debug builds.
* Delete the .profraw files after they've been consumed.
* Include the test-case parameters in the coverage information

Change-Id: I02c6f408ed6e65c6f7e9eb1b4cd8443e4cfa7939
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117882
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2023-02-01 15:02:56 +00:00
..
CMakeLists.txt tools: More CTS coverage fixes 2023-02-01 15:02:56 +00:00
README.md tools: Add documentation for coverage viewer 2022-12-13 15:48:49 +00:00
main.cpp code-coverage / turbocov fixes 2023-01-26 15:57:27 +00:00

README.md

turbo-cov

About

turbo-cov can be used by the ./tools/run cts run-cts tool, when passing the --coverage flag. turbo-cov is substantially faster at processing coverage data than using the standard LLVM tools.

Requirements

To build turbo-cov, you will need to set the CMake define the CMake flag LLVM_SOURCE_DIR to the /llvm subdirectory of a LLVM checkout. turbo-cov requires LLVM 9+.

Details

Clang provides two tools for processing coverage data:

  • llvm-profdata indexes the raw .profraw coverage profile file and emits a .profdata file.
  • llvm-cov further processes the .profdata file into something human readable or machine parsable.

llvm-cov provides many options, including emitting an pretty HTML file, but is remarkably slow at producing easily machine-parsable data. Fortunately the core of llvm-cov is a few hundreds of lines of code, as it relies on LLVM libraries to do the heavy lifting.

turbo-cov is a a simple llvm-cov replacement, which efficiently converts a .profdata into a simple binary stream which can be consumed by the tools/src/cov package.

File structure

turbo-cov is a trivial binary stream, which takes the tightly-packed form:

struct Root {
    uint32_t num_files;
    File file[num_files];
};
struct File {
    uint32_t name_length
    uint8_t  name_data[name_length];
    uint32_t num_segments;
    Segment  segments[num_segments];
};
struct Segment {
    // The line where this segment begins.
    uint32_t line;
    // The column where this segment begins.
    uint32_t column;
    // The execution count, or zero if no count was recorded.
    uint32_t count;
    // When 0, the segment was uninstrumented or skipped.
    uint8_t  hasCount;
}