public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/17036] New: breakpoint reported on wrong line number
@ 2014-06-06 21:31 dje at google dot com
  2014-06-06 21:33 ` [Bug breakpoints/17036] " dje at google dot com
  2024-01-08 17:48 ` ssbssa at sourceware dot org
  0 siblings, 2 replies; 3+ messages in thread
From: dje at google dot com @ 2014-06-06 21:31 UTC (permalink / raw)
  To: gdb-prs

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.


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

* [Bug breakpoints/17036] breakpoint reported on wrong line number
  2014-06-06 21:31 [Bug gdb/17036] New: breakpoint reported on wrong line number dje at google dot com
@ 2014-06-06 21:33 ` dje at google dot com
  2024-01-08 17:48 ` ssbssa at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: dje at google dot com @ 2014-06-06 21:33 UTC (permalink / raw)
  To: gdb-prs

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

dje at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|gdb                         |breakpoints

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


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

* [Bug breakpoints/17036] breakpoint reported on wrong line number
  2014-06-06 21:31 [Bug gdb/17036] New: breakpoint reported on wrong line number dje at google dot com
  2014-06-06 21:33 ` [Bug breakpoints/17036] " dje at google dot com
@ 2024-01-08 17:48 ` ssbssa at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-08 17:48 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org
         Resolution|---                         |FIXED
   Target Milestone|---                         |8.2
             Status|NEW                         |RESOLVED

--- Comment #3 from Hannes Domani <ssbssa at sourceware dot org> ---
Works since gdb-8.2.

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

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

end of thread, other threads:[~2024-01-08 17:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-06 21:31 [Bug gdb/17036] New: breakpoint reported on wrong line number dje at google dot com
2014-06-06 21:33 ` [Bug breakpoints/17036] " dje at google dot com
2024-01-08 17:48 ` ssbssa at sourceware dot 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).