Skip to content

File format

Mitchell Hentges edited this page Feb 25, 2017 · 20 revisions

gcda/gcno structure (Input of lcov-rs)

These are binary files. Reference

gcda and gcno files follow the same "container" format:

Offset Size (bytes) Purpose Ignored?
0 4 Magic String ("gcda" or "gcno")
4 4 Version
8 4 Stamp (used for "merging") x
12 * Contains records

Each file is contained with different types of records.

gcno records

TAG_FUNCTION[0x01000000]
Offset Size (bytes) Purpose Ignored?
0 4 Identifier
4 4 Line # Checksum
8 4 Config Checksum
12 4 Fn Name Length
16 ^ Fn Name
? 4 Source Path Length
? ^ Source Path
? 4 Line #
TAG_LINES[0x01450000]

Some exceptions, see gcov header

Offset Size (bytes) Purpose Ignored?
0 4 Block # x
4 ? Contains multiple lines

Where each line is:

Offset Size (bytes) Purpose Ignored?
0 4 Line #
------ ------ If Line # == 0, then changing file: ------
4 4 Next filename's length
8 ^ Next filename
TAG_END_FILE[0x00000000]

If this record is encountered, then the rest of the file can be ignored.

gcda records

TAG_PROGRAM_SUMMARY[0xa3000000]
Offset Size (bytes) Purpose Ignored?
0 4 Number of counters ?
4 4 Number of program runs ?
8 8 Sum of all counters accumulated ?
16 8 Maximum value in single run ?
24 8 Sum of all runs' maximums ?
32 ? Histogram of counter values ?
TAG_FUNCTION[0x01000000]

Note: if this record isn't 3 bytes, it should be ignored.

Offset Size (bytes) Purpose Ignored?
0 4 Identifier
4 4 Line # Checksum
8 4 Config Checksum
TAG_COUNTER_BASE[0x01a10000]

Curiously unused when gcov reads gcda files. When in the main parse loop, the closest is a GCOV_TAG_FOR_COUNTER check, (which is based off of TAG_COUNTER_BASE)

TAG_END_FILE[0x00000000]

If this record is encountered, then the rest of the file can be ignored.

lcov "info" file (Output of lcov-rs)

This is a text file. Reference

Prefix Purpose Data Format Strategy
TN Test Name String name of test Leave blank, like lcov is doing in local tests
SF Source File Absolute path to source file Get function identifiers from gcda, use it to reference function definition in gcno file. Print the function's source file
FN Function line # of fn start, fn name Same as above, but print function definition's name
FNDA Fn Data Execution count of fn, fn name ?
FNF # Fn Found integer Print number of TAG_FUNCTION encountered in gcda
FNH # Fn Executed integer ?
DA Executions for some Line line #, execution count ?
LF # Lines Found integer Count lines from gcno lines records
LH # Lines Executed integer ?
end_of_record End of Record Signifies end of data for source file Use the constant "end_of_record"
Clone this wiki locally