This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/17036] New: breakpoint reported on wrong line number


https://sourceware.org/bugzilla/show_bug.cgi?id=17036

            Bug ID: 17036
           Summary: breakpoint reported on wrong line number
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

If one sets a breakpoint on a line with no debug information, the breakpoint
gets set on the next line, but reported to the user as the line he requested.
This is confusing.

(gdb) break x.cc:8
Breakpoint 1 at 0x400633: file x.cc, line 8.

but 0x400633 really corresponds to line 9, not line 8. It should print
"Breakpoint 1 at 0x400633: file x.cc, line 9."

(gdb) run
Starting program: /tmp/x

Breakpoint 1, main () at x.cc:9
9           g();

Testcase:

void g() {}

int f(int, int) { return 1; }

int main(void) {
  int i = 0, j = 0;
  if (f(i,
        j))
    g();
}

Line number table, compiled with clang:

Line Number Statements:
 Extended opcode 2: set Address to 0x4005d0
 Copy
 Set prologue_end to true
 Special opcode 61: advance Address by 4 to 0x4005d4 and Line by 0 to 1
 Special opcode 175: advance Address by 12 to 0x4005e0 and Line by 2 to 3
 Set prologue_end to true
 Special opcode 215: advance Address by 15 to 0x4005ef and Line by 0 to 3
 Advance PC by constant 17 to 0x400600
 Special opcode 7: advance Address by 0 to 0x400600 and Line by 2 to 5
 Set prologue_end to true
 Special opcode 216: advance Address by 15 to 0x40060f and Line by 1 to 6
 Special opcode 202: advance Address by 14 to 0x40061d and Line by 1 to 7
 Advance PC by constant 17 to 0x40062e
 Special opcode 77: advance Address by 5 to 0x400633 and Line by 2 to 9
 Special opcode 76: advance Address by 5 to 0x400638 and Line by 1 to 10
 Advance PC by 9 to 0x400641
 Extended opcode 1: End of Sequence

disas /m, easier to read:

(gdb) disas /m
Dump of assembler code for function main():
5       int main(void) {
  0x0000000000400600 <+0>:     push   %rbp
  0x0000000000400601 <+1>:     mov    %rsp,%rbp
  0x0000000000400604 <+4>:     sub    $0x10,%rsp
  0x0000000000400608 <+8>:     movl   $0x0,-0x4(%rbp)

6         int i = 0, j = 0;
  0x000000000040060f <+15>:    movl   $0x0,-0x8(%rbp)
  0x0000000000400616 <+22>:    movl   $0x0,-0xc(%rbp)

7         if (f(i,
  0x000000000040061d <+29>:    mov    -0x8(%rbp),%edi
  0x0000000000400620 <+32>:    mov    -0xc(%rbp),%esi
  0x0000000000400623 <+35>:    callq  0x4005e0 <f(int, int)>
  0x0000000000400628 <+40>:    cmp    $0x0,%eax
  0x000000000040062d <+45>:    je     0x400638 <main()+56>

8               j))
9           g();
  0x0000000000400633 <+51>:    callq  0x4005d0 <g()>

10      }
  0x0000000000400638 <+56>:    mov    -0x4(%rbp),%eax
  0x000000000040063b <+59>:    add    $0x10,%rsp
  0x000000000040063f <+63>:    pop    %rbp
  0x0000000000400640 <+64>:    retq

End of assembler dump.

google ref# 15455856

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]