From 20c361f30eabe19869e6d2f338785e81866c3176 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 18 Jan 2004 16:10:23 +0100 Subject: [PATCH] coverage.c (checksum_string): Rename to ... * 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. From-SVN: r76102 --- gcc/ChangeLog | 7 ++++++ gcc/coverage.c | 61 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 47ec2e7fbb9..a7db3f7ba90 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-01-18 Jan Hubicka + + * 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. + 2004-01-18 Richard Sandiford * config/mips/mips.c (mips_got_alias_set): Mark for PCH. 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; + if (!strncmp (string + i, "_GLOBAL__", 9)) + for (i = i + 9; string[i]; i++) + if (string[i]=='_') + { + int y; + unsigned seed; - for (ix = 8; ix--; value <<= 1) - { - unsigned feedback; - - feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0; - chksum <<= 1; - chksum ^= feedback; - } + 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;