Skip to content

File format

Mitchell Hentges edited this page Mar 1, 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_BLOCKS[0x01430000]

Each block has "flags", which aren't used. However, the number of blocks is important, and can be inferred from the record size.

Offset Size (bytes) Purpose Ignored?
0 * One 32bit "flag" value per block x
TAG_ARCS[0x01430000]

Represents a "jump" (or an "arc", eyyy) from one block to another.

Offset Size (bytes) Purpose Ignored?
0 4 Source block #
4 * Contains multiple arcs

Where each arc is:

Offset Size (bytes) Purpose Ignored?
0 4 Destination block
4 4 Flag x
TAG_LINES[0x01450000]

Some exceptions, see gcov header

Offset Size (bytes) Purpose Ignored?
0 4 Block #
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 Checksum ?
4 4 Number of counters ?
8 4 Number of program runs ?
12 8 Sum of all counters accumulated ?
20 8 Maximum value in single run ?
28 8 Sum of all runs' maximums ?
36 * Contains histogram of buckets ?

Where each bucket is:

Offset Size (bytes) Purpose Ignored?
0 4 Number of counters whose profile count is within bucket
4 8 Minimum profile count included in bucket
12 8 Cumulative value of profile counts in bucket
TAG_FUNCTION[0x01000000]

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

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

TAG_COUNTER_BASE actually has one or more tags, based on how many "runs" have occurred:

  • Tag for the "run" #1: 0x01a10000
  • Tag for the "run" #2: 0x01a30000
  • Tag for the "run" #3: 0x01a50000
  • Tag for the "run" #4: 0x01a70000
  • And so on So, each run's COUNTER data is separately identifiable, and separated by 2^17
Offset Size (bytes) Purpose Ignored?
0 * Multiple 64bit "count" values
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 Use absolute source file path from gcno file (!).
FN Function line # of fn start, fn name Function from gcno file where src_path is the current SF and first lines record refers to current SF (!)
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" (!)
  • It is possible to have an output record where some functions are printed in the FNDA section, but not in the FN section. This occurs when a function's src_path is SF, but its first line record refers to a different source file. For example, the TimeStamp.cpp constructor is in FNDA, but not FN
Clone this wiki locally