Skip to main content

Module coverage

Module coverage 

Source
Expand description

The coverage phase: an instrumented test run rendered into web/static/doc/coverage.

grcov can read the raw profiles itself, but it then holds every binary’s results at once and runs one llvm-cov per CPU β€” about 13 GiB for this workspace, enough to OOM-kill the job on an 8 GiB CI node. So the profiles are merged here single-threaded, each instrumented object is exported to lcov on its own, and grcov only renders. Exporting per object keeps grcov’s numbers: one export over every object discards the counters of functions compiled differently in different binaries.

Unlike grcov, which skips an object llvm-cov cannot export, a failed export fails the phase: every exported object carries a real coverage map, so a failure means a broken build, and a quietly lower percentage would hide it.

StructsΒ§

SectionTable πŸ”’
Where an ELF64 little-endian object keeps its section headers.

ConstantsΒ§

COVMAP_SECTION πŸ”’
The section every instrumented object carries.
ELF_HEADER_LEN πŸ”’
ELF_IDENT πŸ”’
ELF magic, 64-bit class, little-endian data: the only objects CI builds.
E_SHENTSIZE πŸ”’
E_SHNUM πŸ”’
E_SHOFF πŸ”’
E_SHSTRNDX πŸ”’
LCOV_DIR πŸ”’
MAX_TABLE_LEN πŸ”’
Real section and name tables are kilobytes; anything past this is corrupt.
PROFDATA πŸ”’
PROFRAW_DIR πŸ”’
SHN_XINDEX πŸ”’
The name-table index an object with extended numbering stores in section 0.
SH_LINK πŸ”’
SH_NAME πŸ”’
SH_OFFSET πŸ”’
SH_SIZE πŸ”’
TARGET_DIR πŸ”’

FunctionsΒ§

collect_objects πŸ”’
copy_workspace_records πŸ”’
Copies only the records of sources under root, with their paths made relative. The report ignores every absolute path anyway, and dropping the registry and toolchain records here keeps gigabytes of lcov off the disk. Returns how many records were kept.
elf_has_section πŸ”’
Looks the name up in the ELF section table. Matching it anywhere in the file also accepts binaries that merely contain the string β€” xtask itself among them β€” and llvm-cov refuses to export those.
export_object πŸ”’
Returns how many workspace source records were kept.
export_objects πŸ”’
fill πŸ”’
false when the file ends first: a truncated file is not an object.
has_coverage_map πŸ”’
instrumented_objects πŸ”’
instrumented_test_run πŸ”’
is_candidate πŸ”’
Executables (tests, binaries, build scripts) and shared objects (proc macros, which run inside rustc) are what carry coverage maps.
le_bytes πŸ”’
llvm_bin πŸ”’
llvm-tools installs its binaries beside the host target’s libdir.
llvm_bin_for πŸ”’
merge_profiles πŸ”’
One thread: the default of one per CPU took 3 GiB for this merge, one thread takes 250 MiB.
read_region πŸ”’
Reads len bytes at offset; None when the region is implausibly large or runs past the end of the file.
render_html πŸ”’
require_llvm_tools πŸ”’
resolve_extended πŸ”’
With 0xff00 or more sections the header’s count is 0 and its name index is SHN_XINDEX; the real values live in section 0’s sh_size and sh_link.
run_coverage
Instrumented test run, then the HTML report.
section_name πŸ”’