]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb, linespec: avoid multiple locations with same PC
authorKlaus Gerlicher <klaus.gerlicher@intel.com>
Thu, 12 Jun 2025 15:37:50 +0000 (15:37 +0000)
committerKlaus Gerlicher <klaus.gerlicher@intel.com>
Thu, 12 Jun 2025 15:37:50 +0000 (15:37 +0000)
commitc7a45b98a61451f05ff654c4fb72a9c9cb2fba36
treeccd713dda22c86f97a77dcabdc23c2652fc95eee
parentadd73a101f5e8225d4055563c52adaa64c8fb11d
gdb, linespec: avoid multiple locations with same PC

Setting a BP on a line like this would incorrectly yield two BP locations:

01 void two () { {int var = 0;} }

(gdb) break 1
Breakpoint 1 at 0x1164: main.cpp:1. (2 locations)

(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   <MULTIPLE>
1.1                         y   0x0000000000001164 in two() at main.cpp:1
1.2                         y   0x0000000000001164 in two() at main.cpp:1

In this case decode_digits_ordinary () returns two SALs, exactly matching the
requested line.  One for the entry PC and one for the prologue end PC.  This
was
tested with GCC, CLANG and ICPX.  Subsequent code tries to skip the prologue
on these PCs, which in turn makes them the same.

To fix this, ignore SALs with the same PC and program space when adding to the
list of SALs.

This will then properly set only one location:

(gdb) break 1
Breakpoint 1 at 0x1164: file main.cpp, line 1

(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000001164 in two() at main.cpp:1

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/linespec.c
gdb/testsuite/gdb.linespec/linespec.exp
gdb/testsuite/gdb.linespec/lspec.cc