diff options
Diffstat (limited to 'gcc-4.4.3/gcc/gcov-io.h')
-rw-r--r-- | gcc-4.4.3/gcc/gcov-io.h | 288 |
1 files changed, 265 insertions, 23 deletions
diff --git a/gcc-4.4.3/gcc/gcov-io.h b/gcc-4.4.3/gcc/gcov-io.h index ffee38e53..7584f4c4f 100644 --- a/gcc-4.4.3/gcc/gcov-io.h +++ b/gcc-4.4.3/gcc/gcov-io.h @@ -61,7 +61,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see file. It need not be an absolute time stamp, merely a ticker that increments fast enough and cycles slow enough to distinguish different compile/run/compile cycles. - + Although the ident and version are formally 32 bit numbers, they are derived from 4 character ASCII strings. The version number consists of the single character major version number, a two @@ -164,6 +164,89 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef GCC_GCOV_IO_H #define GCC_GCOV_IO_H +typedef double gcov_float_t; +#ifdef __KERNEL__ +#ifndef __GCOV_KERNEL__ +#define __GCOV_KERNEL__ +#endif /* __GCOV_KERNEL__ */ +#endif /* __KERNEL__ */ + +#ifdef __GCOV_KERNEL__ +#define GCOV_LINKAGE /* nothing */ + +/* We need the definitions for + BITS_PER_UNIT and + LONG_LONG_TYPE_SIZE + They are defined in gcc/defaults.h and gcc/config/<arch_depend_files> + (like, gcc/config/i386/i386.h). It's not easy to included them + cleanly. So I hardcoded the value for x86. */ +#define BITS_PER_UNIT 8 +#define LONG_LONG_TYPE_SIZE 64 + +/* There are many gcc_assertions. Set the vaule to 1 if we want a warning + message if the assertion fails. */ +#ifndef ENABLE_ASSERT_CHECKING +#define ENABLE_ASSERT_CHECKING 1 +#endif + +#include <linux/fs.h> +#endif /* __GCOV_KERNEL__ */ + +/* Wrappers to the file operations. */ +#ifndef __GCOV_KERNEL__ +# define _GCOV_FILE FILE +# define _GCOV_fclose fclose +# define _GCOV_ftell ftell +# define _GCOV_fseek fseek +# define _GCOV_ftruncate ftruncate +# define _GCOV_fread fread +# define _GCOV_fwrite fwrite +# define _GCOV_fread fread +# define _GCOV_fileno fileno +#else /* __GCOV_KERNEL__ */ +/* In Linux kernel mode, a virtual file is used for file operations. */ +struct gcov_info; +typedef struct { + long size; /* size of buf */ + long count; /* element written into buf */ + struct gcov_info *info; + char buf[0]; +} gcov_kernel_vfile; + +# define _GCOV_FILE gcov_kernel_vfile + +/* gcc_assert() prints out a warning if the check fails. It + will not abort. */ +#if ENABLE_ASSERT_CHECKING +# define gcc_assert(EXPR) \ + ((void)(!(EXPR) ? printk (KERN_WARNING \ + "GCOV assertion fails: func=%s line=%d\n", \ + __FUNCTION__, __LINE__), 0 : 0)) +#else +# define gcc_assert(EXPR) ((void)(0 && (EXPR))) +#endif + +/* Wrappers to the file operations. */ +# define _GCOV_fclose kernel_file_fclose +# define _GCOV_ftell kernel_file_ftell +# define _GCOV_fseek kernel_file_fseek +# define _GCOV_ftruncate kernel_file_ftruncate +# define _GCOV_fread kernel_file_fread +# define _GCOV_fwrite kernel_file_fwrite +# define _GCOV_fileno kernel_file_fileno + +/* Declarations for virtual files operations. */ +extern int kernel_file_fclose (gcov_kernel_vfile *); +extern long kernel_file_ftell (gcov_kernel_vfile *); +extern int kernel_file_fseek (gcov_kernel_vfile *, long, int); +extern int kernel_file_ftruncate (gcov_kernel_vfile *, off_t); +extern int kernel_file_fread (void *, size_t, size_t, + gcov_kernel_vfile *); +extern int kernel_file_fwrite (const void *, size_t, size_t, + gcov_kernel_vfile *); +extern int kernel_file_fileno(gcov_kernel_vfile *); +#endif /* GCOV_KERNEL */ + #if IN_LIBGCOV #undef FUNC_ID_WIDTH @@ -207,7 +290,7 @@ typedef signed gcov_type __attribute__ ((mode (QI))); #define FUNC_ID_WIDTH 16 #define FUNC_ID_MASK ((1 << FUNC_ID_WIDTH) - 1) #endif -#endif /* BITS_PER_UNIT == 16 */ +#endif /* BITS_PER_UNIT == 16 */ #endif /* BITS_PER_UNIT == 8 */ @@ -265,7 +348,9 @@ typedef HOST_WIDEST_INT gcov_type; is not also used in a DSO. */ #if IN_LIBGCOV +#ifndef __GCOV_KERNEL__ #include "tconfig.h" +#endif /* __GCOV_KERNEL__ */ #define gcov_var __gcov_var #define gcov_open __gcov_open @@ -288,6 +373,11 @@ typedef HOST_WIDEST_INT gcov_type; #define gcov_read_summary __gcov_read_summary #define gcov_read_module_info __gcov_read_module_info #define gcov_sort_n_vals __gcov_sort_n_vals +#define gcov_read_pmu_load_latency_info __gcov_read_pmu_load_latency_info +#define gcov_read_pmu_branch_mispredict_info __gcov_read_pmu_branch_mispredict_info +#define gcov_read_pmu_tool_header __gcov_read_pmu_tool_header +#define destroy_pmu_tool_header __destroy_pmu_tool_header + /* Poison these, so they don't accidentally slip in. */ #pragma GCC poison gcov_write_tag gcov_write_length @@ -352,6 +442,13 @@ typedef HOST_WIDEST_INT gcov_type; #define GCOV_TAG_SUMMARY_LENGTH \ (1 + GCOV_COUNTERS_SUMMABLE * (2 + 3 * 2)) #define GCOV_TAG_MODULE_INFO ((gcov_unsigned_t)0xa4000000) +#define GCOV_TAG_PMU_LOAD_LATENCY_INFO ((gcov_unsigned_t)0xa5000000) +#define GCOV_TAG_PMU_LOAD_LATENCY_LENGTH(filename) \ + (gcov_string_length (filename) + 12 + 2) +#define GCOV_TAG_PMU_BRANCH_MISPREDICT_INFO ((gcov_unsigned_t)0xa7000000) +#define GCOV_TAG_PMU_BRANCH_MISPREDICT_LENGTH(filename) \ + (gcov_string_length (filename) + 5 + 2) +#define GCOV_TAG_PMU_TOOL_HEADER ((gcov_unsigned_t)0xa9000000) /* Counters that are collected. */ #define GCOV_COUNTER_ARCS 0 /* Arc transitions. */ @@ -366,29 +463,32 @@ typedef HOST_WIDEST_INT gcov_type; #define GCOV_COUNTER_V_POW2 2 /* Histogram of exact power2 logarithm of a value. */ #define GCOV_COUNTER_V_SINGLE 3 /* The most common value of expression. */ -#define GCOV_COUNTER_V_DELTA 4 /* The most common difference between +#define GCOV_COUNTER_V_SINGLE_FLOAT 4 /* The most common float value */ +#define GCOV_COUNTER_V_DELTA 5 /* The most common difference between consecutive values of expression. */ -#define GCOV_COUNTER_V_INDIR 5 /* The most common indirect address */ -#define GCOV_COUNTER_AVERAGE 6 /* Compute average value passed to the +#define GCOV_COUNTER_V_INDIR 6 /* The most common indirect address */ +#define GCOV_COUNTER_AVERAGE 7 /* Compute average value passed to the counter. */ -#define GCOV_COUNTER_IOR 7 /* IOR of the all values passed to +#define GCOV_COUNTER_IOR 8 /* IOR of the all values passed to counter. */ -#define GCOV_COUNTER_ICALL_TOPNV 8 /* Top N value tracking for indirect calls */ -#define GCOV_LAST_VALUE_COUNTER 8 /* The last of counters used for value +#define GCOV_COUNTER_ICALL_TOPNV 9 /* Top N value tracking for indirect calls */ +#define GCOV_LAST_VALUE_COUNTER 9 /* The last of counters used for value profiling. */ -#define GCOV_COUNTER_DIRECT_CALL 9 /* Direct call counts. */ -#define GCOV_COUNTERS 10 +#define GCOV_COUNTER_DIRECT_CALL 10 /* Direct call counts. */ +#define GCOV_COUNTER_REUSE_DIST 11 /* Reuse distance measure. */ +#define GCOV_COUNTERS 12 /* Number of counters used for value profiling. */ #define GCOV_N_VALUE_COUNTERS \ (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1) - + /* A list of human readable names of the counters */ #define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", \ - "delta","indirect_call", "average", "ior", \ - "indirect_call_topn", "direct_call"} - + "single_float", "delta","indirect_call", \ + "average", "ior", "indirect_call_topn", \ + "direct_call", "reuse_distance"} + #define GCOV_ICALL_TOPN_VAL 2 /* Track two hottest callees */ #define GCOV_ICALL_TOPN_NCOUNTS 9 /* The number of counter entries per icall callsite */ /* Names of merge functions for counters. */ @@ -396,13 +496,15 @@ typedef HOST_WIDEST_INT gcov_type; "__gcov_merge_add", \ "__gcov_merge_add", \ "__gcov_merge_single", \ + "__gcov_merge_single_float", \ "__gcov_merge_delta", \ "__gcov_merge_single", \ "__gcov_merge_add", \ "__gcov_merge_ior", \ "__gcov_merge_icall_topn",\ - "__gcov_merge_dc" } - + "__gcov_merge_dc", \ + "__gcov_merge_reusedist"} + /* Convert a counter index to a tag. */ #define GCOV_TAG_FOR_COUNTER(COUNT) \ (GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17)) @@ -493,6 +595,91 @@ extern unsigned primary_module_id; && !((module_infos[0]->lang & GCOV_MODULE_ASM_STMTS) \ && flag_ripa_disallow_asm_modules)) +/* Information about the hardware performance monitoring unit. */ +struct gcov_pmu_info +{ + const char *pmu_profile_filename; /* pmu profile filename */ + const char *pmu_tool; /* canonical pmu tool options */ + gcov_unsigned_t pmu_top_n_address; /* how many top addresses to symbolize */ +}; + +/* Information about the PMU tool header. */ +typedef struct gcov_pmu_tool_header { + char *host_cpu; + char *hostname; + char *kernel_version; + char *column_header; + char *column_description; + char *full_header; +} gcov_pmu_tool_header_t; + +/* Available only for PMUs which support PEBS or IBS using pfmon + tool. If any field here is changed, the length computation in + GCOV_TAG_PMU_LOAD_LATENCY_LENGTH must be updated as well. All + percentages are multiplied by 100 to make them out of 10000 and + only integer part is kept. */ +typedef struct gcov_pmu_load_latency_info +{ + gcov_unsigned_t counts; /* raw count of samples */ + gcov_unsigned_t self; /* per 10k of total samples */ + gcov_unsigned_t cum; /* per 10k cumulative weight */ + gcov_unsigned_t lt_10; /* per 10k with latency <= 10 cycles */ + gcov_unsigned_t lt_32; /* per 10k with latency <= 32 cycles */ + gcov_unsigned_t lt_64; /* per 10k with latency <= 64 cycles */ + gcov_unsigned_t lt_256; /* per 10k with latency <= 256 cycles */ + gcov_unsigned_t lt_1024; /* per 10k with latency <= 1024 cycles */ + gcov_unsigned_t gt_1024; /* per 10k with latency > 1024 cycles */ + gcov_unsigned_t wself; /* weighted average cost of this miss in cycles */ + gcov_type code_addr; /* the actual miss address (pc+1 for Intel) */ + gcov_unsigned_t line; /* line number corresponding to this miss */ + gcov_unsigned_t discriminator; /* discriminator information for this miss */ + char *filename; /* filename corresponding to this miss */ +} gcov_pmu_ll_info_t; + +/* This structure is used during runtime as well as in gcov. */ +typedef struct load_latency_infos +{ + /* An array describing the total number of load latency fields. */ + gcov_pmu_ll_info_t **ll_array; + /* The total number of entries in the load latency array. */ + unsigned ll_count; + /* The total number of entries currently allocated in the array. + Used for bookkeeping. */ + unsigned alloc_ll_count; + /* PMU tool header */ + gcov_pmu_tool_header_t *pmu_tool_header; +} ll_infos_t; + +/* Available only for PMUs which support PEBS or IBS using pfmon + tool. If any field here is changed, the length computation in + GCOV_TAG_PMU_BR_MISPREDICT_LENGTH must be updated as well. All + percentages are multiplied by 100 to make them out of 10000 and + only integer part is kept. */ +typedef struct gcov_pmu_branch_mispredict_info +{ + gcov_unsigned_t counts; /* raw count of samples */ + gcov_unsigned_t self; /* per 10k of total samples */ + gcov_unsigned_t cum; /* per 10k cumulative weight */ + gcov_type code_addr; /* the actual mispredict address */ + gcov_unsigned_t line; /* line number corresponding to this event */ + gcov_unsigned_t discriminator; /* discriminator for this event */ + char *filename; /* filename corresponding to this event */ +} gcov_pmu_brm_info_t; + +/* This structure is used during runtime as well as in gcov. */ +typedef struct branch_mispredict_infos +{ + /* An array describing the total number of mispredict entries. */ + gcov_pmu_brm_info_t **brm_array; + /* The total number of entries in the above array. */ + unsigned brm_count; + /* The total number of entries currently allocated in the array. + Used for bookkeeping. */ + unsigned alloc_brm_count; + /* PMU tool header */ + gcov_pmu_tool_header_t *pmu_tool_header; +} brm_infos_t; + /* Structures embedded in coveraged program. The structures generated by write_profile must match these. */ @@ -500,7 +687,7 @@ extern unsigned primary_module_id; /* Information about a single function. This uses the trailing array idiom. The number of counters is determined from the counter_mask in gcov_info. We hold an array of function info, so have to - explicitly calculate the correct array stride. + explicitly calculate the correct array stride. "ident" is no longer used in hash computation. Additionally, "name" is used in hash computation. This makes the profile data @@ -549,6 +736,13 @@ struct gcov_info is. */ }; +/* Information about a single imported module. */ +struct dyn_imp_mod +{ + const struct gcov_info *imp_mod; + double weight; +}; + /* Register a new object file module. */ extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN; @@ -561,6 +755,9 @@ extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; /* The merge function to choose the most common value. */ extern void __gcov_merge_single (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; +/* The merge function to choose the most common value. */ +extern void __gcov_merge_single_float (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; + /* The merge function to choose the most common difference between consecutive values. */ extern void __gcov_merge_delta (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; @@ -571,13 +768,17 @@ extern void __gcov_merge_ior (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; /* The merge function used for direct call counters. */ extern void __gcov_merge_dc (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; +/* The merge function used for reuse distance counters. */ +extern void __gcov_merge_reusedist (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; + /* The merge function used for indirect call counters. */ extern void __gcov_merge_icall_topn (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; /* The profiler functions. */ -extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned); +extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned); extern void __gcov_pow2_profiler (gcov_type *, gcov_type); extern void __gcov_one_value_profiler (gcov_type *, gcov_type); +extern void __gcov_one_float_value_profiler (gcov_type *, gcov_float_t); extern void __gcov_indirect_call_profiler (gcov_type *, gcov_type, void *, void *); extern void __gcov_indirect_call_topn_profiler (void *, void *, gcov_unsigned_t) ATTRIBUTE_HIDDEN; extern void __gcov_direct_call_profiler (void *, void *, gcov_unsigned_t) ATTRIBUTE_HIDDEN; @@ -585,6 +786,12 @@ extern void __gcov_average_profiler (gcov_type *, gcov_type); extern void __gcov_ior_profiler (gcov_type *, gcov_type); extern void __gcov_sort_n_vals (gcov_type *value_array, int n); +/* Initialize/start/stop/dump performance monitoring unit (PMU) profile */ +void __gcov_init_pmu_profiler (struct gcov_pmu_info *) ATTRIBUTE_HIDDEN; +void __gcov_start_pmu_profiler (void) ATTRIBUTE_HIDDEN; +void __gcov_stop_pmu_profiler (void) ATTRIBUTE_HIDDEN; +void __gcov_end_pmu_profiler (void) ATTRIBUTE_HIDDEN; + #ifndef inhibit_libc /* The wrappers around some library functions.. */ extern pid_t __gcov_fork (void) ATTRIBUTE_HIDDEN; @@ -604,9 +811,9 @@ extern int __gcov_execve (const char *, char *const [], char *const []) /* Optimum number of gcov_unsigned_t's read from or written to disk. */ #define GCOV_BLOCK_SIZE (1 << 10) -GCOV_LINKAGE struct gcov_var +struct gcov_var { - FILE *file; + _GCOV_FILE *file; gcov_position_t start; /* Position of first byte of block */ unsigned offset; /* Read/write position within the block. */ unsigned length; /* Read limit in the block. */ @@ -626,7 +833,15 @@ GCOV_LINKAGE struct gcov_var size_t alloc; gcov_unsigned_t *buffer; #endif -} gcov_var ATTRIBUTE_HIDDEN; +}; + +/* In kernel mode, move gcov_var definition to gcov-io.c + to avoid dulipcate definitions. */ +#ifndef __GCOV_KERNEL__ +GCOV_LINKAGE struct gcov_var gcov_var ATTRIBUTE_HIDDEN; +#else +extern struct gcov_var gcov_var; +#endif /* Functions for reading and writing gcov files. In libgcov you can open the file for reading then writing. Elsewhere you can open the @@ -652,11 +867,33 @@ static int gcov_is_error (void); GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void) ATTRIBUTE_HIDDEN; GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE void gcov_read_pmu_load_latency_info ( + gcov_pmu_ll_info_t *ll_info, gcov_unsigned_t len) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE void gcov_read_pmu_branch_mispredict_info ( + gcov_pmu_brm_info_t *brm_info, gcov_unsigned_t len) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE void gcov_read_pmu_tool_header ( + gcov_pmu_tool_header_t *tool_header, gcov_unsigned_t len) ATTRIBUTE_HIDDEN; + #if !IN_LIBGCOV && IN_GCOV != 1 GCOV_LINKAGE void gcov_read_module_info (struct gcov_module_info *mod_info, gcov_unsigned_t len) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE void print_load_latency_line (FILE *fp, + const gcov_pmu_ll_info_t *ll_info, + const int print_newline); +GCOV_LINKAGE void print_branch_mispredict_line ( + FILE *fp, const gcov_pmu_brm_info_t *brm_info, const int print_newline); +GCOV_LINKAGE void print_pmu_tool_header (FILE *fp, + gcov_pmu_tool_header_t *tool_header, + const int print_newline); #endif + +#if IN_GCOV != 1 +GCOV_LINKAGE void destroy_pmu_tool_header (gcov_pmu_tool_header_t *tool_header) + ATTRIBUTE_HIDDEN; +#endif + GCOV_LINKAGE const char *gcov_read_string (void) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE float convert_unsigned_to_pct (const unsigned number); #if IN_LIBGCOV /* Available only in libgcov */ @@ -669,13 +906,14 @@ GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/, GCOV_LINKAGE void gcov_write_module_infos (struct gcov_info *mod_info) ATTRIBUTE_HIDDEN; -GCOV_LINKAGE const struct gcov_info ** +GCOV_LINKAGE const struct dyn_imp_mod ** gcov_get_sorted_import_module_array (struct gcov_info *mod_info, unsigned *len) ATTRIBUTE_HIDDEN; static void gcov_rewrite (void); GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_truncate (void) ATTRIBUTE_HIDDEN; GCOV_LINKAGE gcov_unsigned_t gcov_string_length (const char *) ATTRIBUTE_HIDDEN; +GCOV_LINKAGE unsigned gcov_gcda_file_size (struct gcov_info *); #else /* Available outside libgcov */ GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/, @@ -725,10 +963,14 @@ gcov_rewrite (void) gcov_var.mode = -1; gcov_var.start = 0; gcov_var.offset = 0; - fseek (gcov_var.file, 0L, SEEK_SET); + _GCOV_fseek (gcov_var.file, 0L, SEEK_SET); } #endif #endif /* IN_LIBGCOV >= 0 */ +/* Convert between gcov_type and gcov_float_t. */ +gcov_type gcov_float_to_type(gcov_float_t f); +gcov_float_t gcov_type_to_float(gcov_type t); + #endif /* GCC_GCOV_IO_H */ |