public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/25528] step will stopped at any "asm volatile" statement
Date: Wed, 30 Dec 2020 17:02:58 +0000	[thread overview]
Message-ID: <bug-25528-4717-vdpisCilW6@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-25528-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=25528

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Yibiao Yang from comment #1)
> In current version of GDB, statement with asm volatile will be skipped.
> 
> I was wondering that this is the default behavior of GDB.
> 

Compiling with gcc 9.3.1, and looking at the line info using readline -wL, I
get:
...
CU: small.c:

Line number    Starting address    View    Stmt
4            0x400492               x
5            0x40049c               x
6            0x4004a2               x
6            0x4004a8               x
8            0x4004aa               x
9            0x4004b8               x
9            0x4004c5               x
10           0x4004c9               x
6            0x4004c9       1       x
6            0x4004d4               x
12           0x4004db               x
14           0x4004df               x
14           0x4004e3               x
14           0x4004ed               x
14           0x4004f0               x
...

while we have:
...
$ cat -n small.c
     1  const signed char NM[] = {-1, 0, 1};
     2
     3  __attribute__((noinline)) void f(short delta)
     4  {
     5    short p = 2, s;
     6    for (s = 0; s < 2; s++)
     7    {
     8      p += delta;
     9      if (NM[p] == 0)
    10        asm volatile("");
    11    }
    12  }
    13
    14  void main(void) { f(-1); }
    15
...

So, the line with the asm stmt does have line info, but shares the address with
another entry with another line number.

Using this debugging session, we can see that we do visit the address, but show
line 6 instead of line 10:
...
(gdb) 
9           if (NM[p] == 0)
(gdb) p /x $pc
$1 = 0x4004b8
(gdb) s
6         for (s = 0; s < 2; s++)
(gdb) p /x $pc
$2 = 0x4004c9
(gdb) 
...
which I'd say is a valid interpretation of the line number info.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2020-12-30 17:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-25528-4717@http.sourceware.org/bugzilla/>
2020-12-29  3:33 ` yangyibiao at outlook dot com
2020-12-30 17:02 ` vries at gcc dot gnu.org [this message]
2020-12-30 17:16 ` vries at gcc dot gnu.org

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=bug-25528-4717-vdpisCilW6@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).