[ Reported here ( https://sourceware.org/pipermail/gdb-patches/2023-April/198927.html ), without reproducer. ] Consider mockup functions foo and bar: ... 00000000004004b2 <foo_label>: 4004b2: c7 45 f8 02 00 00 00 movl $0x2,-0x8(%rbp) 00000000004004b9 <bar_label>: 4004b9: c7 45 f4 03 00 00 00 movl $0x3,-0xc(%rbp) 00000000004004c0 <bar_end>: ... with line info: ... INDEX LINE REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END 0 22 0x00000000004004b2 0x00000000004004b2 Y 1 26 0x00000000004004b9 0x00000000004004b9 Y Y 2 END 0x00000000004004c0 0x00000000004004c0 Y ... When setting a breakpoint on foo, we get: ... (gdb) break foo Breakpoint 1 at 0x4004b9: file $src, line 26. ... In other words, the breakpoint was set in bar instead. With the fix from aforementioned patch, we have instead: ... Breakpoint 1 at 0x4004b2: file $src, line 22. ...
Created attachment 14837 [details] Patch with dwarf assembly reproducer
Reproduced with trunk and gdb-13-branch. Doesn't reproduce with gdb-12-branch (executed manually, test-case doesn't compile that far back): ... $ gdb -q -batch dw2-prologue-end-2 -ex "b foo" -ex "print &foo_label" Breakpoint 1 at 0x4004b2: file $src, line 22. $1 = (void (*)()) 0x4004b2 <foo> ... which is not surprising because prologue_end support was only added in gdb 13.
Submitted v3: https://sourceware.org/pipermail/gdb-patches/2023-April/198967.html
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a88ee931eee4ba7339c481735b9405f66161e2f6 commit a88ee931eee4ba7339c481735b9405f66161e2f6 Author: WANG Rui <r@hev.cc> Date: Sat Apr 22 07:50:08 2023 +0200 gdb: Fix false match issue in skip_prologue_using_linetable [ Changes in v2: - rebase on trunk Changes in v3: - add test-case ] We should exclude matches to the ending PC to prevent false matches with the next function, as prologue_end is located at the end PC. <fun1>: 0x00: ... <-- start_pc 0x04: ... 0x08: ... <-- breakpoint 0x0c: ret <fun2>: 0x10: ret <-- end_pc | prologue_end of fun2 Tested on x86_64-linux. Co-Authored-By: WANG Rui <r@hev.cc> (fix, tiny change [1]) Co-Authored-By: Tom de Vries <tdevries@suse.de> (test-case) Approved-by: Kevin Buettner <kevinb@redhat.com> [1] https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html PR symtab/30369 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30369
The gdb-13-branch branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3310ec8b5b6a7578c80a9da81c8357fa9205bba3 commit 3310ec8b5b6a7578c80a9da81c8357fa9205bba3 Author: WANG Rui <r@hev.cc> Date: Sat Apr 22 09:33:45 2023 +0200 gdb: Fix false match issue in skip_prologue_using_linetable [ Changes in v2: - rebase on trunk Changes in v3: - add test-case ] We should exclude matches to the ending PC to prevent false matches with the next function, as prologue_end is located at the end PC. <fun1>: 0x00: ... <-- start_pc 0x04: ... 0x08: ... <-- breakpoint 0x0c: ret <fun2>: 0x10: ret <-- end_pc | prologue_end of fun2 Tested on x86_64-linux. Co-Authored-By: WANG Rui <r@hev.cc> (fix, tiny change [1]) Co-Authored-By: Tom de Vries <tdevries@suse.de> (test-case) Approved-by: Kevin Buettner <kevinb@redhat.com> [1] https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html PR symtab/30369 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30369
Fixed on master, backported to gdb-13-branch.