[RFA] lookup_block_symbol ignores namespace parameter in binary search (gnatsweb gdb/15)

Michael Elizabeth Chastain chastain@cygnus.com
Mon Jan 29 15:48:00 GMT 2001


This patch fixes gnats gdb bug gdb/15 and the ERROR (gdb core dumps)
in gdb.base/structs3.exp, which I am submitting as a separate patch.

This is one of those stupid "how did it ever work" bugs.  The binary
search in lookup_block_symbol simply fails to make a required check.

I found this problem while I was analyzing some other problem in gdb.
I did a "maint print symbols" with a sourceware gdb on an inferior gdb,
and the *superior* gdb crashed with fifty thousand stack frames in
the core dump.  So then I fired up an older, good gdb and debugged the
superior sourceware gdb operating on an inferior sourceware gdb.

I tracked that crash to this bug.

I tested this on Red Hat Linux 7 native using sourceware CVS gcc and
sourceware CVS gdb.  I ran the test suite before and after this patch
and got no variations.  I also ran a new test script before and after
and observed the bug happening (before) and not happening (after).

OK to commit?

Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"

2001-01-29  Michael Chastain  <chastain@redhat.com>

	* symtab.c (block_lookup_symbol): Use 'namespace' parameter in
	symbol comparisons in binary search.

Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 symtab.c
*** gdb/symtab.c	2001/01/19 08:01:46	1.27
--- gdb/symtab.c	2001/01/29 23:35:28
*************** lookup_block_symbol (register const stru
*** 1259,1266 ****
        while (bot < top)
  	{
  	  sym = BLOCK_SYM (block, bot);
! 	  if (SYMBOL_MATCHES_NAME (sym, name))
! 	    return sym;
  	  bot++;
  	}
      }
--- 1259,1269 ----
        while (bot < top)
  	{
  	  sym = BLOCK_SYM (block, bot);
! 	  if (SYMBOL_NAMESPACE (sym) == namespace &&
! 	      SYMBOL_MATCHES_NAME (sym, name))
! 	    {
! 	      return sym;
! 	    }
  	  bot++;
  	}
      }


More information about the Gdb-patches mailing list