* symtab.h (SYMBOL_INIT_MANGLED_NAME): Turn this macro's body into
authorJim Blandy <jimb@codesourcery.com>
Wed, 27 Mar 2002 23:10:24 +0000 (23:10 +0000)
committerJim Blandy <jimb@codesourcery.com>
Wed, 27 Mar 2002 23:10:24 +0000 (23:10 +0000)
a function; leave this macro here to invoke that function.
(symbol_init_mangled_name): Declaration for that function.
* symtab.c (symbol_init_mangled_name): New function.

gdb/ChangeLog
gdb/symtab.c
gdb/symtab.h

index 1a08999ea9516878fc6df8326f12eb3b317d6997..af8bb5e071f13521db16ca575ca93dea919bcb95 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-27  Jim Blandy  <jimb@redhat.com>
+
+       * symtab.h (SYMBOL_INIT_MANGLED_NAME): Turn this macro's body into
+       a function; leave this macro here to invoke that function.
+       (symbol_init_mangled_name): Declaration for that function.
+       * symtab.c (symbol_init_mangled_name): New function.
+
 2002-03-27  Andrew Cagney  <ac131313@redhat.com>
 
        * valarith.c: Replace strerror with safe_strerror.
index 98c3250529c04f96a8fd806bc4cdbce3627f7911..bf6df51806faf64d5adaf49303b2f72ea948f691 100644 (file)
@@ -349,6 +349,83 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   strcat (mangled_name, physname);
   return (mangled_name);
 }
+
+\f
+/* Initialize a symbol's mangled name.  */
+
+/* Try to initialize the demangled name for a symbol, based on the
+   language of that symbol.  If the language is set to language_auto,
+   it will attempt to find any demangling algorithm that works and
+   then set the language appropriately.  If no demangling of any kind
+   is found, the language is set back to language_unknown, so we can
+   avoid doing this work again the next time we encounter the symbol.
+   Any required space to store the name is obtained from the specified
+   obstack. */
+
+void
+symbol_init_demangled_name (struct general_symbol_info *gsymbol,
+                            struct obstack *obstack)
+{
+  char *mangled = gsymbol->name;
+  char *demangled = NULL;
+
+  if (gsymbol->language == language_unknown)
+    gsymbol->language = language_auto;
+  if (gsymbol->language == language_cplus
+      || gsymbol->language == language_auto)
+    {
+      demangled =
+        cplus_demangle (gsymbol->name, DMGL_PARAMS | DMGL_ANSI);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_cplus;
+          gsymbol->language_specific.cplus_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+        }
+    }
+  if (gsymbol->language == language_java)
+    {
+      demangled =
+        cplus_demangle (gsymbol->name,
+                        DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_java;
+          gsymbol->language_specific.cplus_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+        }
+    }
+  if (demangled == NULL
+      && (gsymbol->language == language_chill
+          || gsymbol->language == language_auto))
+    {
+      demangled =
+        chill_demangle (gsymbol->name);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_chill;
+          gsymbol->language_specific.chill_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.chill_specific.demangled_name = NULL;
+        }
+    }
+}
+
+
 \f
 
 
index 69fcf15de5b29402bef0834b4118da1f21866222..f59e7a32040f03571904c66007cdae2e38fb5d58 100644 (file)
@@ -159,74 +159,12 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *);
       }                                                                        \
   } while (0)
 
-/* Macro that attempts to initialize the demangled name for a symbol,
-   based on the language of that symbol.  If the language is set to
-   language_auto, it will attempt to find any demangling algorithm
-   that works and then set the language appropriately.  If no demangling
-   of any kind is found, the language is set back to language_unknown,
-   so we can avoid doing this work again the next time we encounter
-   the symbol.  Any required space to store the name is obtained from the
-   specified obstack. */
-
-#define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack)                     \
-  do {                                                                 \
-    char *demangled = NULL;                                            \
-    if (SYMBOL_LANGUAGE (symbol) == language_unknown)                 \
-          SYMBOL_LANGUAGE (symbol) = language_auto;                    \
-    if (SYMBOL_LANGUAGE (symbol) == language_cplus                     \
-       || SYMBOL_LANGUAGE (symbol) == language_auto)                   \
-      {                                                                        \
-       demangled =                                                     \
-         cplus_demangle (SYMBOL_NAME (symbol), DMGL_PARAMS | DMGL_ANSI);\
-       if (demangled != NULL)                                          \
-         {                                                             \
-           SYMBOL_LANGUAGE (symbol) = language_cplus;                  \
-           SYMBOL_CPLUS_DEMANGLED_NAME (symbol) =                      \
-             obsavestring (demangled, strlen (demangled), (obstack));  \
-           xfree (demangled);                                          \
-         }                                                             \
-       else                                                            \
-         {                                                             \
-           SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;                \
-         }                                                             \
-      }                                                                        \
-    if (SYMBOL_LANGUAGE (symbol) == language_java)                     \
-      {                                                                        \
-       demangled =                                                     \
-         cplus_demangle (SYMBOL_NAME (symbol),                         \
-                         DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);         \
-       if (demangled != NULL)                                          \
-         {                                                             \
-           SYMBOL_LANGUAGE (symbol) = language_java;                   \
-           SYMBOL_CPLUS_DEMANGLED_NAME (symbol) =                      \
-             obsavestring (demangled, strlen (demangled), (obstack));  \
-           xfree (demangled);                                          \
-         }                                                             \
-       else                                                            \
-         {                                                             \
-           SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;                \
-         }                                                             \
-      }                                                                        \
-    if (demangled == NULL                                              \
-       && (SYMBOL_LANGUAGE (symbol) == language_chill                  \
-           || SYMBOL_LANGUAGE (symbol) == language_auto))              \
-      {                                                                        \
-       demangled =                                                     \
-         chill_demangle (SYMBOL_NAME (symbol));                        \
-       if (demangled != NULL)                                          \
-         {                                                             \
-           SYMBOL_LANGUAGE (symbol) = language_chill;                  \
-           SYMBOL_CHILL_DEMANGLED_NAME (symbol) =                      \
-             obsavestring (demangled, strlen (demangled), (obstack));  \
-           xfree (demangled);                                          \
-         }                                                             \
-       else                                                            \
-         {                                                             \
-           SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL;                \
-         }                                                             \
-      }                                                                        \
-  } while (0)
+#define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack) \
+  (symbol_init_demangled_name (&symbol->ginfo, (obstack)))
+extern void symbol_init_demangled_name (struct general_symbol_info *symbol,
+                                        struct obstack *obstack);
 
+  
 /* Macro that returns the demangled name for a symbol based on the language
    for that symbol.  If no demangled name exists, returns NULL. */