[PATCH v3 0/3] Improve debugging of optimized code

Bernd Edlinger bernd.edlinger@hotmail.de
Sun Sep 5 19:15:05 GMT 2021


This update fixes some merge conflicts against recent master.

The problem this patch tries to resolve is the following:
gcc debug info of optimized code with inlined functions may
contain location infos at the end of an inline range, where the
line number info is from an inlined source code.
clang on the other hand manages to avoid location infos
info at the end of an inline range most of the time.

Therefore the debug experience is sub-optimal since step over
does often appear to step into an inline function, but at the
same time the callstack does not show the inline call frame,
which is very confusing.

This is due to an inherent ambiguity in the dwarf2 debug info,
since line table entries at the end of an inline range might be
either from the inline function or from the calling function.
Part [1/3] does not change the behaviour.
Part [2/3] adds a heuristic to determine if a line table
at the end of an inline range is from the inline function
or from the calling function.
Part [3/3] adjusts the breakpoint position of inlined
subroutines.

As a side-effect of part [2/3] also empty inline ranges
may contain line numbers from the inline function.
This may well be the first sub-range so the breakpoint
position of an inline function may change in some cases.

Part [3/3] fixes this breakpoint position to be at the entry-pc,
instead of using simply the first inline range start position,
which is currently used as the breakpoint position.


Bernd Edlinger (3):
  Introduce a new line table flag is_weak
  Fix range end handling of inlined subroutines
  Fix handling of DW_AT_entry_pc of inlined subroutines

 gdb/block.c                                        |  15 +-
 gdb/buildsym.c                                     | 103 ++++++++++--
 gdb/buildsym.h                                     |   3 +
 gdb/dwarf2/read.c                                  |  98 ++++--------
 gdb/infcmd.c                                       |   3 +-
 gdb/infrun.c                                       |  33 +++-
 gdb/jit.c                                          |   1 +
 gdb/symmisc.c                                      |  10 +-
 gdb/symtab.c                                       |  18 +--
 gdb/symtab.h                                       |   4 +
 gdb/testsuite/gdb.base/empty-inline.c              |  43 +++++
 gdb/testsuite/gdb.base/empty-inline.exp            |  50 ++++++
 gdb/testsuite/gdb.cp/empty-inline.cc               |  33 ++++
 gdb/testsuite/gdb.cp/empty-inline.exp              |  55 +++++++
 gdb/testsuite/gdb.cp/step-and-next-inline.cc       |   6 +
 gdb/testsuite/gdb.cp/step-and-next-inline.exp      | 174 ++++++++-------------
 .../gdb.dwarf2/dw2-out-of-range-end-of-seq.exp     |   4 +-
 gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp       |   6 +-
 gdb/xcoffread.c                                    |   1 +
 19 files changed, 454 insertions(+), 206 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/empty-inline.c
 create mode 100644 gdb/testsuite/gdb.base/empty-inline.exp
 create mode 100644 gdb/testsuite/gdb.cp/empty-inline.cc
 create mode 100644 gdb/testsuite/gdb.cp/empty-inline.exp

-- 
1.9.1


More information about the Gdb-patches mailing list