This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFA] symtab.c: Fix for infinite GDB recursion in gdb.c++/classes.exp


Current CVS GDB gets into an infinite recursion in gdb.c++/classes.exp
(print Foo::st) if a stock gcc-2.95.2 with DWARF2 debugging info is used
on Solaris and Linux x86.

The scenario is as follows:

lookup_symbol is called with a request for Foo::st, we find a matching
minimal symbol, detect that it is a mangled variable and call lookup_symbol
with the mangled name. Then lookup_symbol demangles the mangled name again,
calls lookup_symbol with Foo::st and off we go till the stack overflows.

Here is a fix:

	* symtab.c (lookup_symbol_aux):  Call lookup_symbol_aux, not
	lookup_symbol, when trying to find a symbol with a mangled name,
	to avoid infinite recursion.

*** gdb/symtab.c.orig	Wed Oct 25 16:13:13 2000
--- gdb/symtab.c	Thu Oct 26 20:03:48 2000
***************
*** 780,787 ****
  	    {
  	      /* This is a mangled variable, look it up by its
  	         mangled name.  */
! 	      return lookup_symbol (SYMBOL_NAME (msymbol), block,
! 				    namespace, is_a_field_of_this, symtab);
  	    }
  	  /* There are no debug symbols for this file, or we are looking
  	     for an unmangled variable.
--- 780,787 ----
  	    {
  	      /* This is a mangled variable, look it up by its
  	         mangled name.  */
! 	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
! 				        namespace, is_a_field_of_this, symtab);
  	    }
  	  /* There are no debug symbols for this file, or we are looking
  	     for an unmangled variable.
***************
*** 958,965 ****
  		   && MSYMBOL_TYPE (msymbol) != mst_file_text
  		   && !STREQ (name, SYMBOL_NAME (msymbol)))
  	    {
! 	      return lookup_symbol (SYMBOL_NAME (msymbol), block,
! 				    namespace, is_a_field_of_this, symtab);
  	    }
  	}
      }
--- 958,965 ----
  		   && MSYMBOL_TYPE (msymbol) != mst_file_text
  		   && !STREQ (name, SYMBOL_NAME (msymbol)))
  	    {
! 	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
! 				        namespace, is_a_field_of_this, symtab);
  	    }
  	}
      }

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

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