public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30344] New: inconsistent variable values for source-level and instruction-level stepping
@ 2023-04-13  8:30 yangyibiao at nju dot edu.cn
  2023-04-13  8:31 ` [Bug gdb/30344] " yangyibiao at nju dot edu.cn
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: yangyibiao at nju dot edu.cn @ 2023-04-13  8:30 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30344
           Summary: inconsistent variable values for source-level and
                    instruction-level stepping
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

Created attachment 14820
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14820&action=edit
triggering source code of small.c

$ gdb --version
GNU gdb (GDB) 13.0.50.20221107-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ gcc --version
gcc (GCC) 13.0.0 20221107 (experimental)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



$ cat small.c -n
     1  
     2  int main (int argc, char **argv)
     3  {
     4    char buf[10];
     5  
     6    char c[] = "%i";
     7    unsigned char uc[] = "%i";
     8    const char cc[] = "%i";
     9    const unsigned char cuc[] = "%i";
    10  
    11    __builtin_sprintf(buf, (char *)c, 1);
    12    __builtin_sprintf(buf, (char *)uc, 1);
    13    __builtin_sprintf(buf, (char *)cc, 1);
    14    __builtin_sprintf(buf, (char *)cuc, 1); 
    15    __builtin_sprintf(buf, (const char *)L"foo"); 
    16  
    17    return 0;
    18  }


$ gcc -O2 -g small.c


$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x401040: file small.c, line 6.
Starting program: /root/devil/batch/a.out 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffe478) at small.c:6
6         char c[] = "%i";
(gdb) s
7         unsigned char uc[] = "%i";
(gdb) s
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) 


$ gdb -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x401040: file small.c, line 6.
Starting program: /root/devil/batch/a.out 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffe478) at small.c:6
6         char c[] = "%i";
(gdb) si
0x0000000000401044      6         char c[] = "%i";
(gdb) 
0x0000000000401049      7         unsigned char uc[] = "%i";
(gdb) 
0x000000000040104e      9         const unsigned char cuc[] = "%i";
(gdb) 
0x0000000000401053      8         const char cc[] = "%i";
(gdb) info locals
buf = "\000\000\000\000\000\000\000\000\000"
c = "@\000"
uc = "\000\000"
cc = "p\344\377"
cuc = "\377\377\177"
(gdb) 



/**********************************
We can found that, when stepping to source code of line 8, these local
variables has different values. 
**********************************/

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

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

end of thread, other threads:[~2023-04-17  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  8:30 [Bug gdb/30344] New: inconsistent variable values for source-level and instruction-level stepping 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 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).