From: Jim Blandy Date: Wed, 27 Mar 2002 23:10:24 +0000 (+0000) Subject: * symtab.h (SYMBOL_INIT_MANGLED_NAME): Turn this macro's body into X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=12af6855fb8ac29e653f5e8e1f898b7c229e65e8;p=binutils-gdb.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1a08999ea95..af8bb5e071f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2002-03-27 Jim Blandy + + * 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 * valarith.c: Replace strerror with safe_strerror. diff --git a/gdb/symtab.c b/gdb/symtab.c index 98c3250529c..bf6df51806f 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; + } + } +} + + diff --git a/gdb/symtab.h b/gdb/symtab.h index 69fcf15de5b..f59e7a32040 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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. */