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]
Other format: [Raw text]

[RFA] Demangle symbols before lowercasing them instead of after


This slipped through the cracks - my fault for attaching it to the end
of a thread.  This lets us call cplus_demangle before we potentially
lowercase, which seems more correct to me.  OK?

----- Forwarded message from Daniel Jacobowitz <drow@mvista.com> -----

Date: Fri, 22 Mar 2002 17:23:22 -0500
From: Daniel Jacobowitz <drow@mvista.com>
Subject: Re: [RFA] Select a particular mangling of a demangled symbol in lookup_block_symbol
To: Elena Zannoni <ezannoni@redhat.com>
Cc: gdb-patches@sources.redhat.com
Mail-Followup-To: Elena Zannoni <ezannoni@redhat.com>,
	gdb-patches@sources.redhat.com

On Fri, Mar 22, 2002 at 03:11:01PM -0500, Elena Zannoni wrote:
> Daniel Jacobowitz writes:
>  > On Tue, Mar 19, 2002 at 05:46:58PM -0500, Elena Zannoni wrote:
>  > > Replying to myself. I was testing with dwarf2, but using stabs I can
>  > > see it.  I can also see that we call cplus_demangle (__3foor3foo, ...)
>  > > instead of cplus_demangle (__3fooR3foo, ...), if 'set case off'. But
>  > > it returns foo::foo(long double, foo) anyway. So it works?
>  > 
>  > Absolutely not:
>  > 
>  > drow@nevyn:~% c++filt
>  > __3fooR3foo
>  > foo::foo(foo &)
>  > __3foor3foo
>  > foo::foo(long double, foo)
>  > 
> 
> Ah, I didn't think twice when I saw it not core dumping!
> 
>  > Those aren't the same function at all :)
>  > 
> 
> Indeed. Then I think we definitely should use the uppercase parameter.

Is this what you had in mind?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-03-22  Daniel Jacobowitz  <drow@mvista.com>

	* symtab.c (lookup_symbol): Demangle before lowercasing.

Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.58
diff -u -p -r1.58 symtab.c
--- symtab.c	2002/03/22 18:57:08	1.58
+++ symtab.c	2002/03/22 22:22:23
@@ -569,12 +569,27 @@ lookup_symbol (const char *name, const s
 	       const namespace_enum namespace, int *is_a_field_of_this,
 	       struct symtab **symtab)
 {
-  char *modified_name = NULL;
-  char *modified_name2 = NULL;
+  char *demangled_name = NULL;
+  const char *modified_name = NULL;
   const char *mangled_name = NULL;
   int needtofreename = 0;
   struct symbol *returnval;
 
+  modified_name = name;
+
+  /* If we are using C++ language, demangle the name before doing a lookup, so
+     we can always binary search. */
+  if (current_language->la_language == language_cplus)
+    {
+      demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
+      if (demangled_name)
+	{
+	  mangled_name = name;
+	  modified_name = demangled_name;
+	  needtofreename = 1;
+	}
+    }
+
   if (case_sensitivity == case_sensitive_off)
     {
       char *copy;
@@ -587,26 +602,11 @@ lookup_symbol (const char *name, const s
       copy[len] = 0;
       modified_name = copy;
     }
-  else 
-      modified_name = (char *) name;
-
-  /* If we are using C++ language, demangle the name before doing a lookup, so
-     we can always binary search. */
-  if (current_language->la_language == language_cplus)
-    {
-      modified_name2 = cplus_demangle (modified_name, DMGL_ANSI | DMGL_PARAMS);
-      if (modified_name2)
-	{
-	  mangled_name = name;
-	  modified_name = modified_name2;
-	  needtofreename = 1;
-	}
-    }
 
   returnval = lookup_symbol_aux (modified_name, mangled_name, block,
 				 namespace, is_a_field_of_this, symtab);
   if (needtofreename)
-    xfree (modified_name2);
+    xfree (demangled_name);
 
   return returnval;	 
 }


----- End forwarded message -----

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


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