public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/26057] New: inconsistent behaviors at -O1
@ 2020-05-27 21:17 yangyibiao at hust dot edu.cn
  2021-01-13  8:37 ` [Bug symtab/26057] " yangyibiao at outlook dot com
  2021-01-13 11:35 ` yangyibiao at outlook dot com
  0 siblings, 2 replies; 3+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-27 21:17 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 26057
           Summary: inconsistent behaviors at -O1
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: yangyibiao at hust dot edu.cn
  Target Milestone: ---

Created attachment 12573
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12573&action=edit
a.out

$ 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)

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

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

* [Bug symtab/26057] inconsistent behaviors at -O1
  2020-05-27 21:17 [Bug symtab/26057] New: inconsistent behaviors at -O1 yangyibiao at hust dot edu.cn
@ 2021-01-13  8:37 ` yangyibiao at outlook dot com
  2021-01-13 11:35 ` yangyibiao at outlook dot com
  1 sibling, 0 replies; 3+ messages in thread
From: yangyibiao at outlook dot com @ 2021-01-13  8:37 UTC (permalink / raw)
  To: gdb-prs

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

Yibiao Yang <yangyibiao at outlook dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yangyibiao at outlook dot com

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

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

* [Bug symtab/26057] inconsistent behaviors at -O1
  2020-05-27 21:17 [Bug symtab/26057] New: inconsistent behaviors at -O1 yangyibiao at hust dot edu.cn
  2021-01-13  8:37 ` [Bug symtab/26057] " yangyibiao at outlook dot com
@ 2021-01-13 11:35 ` yangyibiao at outlook dot com
  1 sibling, 0 replies; 3+ messages in thread
From: yangyibiao at outlook dot com @ 2021-01-13 11:35 UTC (permalink / raw)
  To: gdb-prs

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

Yibiao Yang <yangyibiao at outlook dot com> changed:

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

--- Comment #1 from Yibiao Yang <yangyibiao at outlook dot com> ---


(gdb) maint info line-table
objfile: /home/yibiao/DeVIL/a.out ((struct objfile *) 0x55ce857d6f60)
compunit_symtab: ((struct compunit_symtab *) 0x55ce857ce7c0)
symtab: /home/yibiao/DeVIL/small.c ((struct symtab *) 0x55ce857ce840)
linetable: ((struct linetable *) 0x55ce85816fe0):
INDEX  LINE   ADDRESS            IS-STMT 
0      3      0x0000555555555149 Y 
1      3      0x0000555555555149   
2      4      0x000055555555514d Y 
3      4      0x000055555555514d   
4      5      0x0000555555555150   
5      7      0x0000555555555151 Y 
6      7      0x0000555555555159   
7      8      0x0000555555555169 Y 
8      9      0x0000555555555169 Y 
9      9      0x0000555555555169   
10     10     0x0000555555555175 Y 
11     3      0x0000555555555175 Y 
12     4      0x0000555555555175 Y 
13     4      0x0000555555555175   
14     4      0x000055555555517a   
15     11     0x000055555555517a Y 
16     12     0x000055555555517a   
17     END    0x0000555555555199 Y

0x0000555555555175 mapping to Line 10 and Line 3 and 4. 

gdb doesn't support locations views yet, so after collapsing entries with the
same address, we left: 

INDEX  LINE   ADDRESS            IS-STMT 
0      3      0x0000555555555149 Y 
2      4      0x000055555555514d Y 
5      7      0x0000555555555151 Y 
8      9      0x0000555555555169 Y 
12     4      0x0000555555555175 Y 
15     11     0x000055555555517a Y 
17     END    0x0000555555555199 Y

Thus, it is all known behaviour.

*** This bug has been marked as a duplicate of bug 25507 ***

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

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

end of thread, other threads:[~2021-01-13 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 21:17 [Bug symtab/26057] New: inconsistent behaviors at -O1 yangyibiao at hust dot edu.cn
2021-01-13  8:37 ` [Bug symtab/26057] " yangyibiao at outlook dot com
2021-01-13 11:35 ` yangyibiao at outlook dot com

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).