public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/22057] New: [4.0/4.1 Regression] Poor -O0 debug information for for loops with no initializer
@ 2005-06-14  1:09 ian at airs dot com
  2005-06-14  1:34 ` [Bug debug/22057] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ian at airs dot com @ 2005-06-14  1:09 UTC (permalink / raw)
  To: gcc-bugs

In this simple test case, setting a breakpoint at the start of the second for
loop is ineffective, even when compiling with -O0.

int
main(int argc, char **argv)
{
  int j;
  unsigned char block[6];

  for (j = 0; j < 4; j++)
    block[j] = (unsigned char) j;

  for (; j < 6; j++)
    block[j] = (unsigned char) j;
} 

The second for loop is compiled into code like this:

    goto L1;
  L2:
    block[j] = (unsigned char) j;
    j += 1;
  L1:
    if (j < 6)
      goto L2;

The first goto has no line number information.  The increment to j is marked
with the line of the start of the for loop (as it should be).  The effect is
that if you use gdb on the program and set a breakpoint on the start of the for
loop, that breakpoint will not be hit until the "j += 1" statement is executed,
at which point the loop has already been executed once.  This can be seen in
gdb, or by using objdump -dl.

This would be perfectly understandable when optimizing, of course, but -O0 -g
should support maximum debuggability, and should certainly permit setting a
breakpoint at the start of a loop.  Presumably the fix is to mark the "goto L1"
statement with the appropriate line number.

This works correctly with gcc 3.4.3, which generates different code in any case.

-- 
           Summary: [4.0/4.1 Regression] Poor -O0 debug information for for
                    loops with no initializer
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2005-07-19  6:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-14  1:09 [Bug debug/22057] New: [4.0/4.1 Regression] Poor -O0 debug information for for loops with no initializer ian at airs dot com
2005-06-14  1:34 ` [Bug debug/22057] " pinskia at gcc dot gnu dot org
2005-06-14 13:21 ` [Bug middle-end/22057] " pinskia at gcc dot gnu dot org
2005-07-08  1:39 ` mmitchel at gcc dot gnu dot org
2005-07-13 20:44 ` ian at airs dot com
2005-07-18 23:25 ` cvs-commit at gcc dot gnu dot org
2005-07-19  0:51 ` [Bug middle-end/22057] [4.0 " ian at airs dot com
2005-07-19  6:27 ` cvs-commit at gcc dot gnu dot org
2005-07-19  7:15 ` ian at airs dot com

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