public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Diego Novillo <dnovillo@google.com>
Cc: Mark Mitchell <mark@codesourcery.com>,
	Robert Dewar <dewar@adacore.com>,
	        Ian Lance Taylor <iant@google.com>,
	        Richard Guenther <richard.guenther@gmail.com>,
	gcc-patches@gcc.gnu.org,         gcc@gcc.gnu.org
Subject: Re: Designs for better debug info in GCC
Date: Sat, 15 Dec 2007 22:51:00 -0000	[thread overview]
Message-ID: <ory7bv3adb.fsf@oliva.athome.lsd.ic.unicamp.br> (raw)
In-Reply-To: <4756B02D.9010302@google.com> (Diego Novillo's message of "Wed\, 05 Dec 2007 09\:05\:33 -0500")

On Dec  5, 2007, Diego Novillo <dnovillo@google.com> wrote:

> On 11/25/07 3:43 PM, Mark Mitchell wrote:

>> My suggestion (not as a GCC SC member or GCC RM, but just as a fellow
>> GCC developer with an interest in improving the compiler in the same way
>> that you're trying to do) is that you stop writing code and start
>> writing a paper about what you're trying to do.
>> 
>> Ignore the implementation.  Describe the problem in detail.  Narrow its
>> scope if necessary.  Describe the success criteria in detail.  Ideally,
>> the success criteria are mechanically checkable properties: i.e., given
>> a C program as input, and optimized code + debug information as output,
>> it should be possible to algorithmically prove whether the output is
>> correct.

> Yes, please.  I would very much like to see an abstract design
> document on what you are trying to accomplish.

Other than the ones I've already posted, here's one:

http://dwarfstd.org/Dwarf3Std.php

Seriously.  There is a standard for this stuff.  My ultimate goal in
this project is that we comply with it, at least as far as emitting
debug information for location of variables is concerned.

Here are some relevant postings on design strategies, rationales and
goals:

http://gcc.gnu.org/ml/gcc/2007-11/msg00229.html (goals)
http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00160.html (initial plan)
http://gcc.gnu.org/ml/gcc/2007-11/msg00261.html (detailed plan)
http://gcc.gnu.org/ml/gcc/2007-11/msg00317.html (example)
http://gcc.gnu.org/ml/gcc/2007-11/msg00590.html (more example)
http://gcc.gnu.org/ml/gcc/2007-11/msg00176.html (design rationale)
http://gcc.gnu.org/ml/gcc/2007-11/msg00177.html (clarification)

> I would like to see exactly what Mark is asking for.  Perhaps a
> presentation in next year's Summit?

Sure, if there's interest, I could sure plan on doing that.  I could
use sponsors, BTW; I haven't discussed this with my employer, and
writing articles and presenting speeches are not part of this
assignment I was given.  Anyhow, by the time of the next year's
Summit, I hope this is mostly old news.

> I don't think I understand the goal of the project.

Follow the standard, as in (1) emit debug information that is correct
(standard-compliant), as in, if we emit some piece of debug
information, it reflects reality, rather than being a sometimes
distant approximation of some past reality long destroyed by some
optimization pass, and (2) emit debug information that is more
complete, as in, we currently fail to emit a lot of debug information
that we could, because we lose track of the location of variables as
optimization passes fail to maintain the needed information to do so.

> "Correct debugging info" means little, particularly if you say that
> it's not debuggers that you are thinking about.

Thinking of the debuggers is a mistake.  We don't think of specific
compilers when reading a programming language standard.  We don't
think of specific processors when reading an ISA or ABI specification.
Even when we read documentation specific to a processor, we still
don't think of its internal implementation details in order to write a
compiler for it; even the scheduling properties are abstracted out in
the design specification and optimization guidelines.

When someone finds that the compiler deviates from one of these
standards, we just cite chapter and verse of the relevant standard,
and people see there's a bug.

Why should debug information standards be treated any differently?

> It's certainly worrisome that your implementation seems to be
> intrusive to the point of brittleness.

What part of instrusiveness are you concerned about?  The change of
INSN_P such that it covers DEBUG_INSN_P too in the supported range?
Or the few changes that revert to the original INSN_P, in the few
exceptions in which DEBUG_INSN_P is not to be handled as an INSN?

I've heard this "intrusiveness" argument be pointed out so many times,
by so many people that claim to not have been able to keep up with the
thread, and who claim to have not looked at the patches at all, that
I'm more and more convinced it's just fear of the unknown than any
actual rational evaluation of the impact of the changes.

Seriously.  Have a look at the patches and tell me what in them you
regard as intrusive.

We're talking about infrastructure here, needed to fix GCC's
carelessness about maintaining a mapping between source and
implementation concepts that went on for years and years, while
optimizations were added and debug information was degraded.

At some point you have to face reality and see that such information
isn't kept around by magic, it takes some effort, and this effort is
needed at every location where there are changes that might affect
debug information.  And that's pretty much everywhere.  Even if we had
consistent interfaces to make some changes, such as variable renaming,
substitution, etc, this would only cover a small amount of the data a
debug info generator would need: it needs higher-level information
than that, especially in rtl, where transformations, for historical
reasons, are messier than in the tree IL.

So, the approach I've taken is to use the strength of the problem
against itself: take advantage of the fact that optimizers already
know how to perform transformations they need to do in order to keep
things consistent, and represent debug information in a way that, to
them, will look just like any other use, so they will adjust it
likewise.  And then, on top of that, handle the few exceptions, in
which the optimizer needs to do something cleverer, because the
transformation it performs wouldn't work when say there's more than
one use or so.

> Will every new optimization need to think about debug information
> from scratch and refrain from doing certain transformations?

Refraining from doing certain transformations would be wrong.  We
don't want debug information to affect code generation, and we don't
want it to reduce the amount of optimization you can make.  So, you
optimize away, and if you find that you can't keep track of debug
information, you mark stuff as unavailable, or, most likely, the
safety nets in place will do that for you, rather than taking the
current approach, in which we silently corrupt debug information.

Sure, this might require a little bit more thinking in some
optimizations.  But in my experience fixing up the tree and rtl passes
that needed tweaking, the additional thinking needed is a no-brainer
in most cases; in a few, you have to work a bit harder to keep
information around rather than simply noting it as unavailable.  But
it has never required optimizations to be disabled, and it must not do
so.  In fact, in a few cases, I noticed we were missing trivial
optimizations and fixed them.

> In my simplistic view of this problem, I've always had the idea that
> -O0 -g means "full debugging bliss", -O1 -g means "tolerable
> debugging" (symbols shouldn't disappear, for instance, though they do
> now) and -O2 -g means "you can probably know what line+function you're
> executing".

I've never seen this documented as such, and we've never worked toward
these stated goals.  However, I see that, underlying all of this, we
should be concerned about emitting debug information that is correct,
i.e., never emit information that says the location of FOO is BAR
while it's actually at BAZ.

I've seen many people (including myself, in a distant past) claiming
that imprecise information is better than no information.  I've
learned better.  Debugger information consumers are often equipped
with heuristics to fill in common gaps in debug information.

But if the information is there, and wrong, the heuristics that might
very well have worked are disabled in favor of the incorrect
information, and then the whole system (debuggers, monitors, etc,
along with the program) misbehaves.

And then, even when heuristics don't exist and the information is
gone, it's better to tell the user "I don't know how to get you that"
than to hand it something other than it needs (e.g., an incorrect
variable location).

> But you seem to be addressing other problems.  And it even seems to me
> that you want debugging information that is capable of deconstructing
> arbitrary transformations done by the optimizers.

No.  I don't see where this notion came from, but it appears to be
quite widespread.  Omitting certain pieces of debug information is
almost always correct, since most debug info attributes are optional.
But emitting information that doesn't reflect the program is always
incorrect.

So, if you perform an arbitrary transformation that is too hard to
represent in debug information, that's fine, just throw the
information away.  The debug information might become less complete,
and therefore less useful, but it will at least won't induce errors
elsewhere.

The parallel I draw is that emitting an optional piece of debug
information is like applying an optional optimization.  If it's
correct, and it's not too expensive, go for it.  But if it's going to
get you the wrong output, it's broken, so don't do it.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

  parent reply	other threads:[~2007-12-15 21:41 UTC|newest]

Thread overview: 192+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <or4pg114h5.fsf@oliva.athome.lsd.ic.unicamp.br>
     [not found] ` <84fc9c000711050327x74845c78ya18a3329fcf9e4d2@mail.gmail.com>
2007-11-07  8:03   ` Designs for better debug info in GCC (was: Re: [vta] don't let debug insns get in the way of simple vect reduction) Alexandre Oliva
2007-11-07 16:37     ` Ian Lance Taylor
2007-11-07 21:43       ` Designs for better debug info in GCC Alexandre Oliva
2007-11-07 23:05         ` Ian Lance Taylor
2007-11-07 23:28           ` Daniel Jacobowitz
2007-11-08  0:01           ` Mark Mitchell
2007-11-08  0:28             ` David Edelsohn
2007-11-08  5:01               ` Mark Mitchell
2007-11-08  5:15                 ` Alexandre Oliva
2007-11-08 18:44                   ` Alexandre Oliva
2007-11-23  2:20                 ` Frank Ch. Eigler
2007-11-23  2:30                   ` Richard Guenther
2007-11-23 23:40                     ` Frank Ch. Eigler
2007-11-23 23:56                       ` Alexandre Oliva
2007-11-24 13:52                     ` Robert Dewar
2007-11-08  5:44               ` Alexandre Oliva
2007-11-08 18:37                 ` Alexandre Oliva
2007-11-08 20:51                 ` Andrew Pinski
2007-11-09  1:11                   ` Alexandre Oliva
2007-11-09 11:28                   ` Robert Dewar
2007-11-08  6:39             ` Alexandre Oliva
2007-11-08 19:13               ` Alexandre Oliva
2007-11-08 20:07               ` Mark Mitchell
2007-11-08 20:14                 ` David Daney
2007-11-08 20:41                   ` Mark Mitchell
2007-11-09  9:10                 ` Alexandre Oliva
2007-11-12 10:55                   ` Mark Mitchell
2007-11-12 18:22                     ` Alexandre Oliva
2007-11-12 20:08                       ` Joe Buck
2007-11-24 22:12                         ` Alexandre Oliva
2007-11-24 22:42                           ` Richard Kenner
2007-11-12 22:43                       ` Ian Lance Taylor
2007-11-24  1:44                         ` Alexandre Oliva
2007-11-13 10:50                       ` Mark Mitchell
2007-11-24  4:05                         ` Alexandre Oliva
2007-11-13 15:46                       ` Michael Matz
2007-11-23 23:56                         ` Alexandre Oliva
2007-11-26 18:19                           ` Michael Matz
2007-11-27  7:31                             ` Alexandre Oliva
2007-11-27 18:33                               ` Michael Matz
2007-11-27 20:37                                 ` Alexandre Oliva
2007-11-08 10:11             ` Richard Guenther
2007-11-08  5:14           ` Alexandre Oliva
2007-11-08 18:28             ` Alexandre Oliva
2007-11-08 19:23             ` Ian Lance Taylor
2007-11-09  0:08               ` Alexandre Oliva
2007-11-09  1:26                 ` Ian Lance Taylor
2007-11-09 12:22                   ` Robert Dewar
2007-11-12 12:59                     ` Mark Mitchell
2007-11-12 18:05                       ` Alexandre Oliva
2007-11-12 18:09                         ` Mark Mitchell
2007-11-24  4:31                           ` Alexandre Oliva
2007-11-26  6:10                             ` Mark Mitchell
2007-12-05 14:21                               ` Diego Novillo
2007-12-05 22:10                                 ` Joe Buck
2007-12-15 22:51                                 ` Alexandre Oliva [this message]
2007-12-16  6:27                                   ` Daniel Berlin
2007-12-16 12:47                                     ` Alexandre Oliva
2007-12-17  1:27                                       ` Daniel Berlin
2007-12-17  5:38                                         ` Joe Buck
2007-12-17  8:20                                           ` Geert Bosch
2007-12-18  1:24                                             ` Alexandre Oliva
2007-12-18  2:02                                               ` Joe Buck
2007-12-18  4:40                                                 ` Alexandre Oliva
2007-12-18  7:45                                                   ` Robert Dewar
2007-12-18  7:56                                                     ` Alexandre Oliva
2007-12-18 13:29                                                       ` Robert Dewar
2007-12-18 22:15                                                         ` Alexandre Oliva
2007-12-18  6:16                                               ` Robert Dewar
2007-12-18  8:09                                                 ` Alexandre Oliva
2007-12-17 18:33                                           ` Alexandre Oliva
2007-12-17 17:59                                         ` Alexandre Oliva
2007-12-17 18:02                                           ` Diego Novillo
2007-12-17 20:43                                             ` Alexandre Oliva
2007-12-17 21:20                                               ` Diego Novillo
2007-12-18  1:01                                                 ` Alexandre Oliva
2007-12-18  1:14                                                   ` Diego Novillo
2007-12-18  5:17                                                     ` Alexandre Oliva
2007-12-18  8:06                                                       ` Kai Henningsen
2007-12-18  8:39                                                       ` Alexandre Oliva
2007-12-18 13:15                                                         ` Diego Novillo
2007-12-18 15:06                                                           ` Alexandre Oliva
2007-12-18 16:22                                                         ` Ian Lance Taylor
2007-12-18 16:28                                                           ` Robert Dewar
2007-12-18 16:31                                                             ` Andrew Haley
2007-12-18 16:42                                                               ` Robert Dewar
2007-12-18 17:04                                                                 ` Andrew Haley
2007-12-18 17:12                                                               ` Richard Kenner
2007-12-18 16:32                                                             ` Daniel Jacobowitz
2007-12-18 16:44                                                               ` Robert Dewar
2007-12-19  4:30                                                           ` Alexandre Oliva
2007-12-19 18:41                                                             ` Ian Lance Taylor
2007-12-19 19:00                                                               ` Daniel Jacobowitz
2007-12-19 19:53                                                               ` Janis Johnson
2007-12-19 21:17                                                                 ` Ian Lance Taylor
2007-12-20  6:10                                                                   ` Alexandre Oliva
2007-12-20 16:52                                                                     ` Ian Lance Taylor
2007-12-20 21:38                                                                       ` Alexandre Oliva
2007-12-21  1:54                                                                         ` Ian Lance Taylor
     [not found]                                                                           ` <orprx0izhp.fsf@oliva.atho! me.lsd.ic.unicamp.br>
2007-12-21  2:11                                                                           ` Alexandre Oliva
2007-12-21  3:16                                                                             ` Robert Dewar
2007-12-21  5:10                                                                             ` Ian Lance Taylor
2007-12-21 18:12                                                                               ` Alexandre Oliva
2007-12-21 19:32                                                                                 ` Ian Lance Taylor
2007-12-21 22:46                                                                                   ` Alexandre Oliva
2007-12-22  0:07                                                                                     ` Ian Lance Taylor
2007-12-22  0:09                                                                                       ` Andrew Pinski
2007-12-22  3:16                                                                                         ` Andrew Pinski
2007-12-22 11:44                                                                                           ` Chris Lattner
2007-12-22 21:27                                                                                             ` Ian Lance Taylor
2007-12-23 17:40                                                                                       ` Frank Ch. Eigler
2007-12-22  7:38                                                                                     ` Robert Dewar
2007-12-22 13:33                                                                                     ` Andrew Haley
2007-12-22 17:11                                                                                       ` Robert Dewar
2007-12-31 19:39                                                                           ` Alexandre Oliva
2007-12-20  8:00                                                               ` Alexandre Oliva
2007-12-20  8:01                                                                 ` Alexandre Oliva
2007-12-20 17:02                                                                 ` Ian Lance Taylor
2007-12-31 16:55                                                           ` Richard Guenther
     [not found]                                                             ` <y0my7baigdf.fsf@ton.toronto.redhat.com>
2008-01-01 17:31                                                               ` Richard Guenther
2007-12-18 23:19                                                         ` Daniel Berlin
2007-12-19  6:07                                                           ` Alexandre Oliva
2007-12-19  6:18                                                             ` Daniel Berlin
2007-12-19 16:01                                                               ` Daniel Berlin
2007-12-19 16:29                                                                 ` Andrew MacLeod
2007-12-19 19:25                                                                   ` Daniel Berlin
2007-12-19 20:00                                                                 ` Andrew MacLeod
2007-12-19 20:40                                                                   ` Daniel Berlin
2007-12-19 20:00                                                                 ` Alexandre Oliva
2007-12-19 21:11                                                                   ` Daniel Berlin
2007-12-20  5:16                                                                     ` Alexandre Oliva
2007-12-20 16:44                                                                       ` Ian Lance Taylor
2007-12-20 20:42                                                                         ` Alexandre Oliva
2007-12-19 20:03                                                               ` Alexandre Oliva
2007-12-18 23:31                                                         ` Daniel Berlin
2007-12-19  4:35                                                           ` Alexandre Oliva
2007-12-19 16:12                                                             ` Daniel Berlin
2007-12-19 19:13                                                               ` Alexandre Oliva
2007-12-19 20:11                                                                 ` Daniel Jacobowitz
2007-12-31 14:45                                               ` Richard Guenther
2007-12-16 22:20                                   ` Mark Mitchell
2007-11-09 12:31                   ` Seongbae Park (박성배, 朴成培)
2007-11-09 12:42                     ` Robert Dewar
2007-11-07 17:25     ` Designs for better debug info in GCC (was: Re: [vta] don't let debug insns get in the way of simple vect reduction) Michael Matz
2007-11-07 19:03       ` Designs for better debug info in GCC Alexandre Oliva
2007-11-08 11:22         ` Michael Matz
2007-11-08 15:13           ` Robert Dewar
2007-11-08 16:11             ` H.J. Lu
2007-11-08 16:32             ` Michael Matz
2007-11-08 18:18               ` Alexandre Oliva
2007-11-09 14:23                 ` Michael Matz
2007-11-12 18:17                   ` Alexandre Oliva
2007-11-13 14:22                     ` Michael Matz
2007-11-24  4:58                       ` Alexandre Oliva
2007-11-26 18:10                         ` Michael Matz
2007-11-27  3:48                           ` Alexandre Oliva
2007-11-08 17:48             ` Alexandre Oliva
2007-11-09  2:09               ` Robert Dewar
2007-11-12 17:52                 ` Alexandre Oliva
2007-11-09  2:13               ` Joe Buck
2007-11-09 18:40                 ` Daniel Jacobowitz
2007-11-09 19:02                   ` Robert Dewar
2007-11-08 16:37           ` Alexandre Oliva
2007-11-13  7:52 Steven Bosscher
2007-11-23 23:40 ` Alexandre Oliva
2007-11-24 10:27   ` Steven Bosscher
2007-11-24 15:08     ` Alexandre Oliva
2007-11-24 15:18       ` Richard Kenner
2007-11-24 20:21         ` Alexandre Oliva
2007-11-24 20:48           ` Bernd Schmidt
2007-11-24 22:01             ` Alexandre Oliva
2007-11-24 22:34               ` Richard Guenther
2007-11-25  1:21                 ` Alexandre Oliva
2007-11-25  2:36                   ` Richard Guenther
2007-11-26 11:37                     ` Alexandre Oliva
2007-11-26 12:38                       ` Richard Guenther
2007-11-26 18:10                         ` Alexandre Oliva
2007-11-25  0:20               ` Alexandre Oliva
2007-11-24 21:24           ` Richard Kenner
2007-11-24 21:55             ` Alexandre Oliva
2007-11-25  0:39           ` Robert Dewar
2007-12-15 20:32             ` Alexandre Oliva
2007-12-15 21:41               ` Robert Dewar
2007-11-24 16:07       ` Steven Bosscher
2007-11-24 20:11         ` Alexandre Oliva
2007-11-24 20:46           ` Richard Guenther
2007-11-26 18:36 J.C. Pizarro
2007-11-26 18:55 ` J.C. Pizarro
     [not found] <or4pg114h5.fsf@oliva.athome.lsd.ic.unicamp.br.suse.lists.egcs>
     [not found] ` <orsl1xq4p3.fsf@oliva.athome.lsd.ic.unicamp.br.suse.lists.egcs>
     [not found]   ` <m3ir2t2u57.fsf@localhost.localdomain.suse.lists.egcs>
     [not found]     ` <m3tzmd1209.fsf@localhost.localdomain.suse.lists.egcs>
     [not found]       ` <m34pec1x4k.fsf@localhost.localdomain.suse.lists.egcs>
     [not found]         ` <orwsr8eyz5.fsf@oliva.athome.lsd.ic.unicamp.br.suse.lists.egcs>
     [not found]           ` <m3wsr76hov.fsf@localhost.localdomain.suse.lists.egcs>
     [not found]             ` <or8x3ng5ie.fsf@oliva.athome.lsd.ic.unicamp.br.suse.lists.egcs>
     [not found]               ` <m3r6hf4mw1.fsf@localhost.localdomain.suse.lists.egcs>
     [not found]                 ` <de8d50360712211607h77a0add5h794f6b5781b6491b@mail.gmail.com.suse.lists.egcs>
     [not found]                   ` <de8d50360712211609y643b8affpeb91048dedecbe60@mail.gmail.com.suse.lists.egcs>
     [not found]                     ` <7C283DB3-9716-4B2C-9721-D1F503B91CC4@apple.com.suse.lists.egcs>
     [not found]                       ` <m37ij64mwt.fsf@localhost.localdomain.suse.lists.egcs>
2007-12-23  0:52                         ` Andi Kleen
2007-12-23  1:32                           ` Daniel Jacobowitz
2007-12-23  1:36                             ` Andi Kleen
2007-12-23  5:55                               ` Daniel Jacobowitz

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=ory7bv3adb.fsf@oliva.athome.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=dewar@adacore.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=mark@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    /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).