Re: [RFA 3/3] Move logic out of symbol_find_demangled_name

Pedro Alves
2016-06-07T14:27:25Z

On 06/07/2016 12:41 PM, Tom Tromey wrote:
> - if (gsymbol->language == language_cplus
> - || gsymbol->language == language_rust
> - || gsymbol->language == language_auto)
> - {
> - demangled =
> - gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
> - if (demangled != NULL)
> - {
> - gsymbol->language = language_cplus;
> - return demangled;
> - }
> - }

Before, this would set language to language_cplus, even if the
symbol's language was Rust.

> +/* la_sniff_by_symbol for Rust. */
> +
> +static int
> +rust_sniff_by_symbol (const char *mangled, char **demangled)
> +{
> + *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
> + return 1;
> +}

However, this no longer forces C++, is that intended?

Also, before we'd check whether gdb_demangle returned not-NULL,
before taking the language, but now several languages
return 1 even if gdb_demangle returns NULL:

> +/* la_sniff_by_symbol for Java. */
> +
> +static int
> +java_sniff_by_symbol (const char *mangled, char **demangled)
> +{
> + *demangled = java_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
> + return 1;
> +}
> +

Seems like the first language to be consulted always wins?
Is that intended?

Thanks,
Pedro Alves