aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2002-03-27 23:10:24 +0000
committerJim Blandy <jimb@codesourcery.com>2002-03-27 23:10:24 +0000
commit12af6855fb8ac29e653f5e8e1f898b7c229e65e8 (patch)
treedfcb230b8b70743c0867ea48361e9133dd9ecc33 /gdb/symtab.c
parentfd74cc6bd4c53d8b4c4114b29e5638676b8a3193 (diff)
downloadgdb-12af6855fb8ac29e653f5e8e1f898b7c229e65e8.zip
gdb-12af6855fb8ac29e653f5e8e1f898b7c229e65e8.tar.gz
gdb-12af6855fb8ac29e653f5e8e1f898b7c229e65e8.tar.bz2
* 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.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 98c3250..bf6df51 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -349,6 +349,83 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
strcat (mangled_name, physname);
return (mangled_name);
}
+
+
+/* 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;
+ }
+ }
+}
+
+