public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yangyibiao at hust dot edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/95377] New: inconsistent behaviors at -O1
Date: Wed, 27 May 2020 22:07:38 +0000	[thread overview]
Message-ID: <bug-95377-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95377

            Bug ID: 95377
           Summary: inconsistent behaviors at -O1
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at hust dot edu.cn
  Target Milestone: ---

Created attachment 48622
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48622&action=edit
a.out

$ gcc --version
gcc (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 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.


$ gdb --version
GNU gdb (GDB) 10.0.50.20200517-git
Copyright (C) 2020 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.

Consider test-case:
...
$ cat small.c
char *pa;

void access (volatile char *ptr) {
  *ptr = 'x';
}

int main () {
  char a;
  pa = &a;
  access (pa);
  return 0;
}


...

When stepping through the program by using "stepi"
...
$ gcc -O1 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401106: file small.c, line 9.
(gdb) r
Starting program: /home/yibiao/Debugger/a.out 

Breakpoint 1, main () at small.c:9
9         pa = &a;
(gdb) stepi
0x000000000040110b      9         pa = &a;
(gdb) 
access (ptr=0x7fffffffdf07 "") at small.c:4
4         *ptr = 'x';
(gdb) 
main () at small.c:11
11        return 0;
(gdb)
...

/**********************************************
As showed, when stepping with stepi, Line 10 is skipping over. While using
step, Line 10 is hit by gdb as follow:
***********************************************/

When stepping through the program by using step:
...
$ gcc -O1 -g small.c
$ gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401106: file small.c, line 9.
(gdb) r
Starting program: /home/yibiao/Debugger/a.out 

Breakpoint 1, main () at small.c:9
9         pa = &a;
(gdb) step
10        access (pa);
(gdb) 
access (ptr=0x7fffffffdf07 "") at small.c:4
4         *ptr = 'x';
(gdb) 
main () at small.c:11
11        return 0;
(gdb)


Considering that this might be caused by gdb, I also submit a bug report to gdb
as inspired by Tom de Vries :
https://sourceware.org/bugzilla/show_bug.cgi?id=26057

                 reply	other threads:[~2020-05-27 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-95377-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).