aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-04-06 19:50:05 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-04-06 19:50:05 +0000
commit59d7bcaf18f0f9cff495e7a1a9e08dde859fb1f2 (patch)
tree118f98db3d708cd3040abc9be056ed0a817e9449
parent8c5fc8001110c72f83edccd8d3872cc868454f54 (diff)
downloadgdb-59d7bcaf18f0f9cff495e7a1a9e08dde859fb1f2.zip
gdb-59d7bcaf18f0f9cff495e7a1a9e08dde859fb1f2.tar.gz
gdb-59d7bcaf18f0f9cff495e7a1a9e08dde859fb1f2.tar.bz2
gdb/
Code cleanup. * dictionary.c (dict_hash): Use SYMBOL_HASH_NEXT. * dwarf2read.c (mapped_index_string_hash): Refer to SYMBOL_HASH_NEXT in the function comment, a new note on values compatibility. * minsyms.c (msymbol_hash_iw, msymbol_hash): Use SYMBOL_HASH_NEXT. * symtab.h (SYMBOL_HASH_NEXT): New.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/dictionary.c2
-rw-r--r--gdb/dwarf2read.c10
-rw-r--r--gdb/minsyms.c4
-rw-r--r--gdb/symtab.h6
5 files changed, 23 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 031e53a..349e47e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Code cleanup.
+ * dictionary.c (dict_hash): Use SYMBOL_HASH_NEXT.
+ * dwarf2read.c (mapped_index_string_hash): Refer to SYMBOL_HASH_NEXT
+ in the function comment, a new note on values compatibility.
+ * minsyms.c (msymbol_hash_iw, msymbol_hash): Use SYMBOL_HASH_NEXT.
+ * symtab.h (SYMBOL_HASH_NEXT): New.
+
2011-04-06 Thiago Jung Bauermann <bauerman@br.ibm.com>
* ppc-linux-nat.c (check_condition): Add len output parameter.
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 2981692..8142d29 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -826,7 +826,7 @@ dict_hash (const char *string0)
}
/* FALL THROUGH */
default:
- hash = hash * 67 + *string - 113;
+ hash = SYMBOL_HASH_NEXT (hash, *string);
string += 1;
break;
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 591e474..5086733 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1962,11 +1962,11 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
do_cleanups (cleanup);
}
-/* The hash function for strings in the mapped index. This is the
- same as the hashtab.c hash function, but we keep a separate copy to
- maintain control over the implementation. This is necessary
- because the hash function is tied to the format of the mapped index
- file. */
+/* The hash function for strings in the mapped index. This is the same as
+ SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
+ implementation. This is necessary because the hash function is tied to the
+ format of the mapped index file. The hash values do not have to match with
+ SYMBOL_HASH_NEXT. */
static hashval_t
mapped_index_string_hash (const void *p)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index b054e3f..a2c5ebc 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -91,7 +91,7 @@ msymbol_hash_iw (const char *string)
++string;
if (*string && *string != '(')
{
- hash = hash * 67 + *string - 113;
+ hash = SYMBOL_HASH_NEXT (hash, *string);
++string;
}
}
@@ -106,7 +106,7 @@ msymbol_hash (const char *string)
unsigned int hash = 0;
for (; *string; ++string)
- hash = hash * 67 + *string - 113;
+ hash = SYMBOL_HASH_NEXT (hash, *string);
return hash;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 59bbe24..4913e6c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1004,6 +1004,12 @@ extern unsigned int msymbol_hash_iw (const char *);
extern unsigned int msymbol_hash (const char *);
+/* Compute the next hash value from previous HASH and the character C. This
+ is only a GDB in-memory computed value with no external files compatibility
+ requirements. */
+
+#define SYMBOL_HASH_NEXT(hash, c) ((hash) * 67 + (c) - 113)
+
extern struct objfile * msymbol_objfile (struct minimal_symbol *sym);
extern void