From 0cf03b497aedf582a82416b2444acf88bde08de4 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 1 Apr 2011 17:46:44 +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 e8607df8b92..954bc2cec11 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 3fafe9f2cbb..ca6c98b5b5f 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1989,9 +1989,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; @@ -2001,13 +2024,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.30.2