From: Tom de Vries <tdevries@suse.de>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, Jakub Jelinek <jakub@redhat.com>,
Jim Wilson <wilson@tuliptree.org>,
aoliva@redhat.com
Subject: Re: [RFC][debug] Add -fadd-debug-nops
Date: Mon, 16 Jul 2018 15:10:00 -0000 [thread overview]
Message-ID: <0e82c00b-a8fc-9f8a-0115-9f7254e1bde1@suse.de> (raw)
In-Reply-To: <alpine.LSU.2.20.1807161546220.16707@zhemvz.fhfr.qr>
On 07/16/2018 03:50 PM, Richard Biener wrote:
> On Mon, 16 Jul 2018, Tom de Vries wrote:
>
>> Hi,
>>
>> this is an idea that I'm currently playing around with: adding nops in
>> an optimized application with debug info can improve the debug info.
>>
>>
>> Consider f.i. this gdb session in foo of pr54200-2.c (using -Os):
>> ...
>> (gdb) n
>> 26 return a; /* { dg-final { gdb-test . "(int)a" "6" } } */
>> (gdb) p a
>> 'a' has unknown type; cast it to its declared type
>> (gdb) n
>> main () at pr54200-2.c:34
>> 34 return 0;
>> ...
>>
>> The problem is that the scope in which a is declared ends at .LBE7, and the
>> statement .loc for line 26 ends up attached to the ret insn:
>> ...
>> .loc 1 24 11
>> addl %edx, %eax
>> .LVL1:
>> # DEBUG a => ax
>> .loc 1 26 7 is_stmt 1
>> .LBE7:
>> .loc 1 28 1 is_stmt 0
>> ret
>> .cfi_endproc
>> ...
>>
>> This patch fixes the problem (for Og and Os, the 'DEBUG a => ax' is missing
>> for O1 and higher) by adding a nop before the ret insn:
>> ...
>> .loc 1 24 11
>> addl %edx, %eax
>> .LVL1:
>> # DEBUG a => ax
>> .loc 1 26 7 is_stmt 1
>> + nop
>> .LBE7:
>> .loc 1 28 1 is_stmt 0
>> ret
>> .cfi_endproc
>> ...
>>
>> and instead we have:
>> ...
>> (gdb) n
>> 26 return a; /* { dg-final { gdb-test . "(int)a" "6" } } */
>> (gdb) p a
>> $1 = 6
>> (gdb) n
>> main () at pr54200-2.c:34
>> 34 return 0;
>> ...
>>
>> Any comments?
>
> Interesting idea. I wonder if that should be generalized
> to other places
I kept the option name general, to allow for that.
And indeed, this is a point-fix patch. I've been playing around with a
more generic patch that adds nops such that each is_stmt .loc is
associated with a unique insn, but that was embedded in an
fkeep-vars-live branch, so this patch is minimally addressing the first
problem I managed to reproduce on trunk.
> and how we can avoid compare-debug failures
> (var-tracking usually doesn't change code-generation).
>
I could remove the cfun->debug_nonbind_markers test and move the
nop-insertion to a separate pass or some such.
Thanks,
- Tom
next prev parent reply other threads:[~2018-07-16 15:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-16 13:29 Tom de Vries
2018-07-16 13:34 ` Jakub Jelinek
2018-07-16 14:32 ` Tom de Vries
2018-07-17 1:02 ` Alexandre Oliva
2018-07-16 13:50 ` Richard Biener
2018-07-16 15:10 ` Tom de Vries [this message]
2018-07-24 11:30 ` Tom de Vries
2018-07-24 11:35 ` [RFC 1/3, debug] Add fdebug-nops Tom de Vries
2018-07-24 14:59 ` [PATCH, " Tom de Vries
2018-07-24 19:07 ` [RFC 1/3, " Alexandre Oliva
2018-07-24 21:04 ` Tom de Vries
2018-07-26 7:50 ` Alexandre Oliva
2018-07-24 11:37 ` [RFC 2/3, debug] Add fkeep-vars-live Tom de Vries
2018-07-24 11:46 ` Jakub Jelinek
2018-07-24 12:34 ` Tom de Vries
2018-07-24 15:03 ` [PATCH, " Tom de Vries
2018-07-25 11:06 ` Jakub Jelinek
2018-07-25 11:41 ` Richard Biener
2018-07-25 11:47 ` Richard Biener
2018-07-24 19:11 ` [RFC 2/3, " Alexandre Oliva
2018-07-25 11:02 ` Jakub Jelinek
2018-07-26 7:47 ` Alexandre Oliva
2018-07-24 11:38 ` [RFC 3/3, debug] Add fdebug-nops and fkeep-vars-live to Og only Tom de Vries
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=0e82c00b-a8fc-9f8a-0115-9f7254e1bde1@suse.de \
--to=tdevries@suse.de \
--cc=aoliva@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
--cc=wilson@tuliptree.org \
/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).