gdb/33: name matching on template names is sensitive to white space

Michael Elizabeth Chastain chastain@cygnus.com
Fri Feb 23 12:48:00 GMT 2001


The following reply was made to PR gdb/33; it has been noted by GNATS.

From: Michael Elizabeth Chastain <chastain@cygnus.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: gdb/33: name matching on template names is sensitive to white space
Date: Fri, 23 Feb 2001 12:41:21 -0800

 In lookup_block_symbol, the binary search loop says:
 
  1240           else if (strcmp (SYMBOL_SOURCE_NAME (sym), name) < 0)
  1241             {
  1242               bot = inc;
  1243             }
  1244           else
  1245             {
  1246               top = inc;
 
 I've got:
 
   SYMBOL_SOURCE_NAME (sym) = "Foo<volatile char *>"
   name                     = "Foo<volatile char*>"
 
 (I am typing a new-style name into gdb with a v2 inferior program).
 
 strcmp is the wrong test here; it returns a misleading value.
 In this particular case, the binary search stays on track, but this
 is a dangerous bug.
 
 A few lines later:
 
   1261           sym = BLOCK_SYM (block, bot);
   1262           if (SYMBOL_NAMESPACE (sym) == namespace &&
   1263               SYMBOL_MATCHES_NAME (sym, name))
   1264             {
   1265               return sym;
   1266             }
 
 Again:
 
   SYMBOL_SOURCE_NAME (sym) = "Foo<volatile char *>"
   name                     = "Foo<volatile char*>"
 
 The namespaces match, but SYMBOL_MATCHES_NAME fails.  It fails because
 this sym does not have a demangled name:
 
   271 #define SYMBOL_MATCHES_NAME(symbol, name)                               \
   272   (STREQ (SYMBOL_NAME (symbol), (name))                                 \
   273    || (SYMBOL_DEMANGLED_NAME (symbol) != NULL                           \
   274        && strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
   275 
 
   [top1] print *sym
   $30 = {ginfo = {name = 0x826f8b8 "Foo<volatile char *>", value = {ivalue = 0, 
 	block = 0x0, bytes = 0x0, address = 0, chain = 0x0}, 
       language_specific = {cplus_specific = {demangled_name = 0x0}, 
 	chill_specific = {demangled_name = 0x0}}, language = language_cplus, 
       section = 0, bfd_section = 0x0}, type = 0x8271288, 
     namespace = VAR_NAMESPACE, aclass = LOC_TYPEDEF, line = 557, aux_value = {
       basereg = 0}, aliases = 0x0, ranges = 0x0}
 
 Thus, this template name gets matched only on an exact match.



More information about the Gdb-prs mailing list