GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "output.h"
#include "regs.h"
#include "expr.h"
#include "function.h"
#include "basic-block.h"
#include "toplev.h"
#include "tm_p.h"
#include "ggc.h"
#include "coverage.h"
#include "langhooks.h"
#include "hash-table.h"
#include "tree-iterator.h"
#include "context.h"
#include "pass_manager.h"
#include "tree-pass.h"
#include "cgraph.h"
#include "dumpfile.h"
#include "diagnostic-core.h"
#include "intl.h"
#include "filenames.h"
#include "target.h"
#include "gcov-io.h"
#include "gcov-io.c"
#include "gt-coverage.h"
Data Structures | |
struct | coverage_data |
struct | counts_entry |
Macros | |
#define | GCOV_LINKAGE |
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 |
#define GCOV_LINKAGE |
Read and write coverage files, and associated functionality. Copyright (C) 1990-2013 Free Software Foundation, Inc. Contributed by James E. Wilson, UC Berkeley/Cygnus Support; based on some ideas from Dain Samples of UC Berkeley. Further mangling by Bob Manson, Cygnus Support. Further mangled by Nathan Sidwell, CodeSourcery
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
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, NULL, 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, FOR_EACH_BB, FOR_EACH_EDGE, basic_block_def::index, n_basic_blocks, and basic_block_def::succs.
int coverage_counter_alloc | ( | ) |
Allocate NUM counters of type COUNTER. Returns nonzero if the allocation succeeded.
References build4, build_int_cst(), fn_b_ctrs, fn_n_ctrs, fn_v_ctrs, gcc_assert, gcov_type_node, get_gcov_type(), integer_type_node, and NULL.
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(), DECL_SIZE, DECL_SIZE_UNIT, fn_n_ctrs, get_gcov_type(), size_int, TREE_TYPE, TYPE_SIZE, TYPE_SIZE_UNIT, 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_NOTE_MAGIC, GCOV_NOTE_SUFFIX, gcov_open(), gcov_write_unsigned(), and NULL.
|
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_decl, build_index_type(), build_info(), build_qualified_type(), BUILTINS_LOCATION, DECL_INITIAL, DECL_NAME, gcov_fn_info_ptr_type, gcov_info_var, get_identifier(), NULL_TREE, size_int, TREE_STATIC, TREE_TYPE, 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.