public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: David Blaikie <dblaikie@gmail.com>
To: Andrea Monaco <andrea.monaco@autistici.org>
Cc: gdb <gdb@sourceware.org>
Subject: Re: gdb displaying only one line of instructions when stepping
Date: Tue, 21 Dec 2021 09:21:56 -0500	[thread overview]
Message-ID: <CAENS6EudpGD+52w4GF=DdUQ9MbDy7-u=BRnqkhx1ox1i6Y0=iQ@mail.gmail.com> (raw)
In-Reply-To: <87h7b2gi2h.fsf@autistici.org>

The actual underlying DWARF information that gdb is using to render source
only describes a single line of source - and gdb probably doesn't try to
parse or interpret the source code at all.

I'm not sure about GCC's generated DWARF, but Clang's generated DWARF will
use its AST's "preferred location" as the location of a given instruction.
This is the same location as would be highlighted with a "^" in a Clang
warning or other diagnostic.

eg:

a =
  x +
  y;

The store to 'a' should be attributed to '=' and the add instruction should
be attributed to '+'.

If GCC rendered the column info from the line table, it might make it more
clear? (maybe there's an option to make it do that)

Though ultimately the DWARF format itself would probably need to be
improved to describe source ranges (maybe even non-contiguous ones) and a
preferred location - then then + operation could be described as the whole
range of "x + y" with a specific location of '+', and the assignment could
be the whole range of "a = x + y" with a specific location of '='.

On Tue, Dec 21, 2021 at 9:16 AM Andrea Monaco via Gdb <gdb@sourceware.org>
wrote:

>
> Hello.
>
>
> I noticed that, when single stepping through a program, gdb shows only
> one line of instructions that take more than one.
>
> For example, a simple
>
>   a =
>     5;
>
>
> is showed as
>
>   (gdb) next
>   24        a =
>   (gdb)
>
> As a user, I'd definitely prefer gdb to show me the full instruction I'm
> about to run.
>
>
> Maybe there's some way to do that, and I missed it?  Otherwise I can
> work on it.
>
>
>
> Let me know,
>
> Andrea Monaco
>

  reply	other threads:[~2021-12-21 14:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 14:15 Andrea Monaco
2021-12-21 14:21 ` David Blaikie [this message]
2021-12-21 22:14 Andrea Monaco
2021-12-21 22:54 ` David Blaikie

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='CAENS6EudpGD+52w4GF=DdUQ9MbDy7-u=BRnqkhx1ox1i6Y0=iQ@mail.gmail.com' \
    --to=dblaikie@gmail.com \
    --cc=andrea.monaco@autistici.org \
    --cc=gdb@sourceware.org \
    /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).