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/30344] inconsistent variable values for source-level and instruction-level stepping
Date: Mon, 17 Apr 2023 09:09:59 +0000	[thread overview]
Message-ID: <bug-30344-4717-05u4DHV79j@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30344-4717@http.sourceware.org/bugzilla/>

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |NOTABUG
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Yibiao Yang from comment #0)
> /**********************************
> We can found that, when stepping to source code of line 8, these local
> variables has different values. 
> **********************************/

But you haven't stepped to the same location (to be precise, the same pc) in
both cases.

In one case, using step, you've stepped to the start of line 8.

In the other case using stepi, you've stepped until hitting the first insn that
is part of line 8.

You should continue stepi-ing until you hit the same location, at which point
you'll see the same values:
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x400430: file small.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdce8) at small.c:6
6         char c[] = "%i";
(gdb) si
0x0000000000400434      6         char c[] = "%i";
(gdb) 
0x0000000000400439      7         unsigned char uc[] = "%i";
(gdb) 
0x000000000040043e      9         const unsigned char cuc[] = "%i";
(gdb) 
0x0000000000400443      8         const char cc[] = "%i";
(gdb) 
0x0000000000400448      6         char c[] = "%i";
(gdb) 
0x000000000040044d      11        __builtin_sprintf(buf, (char *)c, 1);
(gdb) 
0x0000000000400452      11        __builtin_sprintf(buf, (char *)c, 1);
(gdb) 
0x0000000000400454      7         unsigned char uc[] = "%i";
(gdb) 
0x0000000000400459      11        __builtin_sprintf(buf, (char *)c, 1);
(gdb) 
0x000000000040045e      9         const unsigned char cuc[] = "%i";
(gdb) 
0x0000000000400463      11        __builtin_sprintf(buf, (char *)c, 1);
(gdb) 
0x0000000000400468      8         const char cc[] = "%i";
(gdb) si
0x000000000040046d      6         char c[] = "%i";
(gdb) 
7         unsigned char uc[] = "%i";
(gdb) 
8         const char cc[] = "%i";
(gdb) info locals
buf = "\000\000\000\000\000\000\000\000\000"
c = "%i"
uc = "%i"
cc = "%i\377"
cuc = "%i\177"
(gdb) print /x $pc
$1 = 0x400477
...

Using print /x $pc, we can verify that it is indeed the same location:
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x400430: file small.c, line 6.
Starting program: /data/vries/gdb/a.out 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdce8) at small.c:6
6         char c[] = "%i";
(gdb) s
7         unsigned char uc[] = "%i";
(gdb) 
8         const char cc[] = "%i";
(gdb) p /x $pc
$1 = 0x400477
...

AFAICT, there's no bug in gcc and no bug in gdb.

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

      parent reply	other threads:[~2023-04-17  9:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  8:30 [Bug gdb/30344] New: " yangyibiao at nju dot edu.cn
2023-04-13  8:31 ` [Bug gdb/30344] " yangyibiao at nju dot edu.cn
2023-04-13 12:38 ` yangyibiao at nju dot edu.cn
2023-04-14  3:00 ` yangyibiao at nju dot edu.cn
2023-04-17  9:09 ` vries at gcc dot gnu.org [this message]

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-30344-4717-05u4DHV79j@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).