GCC Middle and Back End API Reference
|
#include "gt-coverage.h"
Data Structures | |
struct | coverage_data |
struct | counts_entry |
Typedefs | |
typedef struct counts_entry | counts_entry_t |
Variables | |
static struct coverage_data * | functions_head = 0 |
static struct coverage_data ** | functions_tail = &functions_head |
static unsigned | no_coverage = 0 |
static unsigned | prg_ctr_mask |
static unsigned | fn_ctr_mask |
static tree | fn_v_ctrs [GCOV_COUNTERS] |
static unsigned | fn_n_ctrs [GCOV_COUNTERS] |
static unsigned | fn_b_ctrs [GCOV_COUNTERS] |
static tree | gcov_info_var |
static tree | gcov_fn_info_type |
static tree | gcov_fn_info_ptr_type |
static char * | bbg_file_name |
static unsigned | bbg_file_stamp |
static char * | da_file_name |
static const char *const | ctr_merge_functions [GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS |
static const char *const | ctr_names [GCOV_COUNTERS] = GCOV_COUNTER_NAMES |
static hash_table< counts_entry > | counts_hash |
typedef struct counts_entry counts_entry_t |
Counts information for a function.
|
static |
|
static |
Returns a CONSTRUCTOR for a gcov_fn_info. DATA is the coverage data for the function and TYPE is the gcov_fn_info RECORD_TYPE. KEY is the object file key.
key
ident
lineno_checksum
cfg_checksum
counters
|
static |
Creates the gcov_fn_info RECORD_TYPE.
ctr_info::num
ctr_info::values
key
ident
lineno_checksum
cfg checksum
counters
Referenced by coverage_obj_init().
|
static |
Returns a CONSTRUCTOR for the gcov_info object. INFO_TYPE is the gcov_info structure type, FN_ARY is the array of pointers to function info objects.
Version ident
next -- NULL
stamp
Filename
merge fn array -- NULL slots indicate unmeasured counters
Initialize assembler name so we can stream out.
n_functions
functions
|
static |
Create gcov_info struct. TYPE is the incomplete RECORD_TYPE to be completed, and FN_INFO_PTR_TYPE is a pointer to the function info type.
Version ident
next pointer
stamp
Filename
merge fn array
n_functions
function_info pointer pointer
|
static |
Generate the constructor function to call __gcov_init.
Build a decl for __gcov_init.
Generate a call to __gcov_init(&gcov_info).
Generate a constructor to run it.
|
static |
Build a coverage variable of TYPE for function FN_DECL. If COUNTER >= 0 it is a counter array, otherwise it is the function structure.
int coverage_begin_function | ( | ) |
Begin output to the notes file for the current function. Writes the function header. Returns nonzero if data should be output.
We don't need to output .gcno file unless we're under -ftest-coverage (e.g. -fprofile-arcs/generate/use don't need .gcno to work).
Announce function
References bbg_file_name, and warning().
|
static |
Generate a checksum for a string. CHKSUM is the current checksum.
Look for everything that looks if it were produced by get_file_function_name and zero out the second part that may result from flag_random_seed. This is not critical as the checksums are used only for sanity checking.
C++ namespaces do have scheme: _GLOBAL__N_<filename>_<wrongmagicnumber>_<magicnumber>functionname since filename might contain extra underscores there seems to be no better chance then walk all possible offsets looking for magicnumber.
unsigned coverage_compute_cfg_checksum | ( | void | ) |
Compute cfg checksum for the current function. The checksum is calculated carefully so that source code changes that doesn't affect the control flow graph won't change the checksum. This is to make the profile data useable across source code change. The downside of this is that the compiler may use potentially wrong profile data - that the source code change has non-trivial impact on the validity of profile data (e.g. the reversed condition) but the compiler won't detect the change and use the wrong profile data.
unsigned coverage_compute_lineno_checksum | ( | void | ) |
Compute checksum for the current function. We generate a CRC32.
unsigned coverage_compute_profile_id | ( | ) |
Compute profile ID. This is better to be unique in whole program.
Non-negative integers are hopefully small enough to fit in all targets.
References crc32_byte(), edge_def::dest, basic_block_def::index, and basic_block_def::succs.
int coverage_counter_alloc | ( | ) |
Allocate NUM counters of type COUNTER. Returns nonzero if the allocation succeeded.
References build_int_cst(), fn_b_ctrs, fn_n_ctrs, fn_v_ctrs, gcov_type_node, and get_gcov_type().
void coverage_end_function | ( | ) |
Finish coverage data for the current function. Verify no output error has occurred. Save function coverage counts.
If the function is extern (i.e. extern inline), then we won't be outputting it, so don't chain it onto the function list.
References build_array_type(), build_index_type(), fn_n_ctrs, get_gcov_type(), and varpool_finalize_decl().
void coverage_finish | ( | void | ) |
Performs file-level cleanup. Close notes file, generate coverage variables and constructor.
Only remove the da file, if we're emitting coverage code and cannot uniquely stamp it. If we can stamp it, libgcov will DTRT.
void coverage_init | ( | ) |
Perform file-level initialization. Read in data file, generate name of notes file.
Since coverage_init is invoked very early, before the pass manager, we need to set up the dumping explicitly. This is similar to the handling in finish_optimization_passes.
Name of da file.
Name of bbg file.
|
static |
|
static |
Finalize the coverage data. Generates the array of pointers to function objects from CTOR. Generate the gcov_info initializer.
|
static |
Generate the coverage function info for FN and DATA. Append a pointer to that object to CTOR and return the appended CTOR.
References bbg_file_name, bbg_file_stamp, error(), gcov_open(), gcov_write_unsigned(), memcpy(), and strlen().
|
static |
Create the gcov_info types and object. Generate the constructor function to call __gcov_init. Does not generate the initializer for the object. Returns TRUE if coverage data is being emitted.
Prune functions.
The function is not being emitted, remove from list.
Build the info and fn_info types. These are mutually recursive.
Build the gcov info var, this is referred to in its own initializer.
References build_array_type(), build_constructor(), build_index_type(), build_info(), build_qualified_type(), gcov_fn_info_ptr_type, gcov_info_var, get_identifier(), TYPE_QUAL_CONST, varpool_finalize_decl(), and vec_safe_length().
gcov_type* get_coverage_counts | ( | unsigned | counter, |
unsigned | expected, | ||
unsigned | cfg_checksum, | ||
unsigned | lineno_checksum, | ||
const struct gcov_ctr_summary ** | summary | ||
) |
Returns the counters for a particular tag.
No hash table, no counts.
The function was not emitted, or is weak and not chosen in the final executable. Silently fail, because there's nothing we can do about it.
tree get_gcov_type | ( | void | ) |
Return the type node for gcov_type.
Referenced by coverage_counter_alloc(), coverage_end_function(), and gimple_init_edge_profiler().
|
static |
Return the type node for gcov_unsigned_t.
|
static |
Forward declarations.
Read in the counts file, if available.
Read the stamp, used for creating a generation count.
References counts_hash, and error().
tree tree_coverage_counter_addr | ( | ) |
Generate a tree to access the address of COUNTER NO.
"no" here is an array index, scaled to bytes later.
References offset.
Referenced by gimple_gen_one_value_profiler(), and gimple_gen_pow2_profiler().
tree tree_coverage_counter_ref | ( | ) |
Generate a tree to access COUNTER NO.
"no" here is an array index, scaled to bytes later.
|
static |
Name of the notes (gcno) output file. The "bbg" prefix is for historical reasons, when the notes file contained only the basic block graph notes. If this is NULL we're not writing to the notes file.
Referenced by coverage_begin_function(), and coverage_obj_fn().
|
static |
File stamp for notes file.
Referenced by coverage_obj_fn().
|
static |
Hash table of count data.
Referenced by read_counts_file().
|
static |
The names of merge functions for counters.
|
static |
|
static |
Name of the count data (gcda) file.
|
static |
Referenced by coverage_counter_alloc().
|
static |
Counter information for current function.
|
static |
Referenced by coverage_counter_alloc(), and coverage_end_function().
|
static |
Referenced by coverage_counter_alloc().
|
static |
|
static |
|
static |
Referenced by coverage_obj_init().
|
static |
|
static |
Coverage info VAR_DECL and function info type nodes.
Referenced by coverage_obj_init().
|
static |
|
static |
Cumulative counter information for whole program.