This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch and pubnames 2/2] Adjust c decl pretty printer to match demangler (issue6195056)


On 8 May 2012 18:20, Sterling Augustine <saugustine@google.com> wrote:
> On Mon, May 7, 2012 at 6:44 PM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
>> On Mon, May 7, 2012 at 7:10 PM, Sterling Augustine
>> <saugustine@google.com> wrote:
>>> This is the second in the series of patches to make c decl pretty printing
>>> more closely match the demangler. A full explanation is here:
>>>
>>> http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00512.html
>>>
>>> OK for mainline?
>>
>> Now I realize something that is wrong with the previous patch.
>> Writing 'const T*' in C++ is very much wide spread style is also the
>> style used in the C++ standard, TC++PL (the de facto popular reference TC++PL),
>> our own C++ standard library implementation, and many popular modern
>> C++ textbooks.
>> It is a strongly well established style.
>> Changing the pretty printer to satisfy the demangler as opposed to users
>> look wrong headed.
>
> I'm most definitely not trying to satisfy the demangler--I'm trying to
> make GCC's naming consistent with the rest of the tool chain, which
> will be good for users. Consider the C++ function:
>
> int foo(const char *bar);
>
> The problem is that the toolchain disagrees on the canonical
> pretty-name of this function. If you use nm, objdump, or readelf, or
> anything that must recover the name from the binary, you will see:
>
> int foo(char const*)
>
> The demangler follows the documented gnu_v3 demangling convention. As
> far as I can tell, the C++ front end is ad-hoc. This disagreement
> creates inconsistencies in the debugging information that is confusing
> to users.
>
> Do you have a suggestion for fixing the disagreement? I would love to
> add this as a parameter somewhere, but the decision is very deep in
> the internals of the pretty printer.

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.

Cheers,

Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]