diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-18 15:10:23 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-18 15:10:23 +0000 |
commit | 39eca7a3220daee8361d2eff13e896e709276d68 (patch) | |
tree | 9fed97a9faf770cfb1e07dc8d782fa440327f565 /gcc/coverage.c | |
parent | d318582e1dd076c5dae41f12a42d99ed9fba7473 (diff) | |
download | gcc-39eca7a3220daee8361d2eff13e896e709276d68.tar.gz |
* coverage.c (checksum_string): Rename to ...
(coverage_checksum_string): ... this one, Use crc32_string; recognize
names containing random number and zero the number out in order to get
match.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76102 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r-- | gcc/coverage.c | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c index f14f0f666fe..d6322b2ca77 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -109,7 +109,7 @@ static int htab_counts_entry_eq (const void *, const void *); static void htab_counts_entry_del (void *); static void read_counts_file (void); static unsigned compute_checksum (void); -static unsigned checksum_string (unsigned, const char *); +static unsigned coverage_checksum_string (unsigned, const char *); static tree build_fn_info_type (unsigned); static tree build_fn_info_value (const struct function_list *, tree); static tree build_ctr_info_type (void); @@ -405,23 +405,51 @@ coverage_counter_ref (unsigned counter, unsigned no) checksum. */ static unsigned -checksum_string (unsigned chksum, const char *string) +coverage_checksum_string (unsigned chksum, const char *string) { - do + int i; + char *dup = NULL; + + /* Look for everything that looks if it were produced by + get_file_function_name_long 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. */ + for (i = 0; string[i]; i++) { - unsigned value = *string << 24; - unsigned ix; - - for (ix = 8; ix--; value <<= 1) - { - unsigned feedback; - - feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0; - chksum <<= 1; - chksum ^= feedback; - } + if (!strncmp (string + i, "_GLOBAL__", 9)) + for (i = i + 9; string[i]; i++) + if (string[i]=='_') + { + int y; + unsigned seed; + + for (y = 1; y < 9; y++) + if (!(string[i + y] >= '0' && string[i + y] <= '9') + && !(string[i + y] >= 'A' && string[i + y] <= 'F')) + break; + if (y != 9 || string[i + 9] != '_') + continue; + for (y = 10; y < 18; y++) + if (!(string[i + y] >= '0' && string[i + y] <= '9') + && !(string[i + y] >= 'A' && string[i + y] <= 'F')) + break; + if (y != 18) + continue; + if (!sscanf (string + i + 10, "%X", &seed)) + abort (); + if (seed != crc32_string (0, flag_random_seed)) + continue; + string = dup = xstrdup (string); + for (y = 10; y < 18; y++) + dup[i + y] = '0'; + break; + } + break; } - while (*string++); + + chksum = crc32_string (chksum, string); + if (dup) + free (dup); return chksum; } @@ -433,8 +461,9 @@ compute_checksum (void) { unsigned chksum = DECL_SOURCE_LINE (current_function_decl); - chksum = checksum_string (chksum, DECL_SOURCE_FILE (current_function_decl)); - chksum = checksum_string + chksum = coverage_checksum_string (chksum, + DECL_SOURCE_FILE (current_function_decl)); + chksum = coverage_checksum_string (chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); return chksum; |