OSDN Git Service

gdb/
authorjkratoch <jkratoch>
Fri, 1 Apr 2011 17:46:41 +0000 (17:46 +0000)
committerjkratoch <jkratoch>
Fri, 1 Apr 2011 17:46:41 +0000 (17:46 +0000)
* 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
gdb/dwarf2read.c

index e8607df..954bc2c 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * 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  <tromey@redhat.com>
 
        * utils.c (report_command_stats): Don't print `-' for negative
index 3fafe9f..ca6c98b 100644 (file)
@@ -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;
        }