From f80b5ea1605c9f9408c5aa386ba71c16d918ebbf Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 22 Apr 2015 10:21:45 +0000 Subject: Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-5.1.0.tar.bz2. --- gcc/gcov-io.c | 86 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'gcc/gcov-io.c') diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 5ef82f6837..cbd0a9f147 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -1,5 +1,5 @@ /* File format for coverage information - Copyright (C) 1996-2014 Free Software Foundation, Inc. + Copyright (C) 1996-2015 Free Software Foundation, Inc. Contributed by Bob Manson . Completely remangled by Nathan Sidwell . @@ -39,7 +39,7 @@ static void gcov_allocate (unsigned); /* 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_position_t start; /* Position of first byte of block */ @@ -64,15 +64,23 @@ GCOV_LINKAGE struct gcov_var } gcov_var; /* Save the current position in the gcov file. */ -static inline gcov_position_t +/* We need to expose this function when compiling for gcov-tool. */ +#ifndef IN_GCOV_TOOL +static inline +#endif +gcov_position_t gcov_position (void) { - gcc_assert (gcov_var.mode > 0); + gcov_nonruntime_assert (gcov_var.mode > 0); return gcov_var.start + gcov_var.offset; } /* Return nonzero if the error flag is set. */ -static inline int +/* We need to expose this function when compiling for gcov-tool. */ +#ifndef IN_GCOV_TOOL +static inline +#endif +int gcov_is_error (void) { return gcov_var.file ? gcov_var.error : 1; @@ -83,7 +91,6 @@ gcov_is_error (void) GCOV_LINKAGE inline void gcov_rewrite (void) { - gcc_assert (gcov_var.mode > 0); gcov_var.mode = -1; gcov_var.start = 0; gcov_var.offset = 0; @@ -133,7 +140,7 @@ gcov_open (const char *name, int mode) s_flock.l_pid = getpid (); #endif - gcc_assert (!gcov_var.file); + gcov_nonruntime_assert (!gcov_var.file); gcov_var.start = 0; gcov_var.offset = gcov_var.length = 0; gcov_var.overread = -1u; @@ -297,14 +304,13 @@ gcov_write_words (unsigned words) { gcov_unsigned_t *result; - gcc_assert (gcov_var.mode < 0); + gcov_nonruntime_assert (gcov_var.mode < 0); #if IN_LIBGCOV if (gcov_var.offset >= GCOV_BLOCK_SIZE) { gcov_write_block (GCOV_BLOCK_SIZE); if (gcov_var.offset) { - gcc_assert (gcov_var.offset == 1); memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4); } } @@ -399,9 +405,9 @@ gcov_write_length (gcov_position_t position) gcov_unsigned_t length; gcov_unsigned_t *buffer; - gcc_assert (gcov_var.mode < 0); - gcc_assert (position + 2 <= gcov_var.start + gcov_var.offset); - gcc_assert (position >= gcov_var.start); + gcov_nonruntime_assert (gcov_var.mode < 0); + gcov_nonruntime_assert (position + 2 <= gcov_var.start + gcov_var.offset); + gcov_nonruntime_assert (position >= gcov_var.start); offset = position - gcov_var.start; length = gcov_var.offset - offset - 2; buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset]; @@ -487,23 +493,22 @@ gcov_read_words (unsigned words) const gcov_unsigned_t *result; unsigned excess = gcov_var.length - gcov_var.offset; - gcc_assert (gcov_var.mode > 0); + gcov_nonruntime_assert (gcov_var.mode > 0); if (excess < words) { gcov_var.start += gcov_var.offset; -#if IN_LIBGCOV if (excess) { - gcc_assert (excess == 1); +#if IN_LIBGCOV memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4); - } #else - memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, excess * 4); + memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, + excess * 4); #endif + } gcov_var.offset = 0; gcov_var.length = excess; #if IN_LIBGCOV - gcc_assert (!gcov_var.length || gcov_var.length == 1); excess = GCOV_BLOCK_SIZE; #else if (gcov_var.length + words > gcov_var.alloc) @@ -560,11 +565,13 @@ gcov_read_counter (void) return value; } +/* We need to expose the below function when compiling for gcov-tool. */ + +#if !IN_LIBGCOV || defined (IN_GCOV_TOOL) /* Read string from coverage file. Returns a pointer to a static buffer, or NULL on empty string. You must copy the string before calling another gcov function. */ -#if !IN_LIBGCOV GCOV_LINKAGE const char * gcov_read_string (void) { @@ -620,7 +627,9 @@ gcov_read_summary (struct gcov_summary *summary) while (!cur_bitvector) { h_ix = bv_ix * 32; - gcc_assert (bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE); + if (bv_ix >= GCOV_HISTOGRAM_BITVECTOR_SIZE) + gcov_error ("corrupted profile info: summary histogram " + "bitvector is corrupt"); cur_bitvector = histo_bitvector[bv_ix++]; } while (!(cur_bitvector & 0x1)) @@ -628,7 +637,9 @@ gcov_read_summary (struct gcov_summary *summary) h_ix++; cur_bitvector >>= 1; } - gcc_assert (h_ix < GCOV_HISTOGRAM_SIZE); + if (h_ix >= GCOV_HISTOGRAM_SIZE) + gcov_error ("corrupted profile info: summary histogram " + "index is corrupt"); csum->histogram[h_ix].num_counters = gcov_read_unsigned (); csum->histogram[h_ix].min_value = gcov_read_counter (); @@ -641,14 +652,16 @@ gcov_read_summary (struct gcov_summary *summary) } } -#if !IN_LIBGCOV +/* We need to expose the below function when compiling for gcov-tool. */ + +#if !IN_LIBGCOV || defined (IN_GCOV_TOOL) /* Reset to a known position. BASE should have been obtained from gcov_position, LENGTH should be a record length. */ GCOV_LINKAGE void gcov_sync (gcov_position_t base, gcov_unsigned_t length) { - gcc_assert (gcov_var.mode > 0); + gcov_nonruntime_assert (gcov_var.mode > 0); base += length; if (base - gcov_var.start <= gcov_var.length) gcov_var.offset = base - gcov_var.start; @@ -667,7 +680,6 @@ gcov_sync (gcov_position_t base, gcov_unsigned_t length) GCOV_LINKAGE void gcov_seek (gcov_position_t base) { - gcc_assert (gcov_var.mode < 0); if (gcov_var.offset) gcov_write_block (gcov_var.offset); fseek (gcov_var.file, base << 2, SEEK_SET); @@ -719,20 +731,8 @@ gcov_histo_index (gcov_type value) r = sizeof (long long) * __CHAR_BIT__ - 1 - __builtin_clzll (v); #else /* We use floor_log2 from hwint.c, which takes a HOST_WIDE_INT - that is either 32 or 64 bits, and gcov_type_unsigned may be 64 bits. - Need to check for the case where gcov_type_unsigned is 64 bits - and HOST_WIDE_INT is 32 bits and handle it specially. */ -#if HOST_BITS_PER_WIDEST_INT == HOST_BITS_PER_WIDE_INT + that is 64 bits and gcov_type_unsigned is 64 bits. */ r = floor_log2 (v); -#elif HOST_BITS_PER_WIDEST_INT == 2 * HOST_BITS_PER_WIDE_INT - HOST_WIDE_INT hwi_v = v >> HOST_BITS_PER_WIDE_INT; - if (hwi_v) - r = floor_log2 (hwi_v) + HOST_BITS_PER_WIDE_INT; - else - r = floor_log2 ((HOST_WIDE_INT)v); -#else - gcc_unreachable (); -#endif #endif } @@ -742,7 +742,7 @@ gcov_histo_index (gcov_type value) if (r < 2) return (unsigned)value; - gcc_assert (r < 64); + gcov_nonruntime_assert (r < 64); /* Find the two next most significant bits to determine which of the four linear sub-buckets to select. */ @@ -859,7 +859,7 @@ static void gcov_histogram_merge (gcov_bucket_type *tgt_histo, /* The merged counters get placed in the new merged histogram at the entry for the merged min_value. */ tmp_i = gcov_histo_index (merge_min); - gcc_assert (tmp_i < GCOV_HISTOGRAM_SIZE); + gcov_nonruntime_assert (tmp_i < GCOV_HISTOGRAM_SIZE); tmp_histo[tmp_i].num_counters += merge_num; tmp_histo[tmp_i].cum_value += merge_cum; if (!tmp_histo[tmp_i].min_value || @@ -873,7 +873,7 @@ static void gcov_histogram_merge (gcov_bucket_type *tgt_histo, } } - gcc_assert (tgt_i < 0); + gcov_nonruntime_assert (tgt_i < 0); /* In the case where there were more counters in the source histogram, accumulate the remaining unmerged cumulative counter values. Add @@ -890,8 +890,8 @@ static void gcov_histogram_merge (gcov_bucket_type *tgt_histo, } /* At this point, tmp_i should be the smallest non-zero entry in the tmp_histo. */ - gcc_assert (tmp_i >= 0 && tmp_i < GCOV_HISTOGRAM_SIZE - && tmp_histo[tmp_i].num_counters > 0); + gcov_nonruntime_assert (tmp_i >= 0 && tmp_i < GCOV_HISTOGRAM_SIZE + && tmp_histo[tmp_i].num_counters > 0); tmp_histo[tmp_i].cum_value += src_cum; /* Finally, copy the merged histogram into tgt_histo. */ @@ -1003,6 +1003,6 @@ compute_working_sets (const struct gcov_ctr_summary *summary, using a temporary above. */ cum += histo_bucket->cum_value; } - gcc_assert (ws_ix == NUM_GCOV_WORKING_SETS); + gcov_nonruntime_assert (ws_ix == NUM_GCOV_WORKING_SETS); } #endif /* IN_GCOV <= 0 && !IN_LIBGCOV */ -- cgit v1.2.1