public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Daniel Berlin <dberlin@dberlin.org>
To: Martin Sebor <msebor@gmail.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Manfred <mx2927@gmail.com>,
	gdb@sourceware.org, 	GCC <gcc@gcc.gnu.org>
Subject: Re: gdb 8.x - g++ 7.x compatibility
Date: Wed, 07 Feb 2018 07:21:00 -0000	[thread overview]
Message-ID: <CAF4BwTVO4Gba3pVBk1Jy0PBRgtO=MymQ_mv=22nnyfZ1ub=BgQ@mail.gmail.com> (raw)
In-Reply-To: <d880fd52-5a88-ddee-03ed-6074cdf1b483@gmail.com>

As the person who, eons ago, wrote a bunch of the the GDB code for this C++
ABI support, and as someone who helped with DWARF support in both GDB and
GCC, let me try to propose a useful path forward (in the hopes that someone
will say "that's horrible, do it this <clearly better way> instead")

Here are the constraints i believe we are working with.

1. GDB should work with multiple DWARF producers and multiple C++ compilers
implementing the C++ ABI
2. There is no canonical demangled format for the C++ ABI
3. There is no canoncial target demangler you can say everyone should use
(and even if there was, you don't want to avoid debugging working because
someone chose not to)
4. You don't want to slow down GDB if you can avoid it
5. Despite them all implementation the same ABI, it's still possible to
distinguish the producers by the producer/compiler in the dwarf info.

Given all that:

GDB has ABI hooks that tell it what to do for various C++ ABIs. This is how
it knows to call the right demangler for gcc v3's abi vs gcc v2's abi. and
handle various differences between them.

See gdb/cp-abi.h

The IMHO, obvious thing to do here is: Handle the resulting demangler
differences with 1 or more new C++ ABI hooks.
Or, introduce C++ debuginfo producer hooks that the C++ ABI hooks use if
folks want it to be separate.

Once the producer is detected, fill in the hooks with a set of functions
that does the right thing.

