Stefan Reinauer | d37ab45 | 2012-12-18 16:23:28 -0800 | [diff] [blame] | 1 | This patch contains our local modifications for gcov-io.h and libgcov.c. |
| 2 | The file gcov-iov.h is taken from a gcc build (produced at compile |
| 3 | time). The file gcov-io.c is unchanged. |
| 4 | |
| 5 | --- gcc-4.7.2/gcc/gcov-io.h 2011-12-04 10:27:19.000000000 -0800 |
Stefan Reinauer | f572e1e | 2013-01-16 09:47:54 -0800 | [diff] [blame] | 6 | +++ coreboot/src/lib/gcov-io.h 2013-01-12 16:45:57.000000000 -0800 |
Stefan Reinauer | d37ab45 | 2012-12-18 16:23:28 -0800 | [diff] [blame] | 7 | @@ -163,6 +163,24 @@ |
| 8 | #ifndef GCC_GCOV_IO_H |
| 9 | #define GCC_GCOV_IO_H |
| 10 | |
| 11 | +#ifdef __COREBOOT__ |
| 12 | +#define GCOV_LINKAGE /* nothing */ |
| 13 | +/* We need the definitions for |
| 14 | + BITS_PER_UNIT and |
| 15 | + LONG_LONG_TYPE_SIZE |
| 16 | + They are defined in gcc/defaults.h and gcc/config/<arch_depend_files> |
| 17 | + (like, gcc/config/i386/i386.h). And it can be overridden by setting |
| 18 | + in build scripts. Here I hardcoded the value for x86. */ |
| 19 | +#define BITS_PER_UNIT 8 |
| 20 | +#define LONG_LONG_TYPE_SIZE 64 |
| 21 | + |
| 22 | +/* There are many gcc_assertions. Set the vaule to 1 if we want a warning |
| 23 | + message if the assertion fails. */ |
| 24 | +#ifndef ENABLE_ASSERT_CHECKING |
| 25 | +#define ENABLE_ASSERT_CHECKING 1 |
| 26 | +#endif |
| 27 | +#endif /* __COREBOOT__ */ |
| 28 | + |
| 29 | #if IN_LIBGCOV |
| 30 | /* About the target */ |
| 31 | |
| 32 | @@ -232,7 +250,9 @@ |
| 33 | is not also used in a DSO. */ |
| 34 | #if IN_LIBGCOV |
| 35 | |
| 36 | +#ifndef __COREBOOT__ |
| 37 | #include "tconfig.h" |
| 38 | +#endif /* __COREBOOT__ */ |
| 39 | |
| 40 | #define gcov_var __gcov_var |
| 41 | #define gcov_open __gcov_open |
| 42 | @@ -455,8 +475,10 @@ |
| 43 | /* Register a new object file module. */ |
| 44 | extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN; |
| 45 | |
| 46 | +#ifndef __COREBOOT__ |
| 47 | /* Called before fork, to avoid double counting. */ |
| 48 | extern void __gcov_flush (void) ATTRIBUTE_HIDDEN; |
| 49 | +#endif |
| 50 | |
| 51 | /* The merge function that just sums the counters. */ |
| 52 | extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; |
| 53 | --- gcc-4.7.2/libgcc/libgcov.c 2012-01-11 10:50:21.000000000 -0800 |
Stefan Reinauer | f572e1e | 2013-01-16 09:47:54 -0800 | [diff] [blame] | 54 | +++ coreboot/src/lib/libgcov.c 2013-01-16 09:45:11.000000000 -0800 |
Stefan Reinauer | d37ab45 | 2012-12-18 16:23:28 -0800 | [diff] [blame] | 55 | @@ -25,12 +25,41 @@ |
| 56 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 57 | <http://www.gnu.org/licenses/>. */ |
| 58 | |
| 59 | +#define __COREBOOT__ |
| 60 | +#ifdef __COREBOOT__ |
| 61 | +#include <stdlib.h> |
| 62 | +#include <string.h> |
| 63 | +#include <console/console.h> |
| 64 | +#include <assert.h> |
| 65 | +typedef s32 pid_t; |
| 66 | +#define gcc_assert(x) ASSERT(x) |
| 67 | +#define fprintf(file, x...) printk(BIOS_ERR, x) |
| 68 | +#define alloca(size) __builtin_alloca (size) |
| 69 | +#include "gcov-glue.c" |
| 70 | + |
| 71 | +/* Define MACROs to be used by coreboot compilation. */ |
| 72 | +# define L_gcov |
| 73 | +# define L_gcov_interval_profiler |
| 74 | +# define L_gcov_pow2_profiler |
| 75 | +# define L_gcov_one_value_profiler |
| 76 | +# define L_gcov_indirect_call_profiler |
| 77 | +# define L_gcov_average_profiler |
| 78 | +# define L_gcov_ior_profiler |
| 79 | + |
| 80 | +# define HAVE_CC_TLS 0 |
| 81 | +# define __GCOV_KERNEL__ |
| 82 | + |
| 83 | +# define IN_LIBGCOV 1 |
| 84 | +# define IN_GCOV 0 |
| 85 | +#else /* __COREBOOT__ */ |
| 86 | #include "tconfig.h" |
| 87 | #include "tsystem.h" |
| 88 | #include "coretypes.h" |
| 89 | #include "tm.h" |
| 90 | #include "libgcc_tm.h" |
| 91 | +#endif /* __COREBOOT__ */ |
| 92 | |
| 93 | +#ifndef __COREBOOT__ |
| 94 | #if defined(inhibit_libc) |
| 95 | #define IN_LIBGCOV (-1) |
| 96 | #else |
| 97 | @@ -41,6 +70,7 @@ |
| 98 | #define GCOV_LINKAGE /* nothing */ |
| 99 | #endif |
| 100 | #endif |
| 101 | +#endif /* __COREBOOT__ */ |
| 102 | #include "gcov-io.h" |
| 103 | |
| 104 | #if defined(inhibit_libc) |
| 105 | @@ -68,12 +98,17 @@ |
| 106 | |
| 107 | #else |
| 108 | |
| 109 | +#ifndef __COREBOOT__ |
| 110 | #include <string.h> |
| 111 | #if GCOV_LOCKED |
| 112 | #include <fcntl.h> |
| 113 | #include <errno.h> |
| 114 | #include <sys/stat.h> |
| 115 | #endif |
| 116 | +#else |
| 117 | +void __gcov_merge_add(gcov_type *counters __attribute__ ((unused)), |
| 118 | + unsigned n_counters __attribute__ ((unused))) {} |
| 119 | +#endif /* __COREBOOT__ */ |
| 120 | |
| 121 | #ifdef L_gcov |
| 122 | #include "gcov-io.c" |
| 123 | @@ -99,6 +134,10 @@ |
| 124 | static int |
| 125 | create_file_directory (char *filename) |
| 126 | { |
| 127 | +#ifdef __COREBOOT__ |
| 128 | + (void) filename; |
| 129 | + return 0; |
| 130 | +#else |
| 131 | #if !defined(TARGET_POSIX_IO) && !defined(_WIN32) |
| 132 | (void) filename; |
| 133 | return -1; |
| 134 | @@ -137,6 +176,7 @@ |
| 135 | }; |
| 136 | return 0; |
| 137 | #endif |
| 138 | +#endif |
| 139 | } |
| 140 | |
| 141 | static struct gcov_fn_buffer * |
| 142 | @@ -279,7 +319,7 @@ |
| 143 | struct gcov_ctr_summary *cs_ptr; |
| 144 | const struct gcov_ctr_info *ci_ptr; |
| 145 | unsigned t_ix; |
| 146 | - int f_ix; |
| 147 | + int f_ix = 0; |
| 148 | gcov_unsigned_t c_num; |
| 149 | const char *gcov_prefix; |
| 150 | int gcov_prefix_strip = 0; |
| 151 | @@ -329,6 +369,7 @@ |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | +#ifndef __COREBOOT__ |
| 156 | { |
| 157 | /* Check if the level of dirs to strip off specified. */ |
| 158 | char *tmp = getenv("GCOV_PREFIX_STRIP"); |
| 159 | @@ -352,6 +393,7 @@ |
| 160 | prefix_length--; |
| 161 | } |
| 162 | else |
| 163 | +#endif |
| 164 | prefix_length = 0; |
| 165 | |
| 166 | /* If no prefix was specified and a prefix stip, then we assume |
| 167 | @@ -696,8 +738,10 @@ |
| 168 | if (filename_length > gcov_max_filename) |
| 169 | gcov_max_filename = filename_length; |
| 170 | |
| 171 | +#ifndef __COREBOOT__ |
| 172 | if (!gcov_list) |
| 173 | atexit (gcov_exit); |
| 174 | +#endif |
| 175 | |
| 176 | info->next = gcov_list; |
| 177 | gcov_list = info; |
Stefan Reinauer | f572e1e | 2013-01-16 09:47:54 -0800 | [diff] [blame] | 178 | @@ -767,14 +811,15 @@ |
| 179 | |
| 180 | #ifdef L_gcov_merge_single |
| 181 | /* The profile merging function for choosing the most common value. |
| 182 | - It is given an array COUNTERS of N_COUNTERS old counters and it |
| 183 | - reads the same number of counters from the gcov file. The counters |
| 184 | - are split into 3-tuples where the members of the tuple have |
| 185 | - meanings: |
| 186 | - |
| 187 | - -- the stored candidate on the most common value of the measured entity |
| 188 | - -- counter |
| 189 | - -- total number of evaluations of the value */ |
| 190 | + * It is given an array COUNTERS of N_COUNTERS old counters and it |
| 191 | + * reads the same number of counters from the gcov file. The counters |
| 192 | + * are split into 3-tuples where the members of the tuple have |
| 193 | + * meanings: |
| 194 | + * |
| 195 | + * -- the stored candidate on the most common value of the measured entity |
| 196 | + * -- counter |
| 197 | + * -- total number of evaluations of the value |
| 198 | + */ |
| 199 | void |
| 200 | __gcov_merge_single (gcov_type *counters, unsigned n_counters) |
| 201 | { |
| 202 | @@ -805,15 +850,16 @@ |
| 203 | |
| 204 | #ifdef L_gcov_merge_delta |
| 205 | /* The profile merging function for choosing the most common |
| 206 | - difference between two consecutive evaluations of the value. It is |
| 207 | - given an array COUNTERS of N_COUNTERS old counters and it reads the |
| 208 | - same number of counters from the gcov file. The counters are split |
| 209 | - into 4-tuples where the members of the tuple have meanings: |
| 210 | - |
| 211 | - -- the last value of the measured entity |
| 212 | - -- the stored candidate on the most common difference |
| 213 | - -- counter |
| 214 | - -- total number of evaluations of the value */ |
| 215 | + * difference between two consecutive evaluations of the value. It is |
| 216 | + * given an array COUNTERS of N_COUNTERS old counters and it reads the |
| 217 | + * same number of counters from the gcov file. The counters are split |
| 218 | + * into 4-tuples where the members of the tuple have meanings: |
| 219 | + * |
| 220 | + * -- the last value of the measured entity |
| 221 | + * -- the stored candidate on the most common difference |
| 222 | + * -- counter |
| 223 | + * -- total number of evaluations of the value |
| 224 | + */ |
| 225 | void |
| 226 | __gcov_merge_delta (gcov_type *counters, unsigned n_counters) |
| 227 | { |