public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add support for DWARF's prologue_end flag in line-table
@ 2022-03-18 14:27 Lancelot SIX
  2022-03-18 14:27 ` [PATCH 1/2] gdb/buildsym: Line record use a record flag Lancelot SIX
  2022-03-18 14:27 ` [PATCH 2/2] gdb: Add support for DW_LNS_set_prologue_end in line-table Lancelot SIX
  0 siblings, 2 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-03-18 14:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

Hi,

I came across a situation where GDB would fail to properly report a
breakpoint hit.

Lets consider the following simplified example:

    void
    foo ()
    {
      inlined_function ();
    }

In this situation, the user did place a breakpoint in foo ("break foo"),
but when the breakpoint was hit GDB reported the stop to be in
inlined_function.

In the debug information, the foo and inlined_functions have the same
low_pc, but GDB places the breakpoint at a PC higher than that $low_pc.
Therefore, when the breakpoint is hit, the effective PC seems to be
inside inlined_function.  GDB reports that the stop happened in the
inlined function which is not what the user expects.

The underlying issue is of course that the breakpoint is placed at the
wrong PC.  This comes down to an invalid detection of the end of the
prologue of the foo function, which is what this small series fixes.

The program I am interested in is compiled by a LLVM based compiler,
which includes prologue_end markers in the line table information.
Those markers (introduced in DWARF-3) indicate where breakpoints should
be placed to be at the first instruction past the prologue of a
function.  Currently, GDB does not process this information.

This series proposes to implement support for the DWARF prologue_end
flags.  The first patch in the series does some minor refactoring, and
the second patch adds support for the prologue_end flags.

As (as far as I can tell) GCC does not emit those flags, this series has
no effect to debug code produced by this compiler.

The series have been regression tested on upuntu-20.04 x86_64-linux
using:

- make check
- make check RUNTESTFLAGS="CC_FOR_TARGET=clang CXX_FOR_TARGET=clang++"

All feedbacks are welcome,
Best,
Lancelot.

Lancelot SIX (2):
  gdb/buildsym: Line record use a record flag
  gdb: Add support for DW_LNS_set_prologue_end in line-table

 gdb/NEWS                                      |  4 +
 gdb/buildsym-legacy.c                         |  2 +-
 gdb/buildsym.c                                |  5 +-
 gdb/buildsym.h                                | 12 ++-
 gdb/doc/gdb.texinfo                           | 27 ++++++
 gdb/dwarf2/read.c                             | 52 +++++++----
 gdb/symmisc.c                                 |  6 +-
 gdb/symtab.c                                  | 51 +++++++++++
 gdb/symtab.h                                  |  4 +
 .../dw2-out-of-range-end-of-seq.exp           |  4 +-
 gdb/testsuite/gdb.dwarf2/dw2-prologue-end.c   | 28 ++++++
 gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp | 91 +++++++++++++++++++
 gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp  |  2 +-
 gdb/testsuite/lib/dwarf.exp                   | 16 ++--
 14 files changed, 273 insertions(+), 31 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-prologue-end.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp


base-commit: c4d0963383ad8ca0f0bf63c857b9462efdacff7c
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-18 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 14:27 [PATCH 0/2] Add support for DWARF's prologue_end flag in line-table Lancelot SIX
2022-03-18 14:27 ` [PATCH 1/2] gdb/buildsym: Line record use a record flag Lancelot SIX
2022-03-18 14:27 ` [PATCH 2/2] gdb: Add support for DW_LNS_set_prologue_end in line-table Lancelot SIX
2022-03-18 15:11   ` Eli Zaretskii
2022-03-18 16:35     ` Lancelot SIX

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).