I imagine this would also clean up a bundle of hacks in various parts of
gdb trying to handle these differences anyway (which is where a lot of the
multiple symbol lookups/etc that are often slow come from.
If we just detected and said "this is gcc 6, it behaves like this", we
wouldn't need to do that)

In case you are worried, you will discover this is how a bunch of stuff is
done and already contains a ball of hacks.

Using hooks would be, IMHO, a significant improvement.



On Mon, Feb 5, 2018 at 7:52 PM, Martin Sebor <msebor@gmail.com> wrote:

> On 02/05/2018 09:59 AM, Simon Marchi wrote:
>
>> On 2018-02-05 11:45, Martin Sebor wrote:
>>
>>> Yes, with auto, the type of the constant does determine the type
>>> of the specialization of the template in the source code.
>>>
>>> In non-type template arguments, and more to the point I was making,
>>> in diagnostics, the suffix shouldn't or doesn't need to be what
>>> distinguishes the type of the template, even with auto.  The part
>>> "with auto IVAL = 10" in the message
>>>
>>>   'void foo<IVAL>::print() [with auto IVAL = 10]':
>>>
>>> would be far clearer if auto were replaced by the deduced type,
>>> say along these lines:
>>>
>>>   'void foo<IVAL>::print() [with int IVAL = 10]':
>>>
>>> rather than relying on the suffix alone to distinguish between
>>> different specializations of the template.  That seems far too
>>> subtle to me.  But I think the diagnostic format is (or should
>>> be) independent of the debug info.
>>>
>>
>> That makes sense.
>>
>> With respect to the suffix, I keep coming back to the reality
>>> that even if GCC were to change to emit a format that GDB can
>>> interpret easily and efficiently, there still are other
>>> compilers that emit a different format.  So the conclusion
>>> that a general solution that handles more than just one format
>>> (at least for non-type template arguments without auto) seems
>>> unescapable.
>>>
>>
>> If there are other compilers we wanted to support for which we can't
>> trust the template format, we could always ignore the template part of
>> DW_AT_name specifically for them.  But since g++ and gdb are part of the
>> same project and are expected to work well and efficiently together, I
>> would have hoped that we could agree on a format so that gdb would not
>> have to do the extra work when parsing a g++-generated file
>> (consequently the same format that libiberty's demangler produces).
>>
>> Given the problem I illustrated in my previous mail, I don't have a
>> general solution to the problem to propose.
>>
>
> Okay, let me talk to Jason to see what he thinks.  I'm open
> to restoring the suffix for the debug info as long as it doesn't
> adversely affect the diagnostics.  I agree that if GCC can help
> make GDB more efficient it's worth putting effort into.  (I do
> still think that GDB should work with other providers besides
> GCC, even if perhaps not necessarily as efficiently.)
>
> Martin
>

  reply	other threads:[~2018-02-07  7:21 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-03  3:17 Roman Popov
2018-02-03  3:57 ` carl hansen
2018-02-03  4:54 ` Simon Marchi
2018-02-03  5:02   ` Roman Popov
2018-02-03  6:43   ` Roman Popov
2018-02-03 14:20   ` Paul Smith
2018-02-03 17:18     ` Roman Popov
2018-02-03 18:36       ` Manfred
2018-02-04  5:01         ` Simon Marchi
2018-02-04 17:09           ` Manfred
2018-02-04 19:17           ` Martin Sebor
2018-02-05  5:07             ` Simon Marchi
2018-02-05  9:16               ` Stephan Bergmann
2018-02-05 10:59                 ` Jonathan Wakely
2018-02-05 16:45               ` Martin Sebor
2018-02-05 16:59                 ` Simon Marchi
2018-02-05 17:44                   ` Roman Popov
2018-02-05 20:08                     ` Jonathan Wakely
2018-02-05 20:10                       ` Roman Popov
2018-02-05 20:12                         ` Jonathan Wakely
2018-02-05 20:17                           ` Roman Popov
2018-02-06  3:52                   ` Martin Sebor
2018-02-07  7:21                     ` Daniel Berlin [this message]
2018-02-07 13:44                       ` Simon Marchi
2018-02-07 15:07                         ` Manfred
2018-02-07 15:16                           ` Jonathan Wakely
2018-02-07 16:19                             ` Manfred
2018-02-07 16:26                         ` Michael Matz
2018-02-07 16:36                           ` Simon Marchi
2018-02-07 16:51                             ` Jonathan Wakely
2018-02-07 17:13                               ` Simon Marchi
2018-02-07 17:08                                 ` Jonathan Wakely
2018-02-07 17:20                                   ` Simon Marchi
2018-02-07 17:30                                     ` Jonathan Wakely
2018-02-07 18:28                                       ` Simon Marchi
2018-02-08 11:26                                         ` Michael Matz
2018-02-08 14:05                                           ` Paul Smith
2018-02-08 14:07                                             ` Jonathan Wakely
2018-02-07 17:31                                     ` Marc Glisse
2018-02-07 17:04                         ` Daniel Berlin
2018-02-07 17:11                           ` Daniel Berlin
2018-02-07 22:00                             ` Nathan Sidwell
2018-02-07 20:29                           ` Tom Tromey
2018-02-08 15:05               ` Richard Biener
2018-03-01 20:18                 ` Roman Popov
2018-03-01 20:26                   ` Andrew Pinski
2018-03-01 21:03                     ` Jason Merrill
2018-03-02 23:06                       ` Roman Popov
2018-03-03  4:01                         ` Roman Popov
2018-03-04  4:28                         ` Daniel Berlin
2018-02-05 11:05             ` Jonathan Wakely
2018-02-07 15:19           ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF4BwTVO4Gba3pVBk1Jy0PBRgtO=MymQ_mv=22nnyfZ1ub=BgQ@mail.gmail.com' \
    --to=dberlin@dberlin.org \
    --cc=gcc@gcc.gnu.org \
    --cc=gdb@sourceware.org \
    --cc=msebor@gmail.com \
    --cc=mx2927@gmail.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).