comparison gcc/gcov-io.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* File format for coverage information 1 /* File format for coverage information
2 Copyright (C) 1996-2017 Free Software Foundation, Inc. 2 Copyright (C) 1996-2018 Free Software Foundation, Inc.
3 Contributed by Bob Manson <manson@cygnus.com>. 3 Contributed by Bob Manson <manson@cygnus.com>.
4 Completely remangled by Nathan Sidwell <nathan@codesourcery.com>. 4 Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
46 int64: int32:low int32:high 46 int64: int32:low int32:high
47 string: int32:0 | int32:length char* char:0 padding 47 string: int32:0 | int32:length char* char:0 padding
48 padding: | char:0 | char:0 char:0 | char:0 char:0 char:0 48 padding: | char:0 | char:0 char:0 | char:0 char:0 char:0
49 item: int32 | int64 | string 49 item: int32 | int64 | string
50 50
51 The basic format of the files is 51 The basic format of the notes file is
52
53 file : int32:magic int32:version int32:stamp int32:support_unexecuted_blocks record*
54
55 The basic format of the data file is
52 56
53 file : int32:magic int32:version int32:stamp record* 57 file : int32:magic int32:version int32:stamp record*
54 58
55 The magic ident is different for the notes and the data files. The 59 The magic ident is different for the notes and the data files. The
56 magic ident is used to determine the endianness of the file, when 60 magic ident is used to determine the endianness of the file, when
102 note: unit function-graph* 106 note: unit function-graph*
103 unit: header int32:checksum string:source 107 unit: header int32:checksum string:source
104 function-graph: announce_function basic_blocks {arcs | lines}* 108 function-graph: announce_function basic_blocks {arcs | lines}*
105 announce_function: header int32:ident 109 announce_function: header int32:ident
106 int32:lineno_checksum int32:cfg_checksum 110 int32:lineno_checksum int32:cfg_checksum
107 string:name string:source int32:lineno 111 string:name string:source int32:start_lineno int32:start_column int32:end_lineno
108 basic_block: header int32:flags* 112 basic_block: header int32:flags*
109 arcs: header int32:block_no arc* 113 arcs: header int32:block_no arc*
110 arc: int32:dest_block int32:flags 114 arc: int32:dest_block int32:flags
111 lines: header int32:block_no line* 115 lines: header int32:block_no line*
112 int32:0 string:NULL 116 int32:0 string:NULL
127 interleaved in any manner. The current filename follows the order 131 interleaved in any manner. The current filename follows the order
128 the LINES records are stored in the file, *not* the ordering of the 132 the LINES records are stored in the file, *not* the ordering of the
129 blocks they are for. 133 blocks they are for.
130 134
131 The data file contains the following records. 135 The data file contains the following records.
132 data: {unit summary:object summary:program* function-data*}* 136 data: {unit summary:object function-data*}*
133 unit: header int32:checksum 137 unit: header int32:checksum
134 function-data: announce_function present counts 138 function-data: announce_function present counts
135 announce_function: header int32:ident 139 announce_function: header int32:ident
136 int32:lineno_checksum int32:cfg_checksum 140 int32:lineno_checksum int32:cfg_checksum
137 present: header int32:present 141 present: header int32:present
138 counts: header int64:count* 142 counts: header int64:count*
139 summary: int32:checksum {count-summary}GCOV_COUNTERS_SUMMABLE 143 summary: int32:checksum int32:runs int32:sum_max
140 count-summary: int32:num int32:runs int64:sum
141 int64:max int64:sum_max histogram
142 histogram: {int32:bitvector}8 histogram-buckets*
143 histogram-buckets: int32:num int64:min int64:sum
144 144
145 The ANNOUNCE_FUNCTION record is the same as that in the note file, 145 The ANNOUNCE_FUNCTION record is the same as that in the note file,
146 but without the source location. The COUNTS gives the 146 but without the source location. The COUNTS gives the
147 counter values for instrumented features. The about the whole 147 counter values for instrumented features. The about the whole
148 program. The checksum is used for whole program summaries, and 148 program. The checksum is used for whole program summaries, and
185 #define GCOV_LOCKED 0 185 #define GCOV_LOCKED 0
186 #endif 186 #endif
187 187
188 #define ATTRIBUTE_HIDDEN 188 #define ATTRIBUTE_HIDDEN
189 189
190 #endif /* !IN_LIBGOCV */ 190 #endif /* !IN_LIBGCOV */
191 191
192 #ifndef GCOV_LINKAGE 192 #ifndef GCOV_LINKAGE
193 #define GCOV_LINKAGE extern 193 #define GCOV_LINKAGE extern
194 #endif 194 #endif
195 195
235 #define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2) 235 #define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2)
236 #define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000) 236 #define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000)
237 #define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000) 237 #define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000)
238 #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2) 238 #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
239 #define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2) 239 #define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
240 #define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000) /* Obsolete */ 240 #define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000)
241 #define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000) 241 #define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000) /* Obsolete */
242 #define GCOV_TAG_SUMMARY_LENGTH(NUM) \ 242 #define GCOV_TAG_SUMMARY_LENGTH (2)
243 (1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
244 #define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000) 243 #define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
245 #define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000) 244 #define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
246 #define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000) 245 #define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
247 246
248 247
253 #include "gcov-counter.def" 252 #include "gcov-counter.def"
254 GCOV_COUNTERS 253 GCOV_COUNTERS
255 }; 254 };
256 #undef DEF_GCOV_COUNTER 255 #undef DEF_GCOV_COUNTER
257 256
258 /* Counters which can be summaried. */
259 #define GCOV_COUNTERS_SUMMABLE (GCOV_COUNTER_ARCS + 1)
260
261 /* The first of counters used for value profiling. They must form a 257 /* The first of counters used for value profiling. They must form a
262 consecutive interval and their order must match the order of 258 consecutive interval and their order must match the order of
263 HIST_TYPEs in value-prof.h. */ 259 HIST_TYPEs in value-prof.h. */
264 #define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTERS_SUMMABLE 260 #define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTER_V_INTERVAL
265 261
266 /* The last of counters used for value profiling. */ 262 /* The last of counters used for value profiling. */
267 #define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1) 263 #define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1)
268 264
269 /* Number of counters used for value profiling. */ 265 /* Number of counters used for value profiling. */
306 /* Arc flags. */ 302 /* Arc flags. */
307 #define GCOV_ARC_ON_TREE (1 << 0) 303 #define GCOV_ARC_ON_TREE (1 << 0)
308 #define GCOV_ARC_FAKE (1 << 1) 304 #define GCOV_ARC_FAKE (1 << 1)
309 #define GCOV_ARC_FALLTHROUGH (1 << 2) 305 #define GCOV_ARC_FALLTHROUGH (1 << 2)
310 306
311 /* Structured records. */
312
313 /* Structure used for each bucket of the log2 histogram of counter values. */
314 typedef struct
315 {
316 /* Number of counters whose profile count falls within the bucket. */
317 gcov_unsigned_t num_counters;
318 /* Smallest profile count included in this bucket. */
319 gcov_type min_value;
320 /* Cumulative value of the profile counts in this bucket. */
321 gcov_type cum_value;
322 } gcov_bucket_type;
323
324 /* For a log2 scale histogram with each range split into 4
325 linear sub-ranges, there will be at most 64 (max gcov_type bit size) - 1 log2
326 ranges since the lowest 2 log2 values share the lowest 4 linear
327 sub-range (values 0 - 3). This is 252 total entries (63*4). */
328
329 #define GCOV_HISTOGRAM_SIZE 252
330
331 /* How many unsigned ints are required to hold a bit vector of non-zero
332 histogram entries when the histogram is written to the gcov file.
333 This is essentially a ceiling divide by 32 bits. */
334 #define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
335
336 /* Cumulative counter data. */
337 struct gcov_ctr_summary
338 {
339 gcov_unsigned_t num; /* number of counters. */
340 gcov_unsigned_t runs; /* number of program runs */
341 gcov_type sum_all; /* sum of all counters accumulated. */
342 gcov_type run_max; /* maximum value on a single run. */
343 gcov_type sum_max; /* sum of individual run max values. */
344 gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* histogram of
345 counter values. */
346 };
347
348 /* Object & program summary record. */ 307 /* Object & program summary record. */
308
349 struct gcov_summary 309 struct gcov_summary
350 { 310 {
351 gcov_unsigned_t checksum; /* checksum of program */ 311 gcov_unsigned_t runs; /* Number of program runs. */
352 struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE]; 312 gcov_type sum_max; /* Sum of individual run max values. */
353 }; 313 };
354 314
355 #if !defined(inhibit_libc) 315 #if !defined(inhibit_libc)
356 316
357 /* Functions for reading and writing gcov files. In libgcov you can 317 /* Functions for reading and writing gcov files. In libgcov you can
375 GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN; 335 GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN;
376 GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN; 336 GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN;
377 GCOV_LINKAGE const char *gcov_read_string (void); 337 GCOV_LINKAGE const char *gcov_read_string (void);
378 GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/, 338 GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/,
379 gcov_unsigned_t /*length */); 339 gcov_unsigned_t /*length */);
340 char *mangle_path (char const *base);
380 341
381 #if !IN_GCOV 342 #if !IN_GCOV
382 /* Available outside gcov */ 343 /* Available outside gcov */
383 GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t) ATTRIBUTE_HIDDEN; 344 GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t) ATTRIBUTE_HIDDEN;
384 #endif 345 #endif
385 346
386 #if !IN_GCOV && !IN_LIBGCOV 347 #if !IN_GCOV && !IN_LIBGCOV
387 /* Available only in compiler */ 348 /* Available only in compiler */
388 GCOV_LINKAGE unsigned gcov_histo_index (gcov_type value);
389 GCOV_LINKAGE void gcov_write_string (const char *); 349 GCOV_LINKAGE void gcov_write_string (const char *);
390 GCOV_LINKAGE void gcov_write_filename (const char *); 350 GCOV_LINKAGE void gcov_write_filename (const char *);
391 GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t); 351 GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
392 GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/); 352 GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
393 #endif 353 #endif
394 354
395 #if IN_GCOV <= 0 && !IN_LIBGCOV
396 /* Available in gcov-dump and the compiler. */
397
398 /* Number of data points in the working set summary array. Using 128
399 provides information for at least every 1% increment of the total
400 profile size. The last entry is hardwired to 99.9% of the total. */
401 #define NUM_GCOV_WORKING_SETS 128
402
403 /* Working set size statistics for a given percentage of the entire
404 profile (sum_all from the counter summary). */
405 typedef struct gcov_working_set_info
406 {
407 /* Number of hot counters included in this working set. */
408 unsigned num_counters;
409 /* Smallest counter included in this working set. */
410 gcov_type min_counter;
411 } gcov_working_set_t;
412
413 GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary,
414 gcov_working_set_t *gcov_working_sets);
415 #endif
416
417 #if IN_GCOV > 0 355 #if IN_GCOV > 0
418 /* Available in gcov */ 356 /* Available in gcov */
419 GCOV_LINKAGE time_t gcov_time (void); 357 GCOV_LINKAGE time_t gcov_time (void);
420 #endif 358 #endif
421 359