On 9 May 2012 01:34, Cary Coutant <ccout...@google.com> wrote:
>>> A suggestion: Make dwarf_name call the demangler, and then a (new?) a
>>> function that converts a mangled decl to a human-readable string. In
>>> any case, the pretty-printer does a lot of stuff that is mostly
>>> useless for just printing a declaration (translation, wrapping, etc.).
>>>
>>> Bonus point if all GNU toolchain program use the same functions for
>>> demangling and undemagling (because I guess they actually don't, no?)
>>>
>>> I guess it cannot be so easy, so I apologize in advance for saying nonsense.
>>
>> It makes sense; and I don't think it is as complicated as it might sound.
>
> dwarf_name takes a tree; the demangler takes a mangled name. We don't
> have mangled names for many of the names we want to enter into the
> pubnames table.

Sorry that was a typo. My proposal is to mangle the tree (GCC already
does that) and then demangle it to a human-readable string (GCC also
does that already, no? Or at least  GDB and other programs have to do
that anyway, no? In any case, the demangling code should be shared
and, hence, consistent.)

For the names that the mangler/demangler do not support, I guess it
doesn't make sense to extend the demangler, so you will need to handle
them explicitly. You may call then the pretty-printer, since anyway
GDB and the other programs cannot demangle those names, so whatever is
used by GCC should be fine. Or implement a custom pretty-printer for
them. A custom pretty-printer will be for sure much simpler than the
diagnostics pretty-printer, since you don't have to worry about all
kinds of trees, wrapping, inheritance, i18n, etc.

Probably I am missing some details that may make the plan above
infeasible. In any case, I think your intention to make the output of
the different toolchain programs more consistent is worthwhile. If
dwarf_name has to use the pretty-printer, then I'd prefer that you
changed the demangler to match the diagnostics output, rather than the
other way around. Also, I am no maintainer, so these are merely
suggestions that you may freely ignore. :-)

Cheers,

Manuel..

Reply via email to