[PATCHv3 0/7] Inline Function Optimised Code Debug Improvements

Andrew Burgess
2025-10-16T17:51:53Z

In v3:

- Rebased to current upstream HEAD. Resolved merged conflicts, and
retested.

- Reread all the patches, and updated / tweaked some of the comment
and commit messages, but no changes to the code other than as
required to fix merge conflicts.

- Updated the tests to take account of changes to the DWARF assembler.

In v2:

- Fixes to the test added in patch (2) to address failures reported
from Linaro CI. The issues all relate to compiling the DWARF
assembler test with `-pie` which is on by default for the Linaro
CI machines. The issues were all DWARF generation issues.

- Rebased series to more recent upstream/master.

---

This series presents some improvements to debugging inline functions,
especially in optimised code.

The first two patches of this series have been posted previously here:

https://inbox.sourceware.org/gdb-patches/cover.1736865029.git.aburgess@redhat.com

This series replaces that earlier work, though the patches are
basically unchanged.

This entire series is an alternative solution to the patches that were
posted here:

https://inbox.sourceware.org/gdb-patches/AS1PR01MB946510286FBF2497A6F03E83E4922@AS1PR01MB9465.eurprd01.prod.exchangelabs.com/

My reasons for writing an alternative patch set can be found in the
commit messages of patches (2) and (7), I'm not going to repeat them
here. However, Bernd, the original patch author, did amazing work
identifying the problems GDB was having, and these patches likely
wouldn't exist without the original patch series, so a big thanks
there.

For reviewing, this series can be considered in 3 parts:

+ Patches (1) and (2) are independent from the rest of the series,
though related in theme. Both these patches could be approved and
merged ahead of remaining work, and do offer an improvement to GDB
on their own.

+ Patches (3), (4), (5), and (6) are refactoring work to support the
last patch. These can be reviewed, but shouldn't be merged until
the last patch is approved.

+ Patch (7) covers the final parts of this work, which deal with
non-empty inline functions.

All thoughts and feedback are welcome.

Thanks,
Andrew

---

Andrew Burgess (7):
gdb: improve line number lookup around inline functions
gdb: handle empty ranges for inline subroutines
gdb: split dwarf line table parsing in two
gdb: move block range recording into its own function
gdb: create address map after parsing all DIE
gdb: record block end addresses while parsing DIEs
gdb: fix-up truncated inline function block ranges

gdb/buildsym.c | 42 +-
gdb/buildsym.h | 13 +-
gdb/dwarf2/cu.h | 7 +
gdb/dwarf2/line-program.c | 120 +++-
gdb/dwarf2/line-program.h | 25 +-
gdb/dwarf2/read.c | 181 +++++-
gdb/symtab.c | 25 +-
gdb/testsuite/gdb.cp/step-and-next-inline.exp | 171 ++++--
.../gdb.dwarf2/dw2-empty-inline-low-high.c | 39 ++
.../gdb.dwarf2/dw2-empty-inline-low-high.exp | 128 ++++
.../gdb.dwarf2/dw2-empty-inline-ranges.c | 54 ++
.../gdb.dwarf2/dw2-empty-inline-ranges.exp | 262 ++++++++
.../gdb.dwarf2/dw2-extend-inline-block.c | 78 +++
.../gdb.dwarf2/dw2-extend-inline-block.exp | 574 ++++++++++++++++++
gdb/testsuite/gdb.dwarf2/dw2-inline-bt.c | 79 +++
gdb/testsuite/gdb.dwarf2/dw2-inline-bt.exp | 227 +++++++
.../gdb.dwarf2/dw2-unexpected-entry-pc.exp | 75 ++-
gdb/testsuite/gdb.opt/empty-inline-cxx.cc | 65 ++
gdb/testsuite/gdb.opt/empty-inline-cxx.exp | 95 +++
gdb/testsuite/gdb.opt/empty-inline.c | 40 ++
gdb/testsuite/gdb.opt/empty-inline.exp | 130 ++++
gdb/testsuite/gdb.opt/inline-bt.c | 28 +
gdb/testsuite/gdb.opt/inline-bt.exp | 119 ++--
23 files changed, 2352 insertions(+), 225 deletions(-)
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-empty-inline-low-high.c
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-empty-inline-low-high.exp
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-empty-inline-ranges.c
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-empty-inline-ranges.exp
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.c
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-extend-inline-block.exp
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-bt.c
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-bt.exp
create mode 100644 gdb/testsuite/gdb.opt/empty-inline-cxx.cc
create mode 100644 gdb/testsuite/gdb.opt/empty-inline-cxx.exp
create mode 100644 gdb/testsuite/gdb.opt/empty-inline.c
create mode 100644 gdb/testsuite/gdb.opt/empty-inline.exp

base-commit: b6753354fbbe7c2c66ae9f452ba7aa049db0fe0c
--
2.47.1