public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <lancelot.six@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <lsix@lancelotsix.com>, Lancelot SIX <lancelot.six@amd.com>
Subject: [PATCH 0/2] Add support for DWARF's prologue_end flag in line-table
Date: Fri, 18 Mar 2022 14:27:31 +0000	[thread overview]
Message-ID: <20220318142733.1097657-1-lancelot.six@amd.com> (raw)

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


             reply	other threads:[~2022-03-18 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 14:27 Lancelot SIX [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220318142733.1097657-1-lancelot.six@amd.com \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).