From 8578ba4dbefcb4bae5c038cfdc912b7ad7b5927b Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 17 May 2011 21:26:39 +0000 Subject: [PATCH] gdb/ * dwarf2read.c (find_slot_in_mapped_hash): New variable back_to, initialize it. Delay HASH initialization. Strip the part after open parenthesis for languages with qualifiers. Call do_cleanups. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2read.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e4894c7d0c7..f70a5359aa2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-04-01 Jan Kratochvil + + * dwarf2read.c (find_slot_in_mapped_hash): New variable back_to, + initialize it. Delay HASH initialization. Strip the part after open + parenthesis for languages with qualifiers. Call do_cleanups. + 2011-04-01 Tom Tromey * utils.c (report_command_stats): Don't print `-' for negative diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 7e74cea8c0a..51e0442ffbe 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1997,9 +1997,32 @@ static int find_slot_in_mapped_hash (struct mapped_index *index, const char *name, offset_type **vec_out) { - offset_type hash = mapped_index_string_hash (name); + struct cleanup *back_to = make_cleanup (null_cleanup, 0); + offset_type hash; offset_type slot, step; + if (current_language->la_language == language_cplus + || current_language->la_language == language_java + || current_language->la_language == language_fortran) + { + /* NAME is already canonical. Drop any qualifiers as .gdb_index does + not contain any. */ + const char *paren = strchr (name, '('); + + if (paren) + { + char *dup; + + dup = xmalloc (paren - name + 1); + memcpy (dup, name, paren - name); + dup[paren - name] = 0; + + make_cleanup (xfree, dup); + name = dup; + } + } + + hash = mapped_index_string_hash (name); slot = hash & (index->symbol_table_slots - 1); step = ((hash * 17) & (index->symbol_table_slots - 1)) | 1; @@ -2009,13 +2032,17 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name, offset_type i = 2 * slot; const char *str; if (index->symbol_table[i] == 0 && index->symbol_table[i + 1] == 0) - return 0; + { + do_cleanups (back_to); + return 0; + } str = index->constant_pool + MAYBE_SWAP (index->symbol_table[i]); if (!strcmp (name, str)) { *vec_out = (offset_type *) (index->constant_pool + MAYBE_SWAP (index->symbol_table[i + 1])); + do_cleanups (back_to); return 1; } -- 2.47.2