public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17036] New: breakpoint reported on wrong line number
Date: Fri, 06 Jun 2014 21:31:00 -0000	[thread overview]
Message-ID: <bug-17036-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2014-06-06 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 21:31 dje at google dot com [this message]
2014-06-06 21:33 ` [Bug breakpoints/17036] " dje at google dot com
2024-01-08 17:48 ` ssbssa at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-17036-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).