xref: /dragonfly/contrib/gcc-8.0/gcc/gcov-io.h (revision 38fd1498)
1*38fd1498Szrj /* File format for coverage information
2*38fd1498Szrj    Copyright (C) 1996-2018 Free Software Foundation, Inc.
3*38fd1498Szrj    Contributed by Bob Manson <manson@cygnus.com>.
4*38fd1498Szrj    Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
5*38fd1498Szrj 
6*38fd1498Szrj This file is part of GCC.
7*38fd1498Szrj 
8*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
9*38fd1498Szrj the terms of the GNU General Public License as published by the Free
10*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
11*38fd1498Szrj version.
12*38fd1498Szrj 
13*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16*38fd1498Szrj for more details.
17*38fd1498Szrj 
18*38fd1498Szrj Under Section 7 of GPL version 3, you are granted additional
19*38fd1498Szrj permissions described in the GCC Runtime Library Exception, version
20*38fd1498Szrj 3.1, as published by the Free Software Foundation.
21*38fd1498Szrj 
22*38fd1498Szrj You should have received a copy of the GNU General Public License and
23*38fd1498Szrj a copy of the GCC Runtime Library Exception along with this program;
24*38fd1498Szrj see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25*38fd1498Szrj <http://www.gnu.org/licenses/>.  */
26*38fd1498Szrj 
27*38fd1498Szrj 
28*38fd1498Szrj /* Coverage information is held in two files.  A notes file, which is
29*38fd1498Szrj    generated by the compiler, and a data file, which is generated by
30*38fd1498Szrj    the program under test.  Both files use a similar structure.  We do
31*38fd1498Szrj    not attempt to make these files backwards compatible with previous
32*38fd1498Szrj    versions, as you only need coverage information when developing a
33*38fd1498Szrj    program.  We do hold version information, so that mismatches can be
34*38fd1498Szrj    detected, and we use a format that allows tools to skip information
35*38fd1498Szrj    they do not understand or are not interested in.
36*38fd1498Szrj 
37*38fd1498Szrj    Numbers are recorded in the 32 bit unsigned binary form of the
38*38fd1498Szrj    endianness of the machine generating the file. 64 bit numbers are
39*38fd1498Szrj    stored as two 32 bit numbers, the low part first.  Strings are
40*38fd1498Szrj    padded with 1 to 4 NUL bytes, to bring the length up to a multiple
41*38fd1498Szrj    of 4. The number of 4 bytes is stored, followed by the padded
42*38fd1498Szrj    string. Zero length and NULL strings are simply stored as a length
43*38fd1498Szrj    of zero (they have no trailing NUL or padding).
44*38fd1498Szrj 
45*38fd1498Szrj    	int32:  byte3 byte2 byte1 byte0 | byte0 byte1 byte2 byte3
46*38fd1498Szrj 	int64:  int32:low int32:high
47*38fd1498Szrj 	string: int32:0 | int32:length char* char:0 padding
48*38fd1498Szrj 	padding: | char:0 | char:0 char:0 | char:0 char:0 char:0
49*38fd1498Szrj 	item: int32 | int64 | string
50*38fd1498Szrj 
51*38fd1498Szrj    The basic format of the notes file is
52*38fd1498Szrj 
53*38fd1498Szrj 	file : int32:magic int32:version int32:stamp int32:support_unexecuted_blocks record*
54*38fd1498Szrj 
55*38fd1498Szrj    The basic format of the data file is
56*38fd1498Szrj 
57*38fd1498Szrj    	file : int32:magic int32:version int32:stamp record*
58*38fd1498Szrj 
59*38fd1498Szrj    The magic ident is different for the notes and the data files.  The
60*38fd1498Szrj    magic ident is used to determine the endianness of the file, when
61*38fd1498Szrj    reading.  The version is the same for both files and is derived
62*38fd1498Szrj    from gcc's version number. The stamp value is used to synchronize
63*38fd1498Szrj    note and data files and to synchronize merging within a data
64*38fd1498Szrj    file. It need not be an absolute time stamp, merely a ticker that
65*38fd1498Szrj    increments fast enough and cycles slow enough to distinguish
66*38fd1498Szrj    different compile/run/compile cycles.
67*38fd1498Szrj 
68*38fd1498Szrj    Although the ident and version are formally 32 bit numbers, they
69*38fd1498Szrj    are derived from 4 character ASCII strings.  The version number
70*38fd1498Szrj    consists of a two character major version number
71*38fd1498Szrj    (first digit starts from 'A' letter to not to clash with the older
72*38fd1498Szrj    numbering scheme), the single character minor version number,
73*38fd1498Szrj    and a single character indicating the status of the release.
74*38fd1498Szrj    That will be 'e' experimental, 'p' prerelease and 'r' for release.
75*38fd1498Szrj    Because, by good fortune, these are in alphabetical order, string
76*38fd1498Szrj    collating can be used to compare version strings.  Be aware that
77*38fd1498Szrj    the 'e' designation will (naturally) be unstable and might be
78*38fd1498Szrj    incompatible with itself.  For gcc 17.0 experimental, it would be
79*38fd1498Szrj    'B70e' (0x42373065).  As we currently do not release more than 5 minor
80*38fd1498Szrj    releases, the single character should be always fine.  Major number
81*38fd1498Szrj    is currently changed roughly every year, which gives us space
82*38fd1498Szrj    for next 250 years (maximum allowed number would be 259.9).
83*38fd1498Szrj 
84*38fd1498Szrj    A record has a tag, length and variable amount of data.
85*38fd1498Szrj 
86*38fd1498Szrj    	record: header data
87*38fd1498Szrj 	header: int32:tag int32:length
88*38fd1498Szrj 	data: item*
89*38fd1498Szrj 
90*38fd1498Szrj    Records are not nested, but there is a record hierarchy.  Tag
91*38fd1498Szrj    numbers reflect this hierarchy.  Tags are unique across note and
92*38fd1498Szrj    data files.  Some record types have a varying amount of data.  The
93*38fd1498Szrj    LENGTH is the number of 4bytes that follow and is usually used to
94*38fd1498Szrj    determine how much data.  The tag value is split into 4 8-bit
95*38fd1498Szrj    fields, one for each of four possible levels.  The most significant
96*38fd1498Szrj    is allocated first.  Unused levels are zero.  Active levels are
97*38fd1498Szrj    odd-valued, so that the LSB of the level is one.  A sub-level
98*38fd1498Szrj    incorporates the values of its superlevels.  This formatting allows
99*38fd1498Szrj    you to determine the tag hierarchy, without understanding the tags
100*38fd1498Szrj    themselves, and is similar to the standard section numbering used
101*38fd1498Szrj    in technical documents.  Level values [1..3f] are used for common
102*38fd1498Szrj    tags, values [41..9f] for the notes file and [a1..ff] for the data
103*38fd1498Szrj    file.
104*38fd1498Szrj 
105*38fd1498Szrj    The notes file contains the following records
106*38fd1498Szrj    	note: unit function-graph*
107*38fd1498Szrj 	unit: header int32:checksum string:source
108*38fd1498Szrj 	function-graph: announce_function basic_blocks {arcs | lines}*
109*38fd1498Szrj 	announce_function: header int32:ident
110*38fd1498Szrj 		int32:lineno_checksum int32:cfg_checksum
111*38fd1498Szrj 		string:name string:source int32:start_lineno int32:start_column int32:end_lineno
112*38fd1498Szrj 	basic_block: header int32:flags*
113*38fd1498Szrj 	arcs: header int32:block_no arc*
114*38fd1498Szrj 	arc:  int32:dest_block int32:flags
115*38fd1498Szrj         lines: header int32:block_no line*
116*38fd1498Szrj                int32:0 string:NULL
117*38fd1498Szrj 	line:  int32:line_no | int32:0 string:filename
118*38fd1498Szrj 
119*38fd1498Szrj    The BASIC_BLOCK record holds per-bb flags.  The number of blocks
120*38fd1498Szrj    can be inferred from its data length.  There is one ARCS record per
121*38fd1498Szrj    basic block.  The number of arcs from a bb is implicit from the
122*38fd1498Szrj    data length.  It enumerates the destination bb and per-arc flags.
123*38fd1498Szrj    There is one LINES record per basic block, it enumerates the source
124*38fd1498Szrj    lines which belong to that basic block.  Source file names are
125*38fd1498Szrj    introduced by a line number of 0, following lines are from the new
126*38fd1498Szrj    source file.  The initial source file for the function is NULL, but
127*38fd1498Szrj    the current source file should be remembered from one LINES record
128*38fd1498Szrj    to the next.  The end of a block is indicated by an empty filename
129*38fd1498Szrj    - this does not reset the current source file.  Note there is no
130*38fd1498Szrj    ordering of the ARCS and LINES records: they may be in any order,
131*38fd1498Szrj    interleaved in any manner.  The current filename follows the order
132*38fd1498Szrj    the LINES records are stored in the file, *not* the ordering of the
133*38fd1498Szrj    blocks they are for.
134*38fd1498Szrj 
135*38fd1498Szrj    The data file contains the following records.
136*38fd1498Szrj         data: {unit summary:object summary:program* function-data*}*
137*38fd1498Szrj 	unit: header int32:checksum
138*38fd1498Szrj         function-data:	announce_function present counts
139*38fd1498Szrj 	announce_function: header int32:ident
140*38fd1498Szrj 		int32:lineno_checksum int32:cfg_checksum
141*38fd1498Szrj 	present: header int32:present
142*38fd1498Szrj 	counts: header int64:count*
143*38fd1498Szrj 	summary: int32:checksum {count-summary}GCOV_COUNTERS_SUMMABLE
144*38fd1498Szrj 	count-summary:	int32:num int32:runs int64:sum
145*38fd1498Szrj 			int64:max int64:sum_max histogram
146*38fd1498Szrj         histogram: {int32:bitvector}8 histogram-buckets*
147*38fd1498Szrj         histogram-buckets: int32:num int64:min int64:sum
148*38fd1498Szrj 
149*38fd1498Szrj    The ANNOUNCE_FUNCTION record is the same as that in the note file,
150*38fd1498Szrj    but without the source location.  The COUNTS gives the
151*38fd1498Szrj    counter values for instrumented features.  The about the whole
152*38fd1498Szrj    program.  The checksum is used for whole program summaries, and
153*38fd1498Szrj    disambiguates different programs which include the same
154*38fd1498Szrj    instrumented object file.  There may be several program summaries,
155*38fd1498Szrj    each with a unique checksum.  The object summary's checksum is
156*38fd1498Szrj    zero.  Note that the data file might contain information from
157*38fd1498Szrj    several runs concatenated, or the data might be merged.
158*38fd1498Szrj 
159*38fd1498Szrj    This file is included by both the compiler, gcov tools and the
160*38fd1498Szrj    runtime support library libgcov. IN_LIBGCOV and IN_GCOV are used to
161*38fd1498Szrj    distinguish which case is which.  If IN_LIBGCOV is nonzero,
162*38fd1498Szrj    libgcov is being built. If IN_GCOV is nonzero, the gcov tools are
163*38fd1498Szrj    being built. Otherwise the compiler is being built. IN_GCOV may be
164*38fd1498Szrj    positive or negative. If positive, we are compiling a tool that
165*38fd1498Szrj    requires additional functions (see the code for knowledge of what
166*38fd1498Szrj    those functions are).  */
167*38fd1498Szrj 
168*38fd1498Szrj #ifndef GCC_GCOV_IO_H
169*38fd1498Szrj #define GCC_GCOV_IO_H
170*38fd1498Szrj 
171*38fd1498Szrj #ifndef IN_LIBGCOV
172*38fd1498Szrj /* About the host */
173*38fd1498Szrj 
174*38fd1498Szrj typedef unsigned gcov_unsigned_t;
175*38fd1498Szrj typedef unsigned gcov_position_t;
176*38fd1498Szrj /* gcov_type is typedef'd elsewhere for the compiler */
177*38fd1498Szrj #if IN_GCOV
178*38fd1498Szrj #define GCOV_LINKAGE static
179*38fd1498Szrj typedef int64_t gcov_type;
180*38fd1498Szrj typedef uint64_t gcov_type_unsigned;
181*38fd1498Szrj #if IN_GCOV > 0
182*38fd1498Szrj #include <sys/types.h>
183*38fd1498Szrj #endif
184*38fd1498Szrj #endif
185*38fd1498Szrj 
186*38fd1498Szrj #if defined (HOST_HAS_F_SETLKW)
187*38fd1498Szrj #define GCOV_LOCKED 1
188*38fd1498Szrj #else
189*38fd1498Szrj #define GCOV_LOCKED 0
190*38fd1498Szrj #endif
191*38fd1498Szrj 
192*38fd1498Szrj #define ATTRIBUTE_HIDDEN
193*38fd1498Szrj 
194*38fd1498Szrj #endif /* !IN_LIBGOCV */
195*38fd1498Szrj 
196*38fd1498Szrj #ifndef GCOV_LINKAGE
197*38fd1498Szrj #define GCOV_LINKAGE extern
198*38fd1498Szrj #endif
199*38fd1498Szrj 
200*38fd1498Szrj #if IN_LIBGCOV
201*38fd1498Szrj #define gcov_nonruntime_assert(EXPR) ((void)(0 && (EXPR)))
202*38fd1498Szrj #else
203*38fd1498Szrj #define gcov_nonruntime_assert(EXPR) gcc_assert (EXPR)
204*38fd1498Szrj #define gcov_error(...) fatal_error (input_location, __VA_ARGS__)
205*38fd1498Szrj #endif
206*38fd1498Szrj 
207*38fd1498Szrj /* File suffixes.  */
208*38fd1498Szrj #define GCOV_DATA_SUFFIX ".gcda"
209*38fd1498Szrj #define GCOV_NOTE_SUFFIX ".gcno"
210*38fd1498Szrj 
211*38fd1498Szrj /* File magic. Must not be palindromes.  */
212*38fd1498Szrj #define GCOV_DATA_MAGIC ((gcov_unsigned_t)0x67636461) /* "gcda" */
213*38fd1498Szrj #define GCOV_NOTE_MAGIC ((gcov_unsigned_t)0x67636e6f) /* "gcno" */
214*38fd1498Szrj 
215*38fd1498Szrj /* gcov-iov.h is automatically generated by the makefile from
216*38fd1498Szrj    version.c, it looks like
217*38fd1498Szrj    	#define GCOV_VERSION ((gcov_unsigned_t)0x89abcdef)
218*38fd1498Szrj */
219*38fd1498Szrj #include "gcov-iov.h"
220*38fd1498Szrj 
221*38fd1498Szrj /* Convert a magic or version number to a 4 character string.  */
222*38fd1498Szrj #define GCOV_UNSIGNED2STRING(ARRAY,VALUE)	\
223*38fd1498Szrj   ((ARRAY)[0] = (char)((VALUE) >> 24),		\
224*38fd1498Szrj    (ARRAY)[1] = (char)((VALUE) >> 16),		\
225*38fd1498Szrj    (ARRAY)[2] = (char)((VALUE) >> 8),		\
226*38fd1498Szrj    (ARRAY)[3] = (char)((VALUE) >> 0))
227*38fd1498Szrj 
228*38fd1498Szrj /* The record tags.  Values [1..3f] are for tags which may be in either
229*38fd1498Szrj    file.  Values [41..9f] for those in the note file and [a1..ff] for
230*38fd1498Szrj    the data file.  The tag value zero is used as an explicit end of
231*38fd1498Szrj    file marker -- it is not required to be present.  */
232*38fd1498Szrj 
233*38fd1498Szrj #define GCOV_TAG_FUNCTION	 ((gcov_unsigned_t)0x01000000)
234*38fd1498Szrj #define GCOV_TAG_FUNCTION_LENGTH (3)
235*38fd1498Szrj #define GCOV_TAG_BLOCKS		 ((gcov_unsigned_t)0x01410000)
236*38fd1498Szrj #define GCOV_TAG_BLOCKS_LENGTH(NUM) (NUM)
237*38fd1498Szrj #define GCOV_TAG_ARCS		 ((gcov_unsigned_t)0x01430000)
238*38fd1498Szrj #define GCOV_TAG_ARCS_LENGTH(NUM)  (1 + (NUM) * 2)
239*38fd1498Szrj #define GCOV_TAG_ARCS_NUM(LENGTH)  (((LENGTH) - 1) / 2)
240*38fd1498Szrj #define GCOV_TAG_LINES		 ((gcov_unsigned_t)0x01450000)
241*38fd1498Szrj #define GCOV_TAG_COUNTER_BASE 	 ((gcov_unsigned_t)0x01a10000)
242*38fd1498Szrj #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
243*38fd1498Szrj #define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
244*38fd1498Szrj #define GCOV_TAG_OBJECT_SUMMARY  ((gcov_unsigned_t)0xa1000000) /* Obsolete */
245*38fd1498Szrj #define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
246*38fd1498Szrj #define GCOV_TAG_SUMMARY_LENGTH(NUM)  \
247*38fd1498Szrj         (1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
248*38fd1498Szrj #define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
249*38fd1498Szrj #define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
250*38fd1498Szrj #define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
251*38fd1498Szrj 
252*38fd1498Szrj 
253*38fd1498Szrj /* Counters that are collected.  */
254*38fd1498Szrj 
255*38fd1498Szrj #define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) COUNTER,
256*38fd1498Szrj enum {
257*38fd1498Szrj #include "gcov-counter.def"
258*38fd1498Szrj GCOV_COUNTERS
259*38fd1498Szrj };
260*38fd1498Szrj #undef DEF_GCOV_COUNTER
261*38fd1498Szrj 
262*38fd1498Szrj /* Counters which can be summaried.  */
263*38fd1498Szrj #define GCOV_COUNTERS_SUMMABLE	(GCOV_COUNTER_ARCS + 1)
264*38fd1498Szrj 
265*38fd1498Szrj /* The first of counters used for value profiling.  They must form a
266*38fd1498Szrj    consecutive interval and their order must match the order of
267*38fd1498Szrj    HIST_TYPEs in value-prof.h.  */
268*38fd1498Szrj #define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTERS_SUMMABLE
269*38fd1498Szrj 
270*38fd1498Szrj /* The last of counters used for value profiling.  */
271*38fd1498Szrj #define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1)
272*38fd1498Szrj 
273*38fd1498Szrj /* Number of counters used for value profiling.  */
274*38fd1498Szrj #define GCOV_N_VALUE_COUNTERS \
275*38fd1498Szrj   (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
276*38fd1498Szrj 
277*38fd1498Szrj /* The number of hottest callees to be tracked.  */
278*38fd1498Szrj #define GCOV_ICALL_TOPN_VAL  2
279*38fd1498Szrj 
280*38fd1498Szrj /* The number of counter entries per icall callsite.  */
281*38fd1498Szrj #define GCOV_ICALL_TOPN_NCOUNTS (1 + GCOV_ICALL_TOPN_VAL * 4)
282*38fd1498Szrj 
283*38fd1498Szrj /* Convert a counter index to a tag.  */
284*38fd1498Szrj #define GCOV_TAG_FOR_COUNTER(COUNT)				\
285*38fd1498Szrj 	(GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17))
286*38fd1498Szrj /* Convert a tag to a counter.  */
287*38fd1498Szrj #define GCOV_COUNTER_FOR_TAG(TAG)					\
288*38fd1498Szrj 	((unsigned)(((TAG) - GCOV_TAG_COUNTER_BASE) >> 17))
289*38fd1498Szrj /* Check whether a tag is a counter tag.  */
290*38fd1498Szrj #define GCOV_TAG_IS_COUNTER(TAG)				\
291*38fd1498Szrj 	(!((TAG) & 0xFFFF) && GCOV_COUNTER_FOR_TAG (TAG) < GCOV_COUNTERS)
292*38fd1498Szrj 
293*38fd1498Szrj /* The tag level mask has 1's in the position of the inner levels, &
294*38fd1498Szrj    the lsb of the current level, and zero on the current and outer
295*38fd1498Szrj    levels.  */
296*38fd1498Szrj #define GCOV_TAG_MASK(TAG) (((TAG) - 1) ^ (TAG))
297*38fd1498Szrj 
298*38fd1498Szrj /* Return nonzero if SUB is an immediate subtag of TAG.  */
299*38fd1498Szrj #define GCOV_TAG_IS_SUBTAG(TAG,SUB)				\
300*38fd1498Szrj 	(GCOV_TAG_MASK (TAG) >> 8 == GCOV_TAG_MASK (SUB) 	\
301*38fd1498Szrj 	 && !(((SUB) ^ (TAG)) & ~GCOV_TAG_MASK (TAG)))
302*38fd1498Szrj 
303*38fd1498Szrj /* Return nonzero if SUB is at a sublevel to TAG.  */
304*38fd1498Szrj #define GCOV_TAG_IS_SUBLEVEL(TAG,SUB)				\
305*38fd1498Szrj      	(GCOV_TAG_MASK (TAG) > GCOV_TAG_MASK (SUB))
306*38fd1498Szrj 
307*38fd1498Szrj /* Basic block flags.  */
308*38fd1498Szrj #define GCOV_BLOCK_UNEXPECTED	(1 << 1)
309*38fd1498Szrj 
310*38fd1498Szrj /* Arc flags.  */
311*38fd1498Szrj #define GCOV_ARC_ON_TREE 	(1 << 0)
312*38fd1498Szrj #define GCOV_ARC_FAKE		(1 << 1)
313*38fd1498Szrj #define GCOV_ARC_FALLTHROUGH	(1 << 2)
314*38fd1498Szrj 
315*38fd1498Szrj /* Structured records.  */
316*38fd1498Szrj 
317*38fd1498Szrj /* Structure used for each bucket of the log2 histogram of counter values.  */
318*38fd1498Szrj typedef struct
319*38fd1498Szrj {
320*38fd1498Szrj   /* Number of counters whose profile count falls within the bucket.  */
321*38fd1498Szrj   gcov_unsigned_t num_counters;
322*38fd1498Szrj   /* Smallest profile count included in this bucket.  */
323*38fd1498Szrj   gcov_type min_value;
324*38fd1498Szrj   /* Cumulative value of the profile counts in this bucket.  */
325*38fd1498Szrj   gcov_type cum_value;
326*38fd1498Szrj } gcov_bucket_type;
327*38fd1498Szrj 
328*38fd1498Szrj /* For a log2 scale histogram with each range split into 4
329*38fd1498Szrj    linear sub-ranges, there will be at most 64 (max gcov_type bit size) - 1 log2
330*38fd1498Szrj    ranges since the lowest 2 log2 values share the lowest 4 linear
331*38fd1498Szrj    sub-range (values 0 - 3).  This is 252 total entries (63*4).  */
332*38fd1498Szrj 
333*38fd1498Szrj #define GCOV_HISTOGRAM_SIZE 252
334*38fd1498Szrj 
335*38fd1498Szrj /* How many unsigned ints are required to hold a bit vector of non-zero
336*38fd1498Szrj    histogram entries when the histogram is written to the gcov file.
337*38fd1498Szrj    This is essentially a ceiling divide by 32 bits.  */
338*38fd1498Szrj #define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
339*38fd1498Szrj 
340*38fd1498Szrj /* Cumulative counter data.  */
341*38fd1498Szrj struct gcov_ctr_summary
342*38fd1498Szrj {
343*38fd1498Szrj   gcov_unsigned_t num;		/* number of counters.  */
344*38fd1498Szrj   gcov_unsigned_t runs;		/* number of program runs */
345*38fd1498Szrj   gcov_type sum_all;		/* sum of all counters accumulated.  */
346*38fd1498Szrj   gcov_type run_max;		/* maximum value on a single run.  */
347*38fd1498Szrj   gcov_type sum_max;    	/* sum of individual run max values.  */
348*38fd1498Szrj   gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* histogram of
349*38fd1498Szrj                                                       counter values.  */
350*38fd1498Szrj };
351*38fd1498Szrj 
352*38fd1498Szrj /* Object & program summary record.  */
353*38fd1498Szrj struct gcov_summary
354*38fd1498Szrj {
355*38fd1498Szrj   gcov_unsigned_t checksum;	/* checksum of program */
356*38fd1498Szrj   struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
357*38fd1498Szrj };
358*38fd1498Szrj 
359*38fd1498Szrj #if !defined(inhibit_libc)
360*38fd1498Szrj 
361*38fd1498Szrj /* Functions for reading and writing gcov files. In libgcov you can
362*38fd1498Szrj    open the file for reading then writing. Elsewhere you can open the
363*38fd1498Szrj    file either for reading or for writing. When reading a file you may
364*38fd1498Szrj    use the gcov_read_* functions, gcov_sync, gcov_position, &
365*38fd1498Szrj    gcov_error. When writing a file you may use the gcov_write
366*38fd1498Szrj    functions, gcov_seek & gcov_error. When a file is to be rewritten
367*38fd1498Szrj    you use the functions for reading, then gcov_rewrite then the
368*38fd1498Szrj    functions for writing.  Your file may become corrupted if you break
369*38fd1498Szrj    these invariants.  */
370*38fd1498Szrj 
371*38fd1498Szrj #if !IN_LIBGCOV
372*38fd1498Szrj GCOV_LINKAGE int gcov_open (const char */*name*/, int /*direction*/);
373*38fd1498Szrj GCOV_LINKAGE int gcov_magic (gcov_unsigned_t, gcov_unsigned_t);
374*38fd1498Szrj #endif
375*38fd1498Szrj 
376*38fd1498Szrj /* Available everywhere.  */
377*38fd1498Szrj GCOV_LINKAGE int gcov_close (void) ATTRIBUTE_HIDDEN;
378*38fd1498Szrj GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void) ATTRIBUTE_HIDDEN;
379*38fd1498Szrj GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN;
380*38fd1498Szrj GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN;
381*38fd1498Szrj GCOV_LINKAGE const char *gcov_read_string (void);
382*38fd1498Szrj GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/,
383*38fd1498Szrj 			     gcov_unsigned_t /*length */);
384*38fd1498Szrj 
385*38fd1498Szrj #if !IN_GCOV
386*38fd1498Szrj /* Available outside gcov */
387*38fd1498Szrj GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t) ATTRIBUTE_HIDDEN;
388*38fd1498Szrj #endif
389*38fd1498Szrj 
390*38fd1498Szrj #if !IN_GCOV && !IN_LIBGCOV
391*38fd1498Szrj /* Available only in compiler */
392*38fd1498Szrj GCOV_LINKAGE unsigned gcov_histo_index (gcov_type value);
393*38fd1498Szrj GCOV_LINKAGE void gcov_write_string (const char *);
394*38fd1498Szrj GCOV_LINKAGE void gcov_write_filename (const char *);
395*38fd1498Szrj GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
396*38fd1498Szrj GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
397*38fd1498Szrj #endif
398*38fd1498Szrj 
399*38fd1498Szrj #if IN_GCOV <= 0 && !IN_LIBGCOV
400*38fd1498Szrj /* Available in gcov-dump and the compiler.  */
401*38fd1498Szrj 
402*38fd1498Szrj /* Number of data points in the working set summary array. Using 128
403*38fd1498Szrj    provides information for at least every 1% increment of the total
404*38fd1498Szrj    profile size. The last entry is hardwired to 99.9% of the total.  */
405*38fd1498Szrj #define NUM_GCOV_WORKING_SETS 128
406*38fd1498Szrj 
407*38fd1498Szrj /* Working set size statistics for a given percentage of the entire
408*38fd1498Szrj    profile (sum_all from the counter summary).  */
409*38fd1498Szrj typedef struct gcov_working_set_info
410*38fd1498Szrj {
411*38fd1498Szrj   /* Number of hot counters included in this working set.  */
412*38fd1498Szrj   unsigned num_counters;
413*38fd1498Szrj   /* Smallest counter included in this working set.  */
414*38fd1498Szrj   gcov_type min_counter;
415*38fd1498Szrj } gcov_working_set_t;
416*38fd1498Szrj 
417*38fd1498Szrj GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary,
418*38fd1498Szrj                                         gcov_working_set_t *gcov_working_sets);
419*38fd1498Szrj #endif
420*38fd1498Szrj 
421*38fd1498Szrj #if IN_GCOV > 0
422*38fd1498Szrj /* Available in gcov */
423*38fd1498Szrj GCOV_LINKAGE time_t gcov_time (void);
424*38fd1498Szrj #endif
425*38fd1498Szrj 
426*38fd1498Szrj #endif /* !inhibit_libc  */
427*38fd1498Szrj 
428*38fd1498Szrj #endif /* GCC_GCOV_IO_H */
429