public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma
@ 2011-02-02 16:06 hariharans at picochip dot com
  2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: hariharans at picochip dot com @ 2011-02-02 16:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

           Summary: var tracking produces wrong debug in code where
                    optimization is turned off using pragma
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hariharans@picochip.com


Created attachment 23216
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23216
The source code

In the attached testcase #pragma has been used to turn optimization off (The
file is otherwise compiled at -Os). By turning off optimization, we expected to
be able to get better debug experience. We noticed that the variable n in the
function "fn" takes the following values, if you step through the function.

4 3 0 2 1 5 0 10 -1

which is obviously wrong.

I reckon the problem lies in var-tracking. Our dwarf reader tells me that the
value of "n" could be found in the following places.

        Name: n
        Location:
        [29, 48) : DW_OP_reg1
        [48, 66) : DW_OP_reg4
        [66, 102) : DW_OP_fbreg[-6]
        [102, 112) : DW_OP_reg4

I will attach the address encoded assembly so you can see that var-tracking
gets it wrong. If i compile the whole file at -O0, the dwarf information the
dwarf gets it right.

        Name: n
        Location: DW_OP_fbreg[-6]

In this particular case, adding -fno-var-tracking has the same effect in
correcting the debug information.

I guess there are 2 things that could be done.

1. Find out the problem in var-tracking in this case and fix it.

2. Turn off var-tracking for functions where optimization is turned off using
attributes/pragmas.

Please let me know if you need any other information on this. I tried all my
experiments with master (as of 2-feb-2011). The experiments were conducted on
picochip (picochip-unknown-none target triplet).

Thanks
Hari


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-01-01  7:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
2011-02-02 16:09 ` hariharans at picochip dot com
2011-03-27 14:31 ` aoliva at gcc dot gnu.org
2011-03-27 14:36 ` aoliva at gcc dot gnu.org
2011-06-03  1:42 ` aoliva at gcc dot gnu.org
2011-06-04 10:16 ` aoliva at gcc dot gnu.org
2011-06-04 10:22 ` aoliva at gcc dot gnu.org
2011-11-10 16:40 ` hariharans at picochip dot com
2012-03-25 11:56 ` [Bug debug/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma) aoliva at gcc dot gnu.org
2022-01-01  7:44 ` [Bug middle-end/47590] " pinskia at gcc dot gnu.org

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).