1282e23f0SXin LI 2282e23f0SXin LI#------------------------------------------------------------------------------ 3*43a5ec4eSXin LI# $File: coverage,v 1.3 2021/02/23 00:51:10 christos Exp $ 4282e23f0SXin LI# xoverage: file(1) magic for test coverage data 5282e23f0SXin LI 6282e23f0SXin LI# File formats used to store test coverage data 7282e23f0SXin LI# 2016-05-21, Georg Sauthoff <mail@georg.so> 8282e23f0SXin LI 9282e23f0SXin LI 10282e23f0SXin LI# - GCC gcno - written by GCC at compile time when compiling with 11282e23f0SXin LI# gcc -ftest-coverage 12282e23f0SXin LI# - GCC gcda - written by a program that was compiled with 13282e23f0SXin LI# gcc -fprofile-arcs 14282e23f0SXin LI# - LLVM raw profiles - generated by a program compiled with 15282e23f0SXin LI# clang -fprofile-instr-generate -fcoverage-mapping ... 16282e23f0SXin LI# - LLVM indexed profiles - generated by 17282e23f0SXin LI# llvm-profdata 18282e23f0SXin LI# - GCOV reports, i.e. the annotated source code 19282e23f0SXin LI# - LCOV trace files, i.e. aggregated GCC profiles 20282e23f0SXin LI# 21282e23f0SXin LI# GCC coverage tracefiles 22282e23f0SXin LI# .gcno file are created during compile time, 23282e23f0SXin LI# while data collected during runtime is stored in .gcda files 24282e23f0SXin LI# cf. gcov-io.h 25282e23f0SXin LI# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html 26282e23f0SXin LI# Examples: 27282e23f0SXin LI# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35 28282e23f0SXin LI# Debian 8 PPC64/gcc-4.9.2 : 67 63 6e 6f 34 30 39 2a 29282e23f0SXin LI0 lelong 0x67636e6f GCC gcno coverage (-ftest-coverage), 30282e23f0SXin LI>&3 byte x version %c. 31282e23f0SXin LI>&1 byte x \b%c 32282e23f0SXin LI 33282e23f0SXin LI# big endian 34282e23f0SXin LI0 belong 0x67636e6f GCC gcno coverage (-ftest-coverage), 35282e23f0SXin LI>&0 byte x version %c. 36282e23f0SXin LI>&2 byte x \b%c (big-endian) 37282e23f0SXin LI 38282e23f0SXin LI# Examples: 39282e23f0SXin LI# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35 40282e23f0SXin LI# Debian 8 PPC64/gcc-4.9.2 : 67 63 64 61 34 30 39 2a 41282e23f0SXin LI0 lelong 0x67636461 GCC gcda coverage (-fprofile-arcs), 42282e23f0SXin LI>&3 byte x version %c. 43282e23f0SXin LI>&1 byte x \b%c 44282e23f0SXin LI 45282e23f0SXin LI# big endian 46282e23f0SXin LI0 belong 0x67636461 GCC gcda coverage (-fprofile-arcs), 47282e23f0SXin LI>&0 byte x version %c. 48282e23f0SXin LI>&2 byte x \b%c (big-endian) 49282e23f0SXin LI 50282e23f0SXin LI 51282e23f0SXin LI# LCOV tracefiles 52282e23f0SXin LI# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php 53282e23f0SXin LI0 string TN: 54282e23f0SXin LI>&0 search/64 \nSF:/ LCOV coverage tracefile 55282e23f0SXin LI 56282e23f0SXin LI 57282e23f0SXin LI# Coverage reports generated by gcov 58*43a5ec4eSXin LI# i.e. source code annotated with coverage information 59282e23f0SXin LI0 string \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source: 60282e23f0SXin LI>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph: 61282e23f0SXin LI>>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data: GCOV coverage report 62282e23f0SXin LI 63282e23f0SXin LI 64282e23f0SXin LI# LLVM coverage files 65282e23f0SXin LI 66282e23f0SXin LI# raw data after running a program compiled with: 67282e23f0SXin LI# `clang -fprofile-instr-generate -fcoverage-mapping ...` 68282e23f0SXin LI# default name: default.profraw 69282e23f0SXin LI# magic is: \xFF lprofr \x81 7048c779cdSXin LI# cf. https://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html 71282e23f0SXin LI0 lequad 0xff6c70726f667281 LLVM raw profile data, 72282e23f0SXin LI>&0 byte x version %d 73282e23f0SXin LI 74282e23f0SXin LI# big endian 75282e23f0SXin LI0 bequad 0xff6c70726f667281 LLVM raw profile data, 76282e23f0SXin LI>&7 byte x version %d (big-endian) 77282e23f0SXin LI 78282e23f0SXin LI 79282e23f0SXin LI# LLVM indexed instruction profile (as generated by llvm-profdata) 80282e23f0SXin LI# magic is: reverse(\xFF lprofi \x81) 8148c779cdSXin LI# cf. https://llvm.org/docs/CoverageMappingFormat.html 8248c779cdSXin LI# https://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html 8348c779cdSXin LI# https://llvm.org/docs/CommandGuide/llvm-cov.html 8448c779cdSXin LI# https://llvm.org/docs/CommandGuide/llvm-profdata.html 85282e23f0SXin LI0 lequad 0x8169666f72706cff LLVM indexed profile data, 86282e23f0SXin LI>&0 byte x version %d 87282e23f0SXin LI 88282e23f0SXin LI# big endian 89282e23f0SXin LI0 bequad 0x8169666f72706cff LLVM indexed profile data, 90282e23f0SXin LI>&7 byte x version %d (big-endian) 91282e23f0SXin LI 92