https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61237

            Bug ID: 61237
           Summary: gcc puts line number 11 ahead of line number 10 in
                    function call in debug info
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dje at google dot com

I can imagine gcc's trying to be helpful here, but it's not working in this
case (at least in IMHO).
I want to set a breakpoint on line 10, but when I get there line 11 has already
been executed, and by that time it's too late.
[This example is stripped down from the original.]

1       int
2       foo (int a, int b)
3       {
4         return a + b;
5       }
6
7       int
8       main ()
9       {
10        foo (1,
11             -foo (2, 3));
12        return 0;
13      }


$ gdb a.out
(gdb) disas /m main
Dump of assembler code for function main:
9       {
   0x0000000000400484 <+0>:     push   %rbp
   0x0000000000400485 <+1>:     mov    %rsp,%rbp

10        foo (1,
   0x0000000000400497 <+19>:    neg    %eax
   0x0000000000400499 <+21>:    mov    %eax,%esi
   0x000000000040049b <+23>:    mov    $0x1,%edi
   0x00000000004004a0 <+28>:    callq  0x400470 <foo>

11             -foo (2, 3));
   0x0000000000400488 <+4>:     mov    $0x3,%esi
   0x000000000040048d <+9>:     mov    $0x2,%edi
   0x0000000000400492 <+14>:    callq  0x400470 <foo>

12        return 0;
   0x00000000004004a5 <+33>:    mov    $0x0,%eax

13      }
   0x00000000004004aa <+38>:    pop    %rbp
   0x00000000004004ab <+39>:    retq

End of assembler dump.

gdb's attempt at making mixed disassembly output more readable isn't helpful
either.  The thing to note here is that line 11 appears before line 10 in the
code.  Technically, one can argue that that is correct I suppose.  And if that
is the answer, fine.  I'm just filing this so that the answer is written down
somewhere.  I did spend 10 minutes trying to find an existing bug in the
database (which feels like enough - I have to time out at some point), and I
grepped for O0 in the "not a bug" page
https://gcc.gnu.org/bugs/#nonbugs
and didn't find anything.
OTOH, if you want to agree this is a bug, fine by me. :-)

Reply via email to