This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix gdb.cp/ovsrch.exp C++ regression-by-.gdb_index


Hi,

runtest gdb.cp/ovsrch.exp 
vs.
runtest CC_FOR_TARGET=/bin/sh\ $PWD/../cc-with-index.sh\ gcc CXX_FOR_TARGET=/bin/sh\ $PWD/../cc-with-index.sh\ g++ gdb.cp/ovsrch.exp 

has a regression for .gdb_index.  There is more of them (like symbols
completion) but this one may be more serious.
	[Bug symtab/12426] New: Testsuite .gdb_index regressions
	http://sourceware.org/bugzilla/show_bug.cgi?id=12426

Maybe find_slot_in_mapped_hash should also canonicalize NAME first but in
practice the GDB code around already passes it canonicalized.

No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.  I have seen no
other change except fixed gdb.cp/ovsrch.exp.

I believe this patch would be useful for 7.3.


Thanks,
Jan


gdb/
2011-03-30  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.

--- 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;
 	}
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]