public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
	Don Breazeal <donb@codesourcery.com>
Subject: Re: -g and -fvar-tracking
Date: Wed, 25 Apr 2018 03:17:00 -0000	[thread overview]
Message-ID: <82374722-60ca-11aa-dd21-bdcca733ffb3@codesourcery.com> (raw)
In-Reply-To: <20180424070547.GU8577@tucnak>

On 04/24/2018 01:05 AM, Jakub Jelinek wrote:
> On Mon, Apr 23, 2018 at 10:15:57PM -0600, Sandra Loosemore wrote:
>> Can somebody remind me why using -g doesn't also enable -fvar-tracking by
>> default?  At least for -g2, which is supposed to emit debug information
>> about local variables?  It seems kind of counterintuitive to me that
>> specifying a -O option enables a pass to collect better debug information
>> but specifying -g to request debuggable code doesn't.  :-S
> 
> Because var-tracking is compile time expensive and for -O0 not needed in
> most cases (variable live in memory).  It would be nice to have only partial
> fast var-tracking for -O0, that would track only variables that don't live
> in memory or say parameters before they are assigned to their slots or
> similarly VLAs before they make it into their slots.  That said, for -O0 it
> would need to be really fast.

Hmmm.  There is a GDB test case (gdb.base/store.c) that is doing:

charest
wack_charest (register charest u, register charest v)
{
   register charest l = u, r = v;
   l = add_charest (l, r);
   return l + r;
}

and expecting l and r to have meaningful debug information.  If GCC 
can't produce it with just -g and that is intentional behavior, then it 
sounds like the GDB test case needs to be either fixed or XFAILed.  The 
specific failure we're seeing is that r's debug information is pointing 
only at its initial location in a call-clobbered register, even though 
it's moved to a different place before the call.  With -fvar-tracking it 
produces better debug information, and with any kind of optimization 
enabled it produces better code.  :-P

> We also have -Og which is supposed to provide good debugging experience
> while optimizing a little, the worst problem with that is that in -Og we
> don't artificially extend lifetime of variables till end of their scope, so
> if some value is not needed after some point in the middle of the scope,
> then if there is no way to compute that value anymore we can't provide the
> value.

TBH I'm personally more inclined to use just -O rather than -Og for 
building code for hand debugging.  But it looks like the GDB testsuite 
builds its test programs with -g only by default.

-Sandra

      reply	other threads:[~2018-04-24 16:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24  7:06 Sandra Loosemore
2018-04-24  7:18 ` Jakub Jelinek
2018-04-25  3:17   ` Sandra Loosemore [this message]

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=82374722-60ca-11aa-dd21-bdcca733ffb3@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=donb@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.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).