xref: /netbsd-src/external/bsd/file/dist/magic/magdir/coverage (revision 25f16eeab3cef3574b7944f484c90bae9f02e957)
1ae9cfef6Schristos
2ae9cfef6Schristos#------------------------------------------------------------------------------
3*25f16eeaSchristos# $File: coverage,v 1.3 2021/02/23 00:51:10 christos Exp $
4ae9cfef6Schristos# xoverage:  file(1) magic for test coverage data
5ae9cfef6Schristos
6ae9cfef6Schristos# File formats used to store test coverage data
7ae9cfef6Schristos# 2016-05-21, Georg Sauthoff <mail@georg.so>
8ae9cfef6Schristos
9ae9cfef6Schristos
10ae9cfef6Schristos# - GCC gcno - written by GCC at compile time when compiling with
11ae9cfef6Schristos# 	gcc -ftest-coverage
12ae9cfef6Schristos# - GCC gcda - written by a program that was compiled with
13ae9cfef6Schristos#	gcc -fprofile-arcs
14ae9cfef6Schristos# - LLVM raw profiles - generated by a program compiled with
15ae9cfef6Schristos#	clang -fprofile-instr-generate -fcoverage-mapping ...
16ae9cfef6Schristos# - LLVM indexed profiles - generated by
17ae9cfef6Schristos#	llvm-profdata
18ae9cfef6Schristos# - GCOV reports, i.e. the annotated source code
19ae9cfef6Schristos# - LCOV trace files, i.e. aggregated GCC profiles
20ae9cfef6Schristos#
21ae9cfef6Schristos# GCC coverage tracefiles
22ae9cfef6Schristos# .gcno file are created during compile time,
23ae9cfef6Schristos# while data collected during runtime is stored in .gcda files
24ae9cfef6Schristos# cf. gcov-io.h
25ae9cfef6Schristos# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html
26ae9cfef6Schristos# Examples:
27ae9cfef6Schristos# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35
28ae9cfef6Schristos# Debian 8 PPC64/gcc-4.9.2  : 67 63 6e 6f 34 30 39 2a
29ae9cfef6Schristos0	lelong	0x67636e6f	GCC gcno coverage (-ftest-coverage),
30ae9cfef6Schristos>&3	byte	x	version %c.
31ae9cfef6Schristos>&1	byte	x	\b%c
32ae9cfef6Schristos
33ae9cfef6Schristos# big endian
34ae9cfef6Schristos0	belong	0x67636e6f	GCC gcno coverage (-ftest-coverage),
35ae9cfef6Schristos>&0	byte	x	version %c.
36ae9cfef6Schristos>&2	byte	x	\b%c (big-endian)
37ae9cfef6Schristos
38ae9cfef6Schristos# Examples:
39ae9cfef6Schristos# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35
40ae9cfef6Schristos# Debian 8 PPC64/gcc-4.9.2  : 67 63 64 61 34 30 39 2a
41ae9cfef6Schristos0	lelong	0x67636461	GCC gcda coverage (-fprofile-arcs),
42ae9cfef6Schristos>&3	byte	x	version %c.
43ae9cfef6Schristos>&1	byte	x	\b%c
44ae9cfef6Schristos
45ae9cfef6Schristos# big endian
46ae9cfef6Schristos0	belong	0x67636461	GCC gcda coverage (-fprofile-arcs),
47ae9cfef6Schristos>&0	byte	x	version %c.
48ae9cfef6Schristos>&2	byte	x	\b%c (big-endian)
49ae9cfef6Schristos
50ae9cfef6Schristos
51ae9cfef6Schristos# LCOV tracefiles
52ae9cfef6Schristos# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
53ae9cfef6Schristos0	string	TN:
54ae9cfef6Schristos>&0	search/64	\nSF:/	LCOV coverage tracefile
55ae9cfef6Schristos
56ae9cfef6Schristos
57ae9cfef6Schristos# Coverage reports generated by gcov
58*25f16eeaSchristos# i.e. source code annotated with coverage information
59ae9cfef6Schristos0	string	\x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source:
60ae9cfef6Schristos>&0	search/128	\x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph:
61ae9cfef6Schristos>>&0	search/128	\x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data:	GCOV coverage report
62ae9cfef6Schristos
63ae9cfef6Schristos
64ae9cfef6Schristos# LLVM coverage files
65ae9cfef6Schristos
66ae9cfef6Schristos# raw data after running a program compiled with:
67ae9cfef6Schristos# `clang -fprofile-instr-generate -fcoverage-mapping ...`
68ae9cfef6Schristos# default name: default.profraw
69ae9cfef6Schristos# magic is: \xFF lprofr \x81
70dc958920Schristos# cf. https://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html
71ae9cfef6Schristos0	lequad	0xff6c70726f667281	LLVM raw profile data,
72ae9cfef6Schristos>&0	byte	x	version %d
73ae9cfef6Schristos
74ae9cfef6Schristos# big endian
75ae9cfef6Schristos0	bequad	0xff6c70726f667281	LLVM raw profile data,
76ae9cfef6Schristos>&7	byte	x	version %d (big-endian)
77ae9cfef6Schristos
78ae9cfef6Schristos
79ae9cfef6Schristos# LLVM indexed instruction profile (as generated by llvm-profdata)
80ae9cfef6Schristos# magic is: reverse(\xFF lprofi \x81)
81dc958920Schristos# cf. https://llvm.org/docs/CoverageMappingFormat.html
82dc958920Schristos# https://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html
83dc958920Schristos# https://llvm.org/docs/CommandGuide/llvm-cov.html
84dc958920Schristos# https://llvm.org/docs/CommandGuide/llvm-profdata.html
85ae9cfef6Schristos0	lequad	0x8169666f72706cff	LLVM indexed profile data,
86ae9cfef6Schristos>&0	byte	x	version %d
87ae9cfef6Schristos
88ae9cfef6Schristos# big endian
89ae9cfef6Schristos0	bequad	0x8169666f72706cff	LLVM indexed profile data,
90ae9cfef6Schristos>&7	byte	x	version %d (big-endian)
91ae9cfef6Schristos
92