This is the mail archive of the gdb@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]
Other format: [Raw text]

Re: new demangler


Ian Lance Taylor <ian@wasabisystems.com> writes:

> David Carlton <carlton@kealia.com> writes:
> 
> > So is there a problem with the way class_name_from_physname invokes
> > the demangler?  It does this:
> > 
> >   char *demangled_name = cplus_demangle (physname, DMGL_ANSI);
> > 
> > Compared to other places in GDB where the demangler is called, this is
> > unusual since DMGL_PARAMS isn't passed in as well, but I don't see why
> > that would cause the demangling to fail completely.
> 
> Well, in fact, there was a bug in the case where DMGL_PARAMS was not
> set.  I just checked in a patch for it.
> 
> Sorry about that.  I've had the patch for a while, but I haven't had a
> chance to check it in.

BTW, when I say that I just checked in the patch, I mean that I just
checked it in to the master sources in the gcc repository.

Here's the patch.

Ian

Index: cp-demangle.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.c,v
retrieving revision 1.58
diff -u -p -r1.58 cp-demangle.c
--- cp-demangle.c	15 Dec 2003 14:37:25 -0000	1.58
+++ cp-demangle.c	15 Dec 2003 23:14:02 -0000
@@ -3622,9 +3622,11 @@ d_demangle (mangled, options, palc)
   else
     dc = d_type (&di);
 
-  /* If we didn't consume the entire mangled string, then we didn't
-     successfully demangle it.  */
-  if (d_peek_char (&di) != '\0')
+  /* If DMGL_PARAMS is set, then if we didn't consume the entire
+     mangled string, then we didn't successfully demangle it.  If
+     DMGL_PARAMS is not set, we didn't look at the trailing
+     parameters.  */
+  if (((options & DMGL_PARAMS) != 0) && d_peek_char (&di) != '\0')
     dc = NULL;
 
 #ifdef CP_DEMANGLE_DEBUG
@@ -3829,37 +3831,37 @@ is_ctor_or_dtor (mangled, ctor_kind, dto
 
   dc = d_mangled_name (&di, 1);
 
+  /* Note that because we did not pass DMGL_PARAMS, we don't expect to
+     demangle the entire string.  */
+
   ret = 0;
-  if (d_peek_char (&di) == '\0')
+  while (dc != NULL)
     {
-      while (dc != NULL)
+      switch (dc->type)
 	{
-	  switch (dc->type)
-	    {
-	    default:
-	      dc = NULL;
-	      break;
-	    case D_COMP_TYPED_NAME:
-	    case D_COMP_TEMPLATE:
-	    case D_COMP_RESTRICT_THIS:
-	    case D_COMP_VOLATILE_THIS:
-	    case D_COMP_CONST_THIS:
-	      dc = d_left (dc);
-	      break;
-	    case D_COMP_QUAL_NAME:
-	      dc = d_right (dc);
-	      break;
-	    case D_COMP_CTOR:
-	      *ctor_kind = dc->u.s_ctor.kind;
-	      ret = 1;
-	      dc = NULL;
-	      break;
-	    case D_COMP_DTOR:
-	      *dtor_kind = dc->u.s_dtor.kind;
-	      ret = 1;
-	      dc = NULL;
-	      break;
-	    }
+	default:
+	  dc = NULL;
+	  break;
+	case D_COMP_TYPED_NAME:
+	case D_COMP_TEMPLATE:
+	case D_COMP_RESTRICT_THIS:
+	case D_COMP_VOLATILE_THIS:
+	case D_COMP_CONST_THIS:
+	  dc = d_left (dc);
+	  break;
+	case D_COMP_QUAL_NAME:
+	  dc = d_right (dc);
+	  break;
+	case D_COMP_CTOR:
+	  *ctor_kind = dc->u.s_ctor.kind;
+	  ret = 1;
+	  dc = NULL;
+	  break;
+	case D_COMP_DTOR:
+	  *dtor_kind = dc->u.s_dtor.kind;
+	  ret = 1;
+	  dc = NULL;
+	  break;
 	}
     }
 


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