public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/99457] New: gcc/gdb -gstabs+ is buggy.
@ 2021-03-08  4:49 jay.krell at cornell dot edu
  2021-03-08  5:27 ` [Bug debug/99457] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jay.krell at cornell dot edu @ 2021-03-08  4:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99457
           Summary: gcc/gdb -gstabs+ is buggy.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jay.krell at cornell dot edu
  Target Milestone: ---

gcc/gdb -gstabs+ is buggy.
Could be either, I didn't investigate.
The codegen is correct.
That's ok, I didn't really need it, I'll use regular -g.

$ cat 1.c
#include <stdio.h>
int main()
{
        char a[100] = {0};
        printf("%d\n", a[0]);
}

$ gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0

$ gcc -gstabs+ 1.c

 # correct output
$ ./a.out
0

$ gdb --version
GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1

$ gdb ./a.out
(gdb) break main
(gdb) r

Breakpoint 1, main () at 1.c:3
3       {
(gdb) n
4               char a[100] = {0};
(gdb)
5               printf("%d\n", a[0]);
(gdb) p a
$1 =
"@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003\000\000@\003",
'\000' <repeats 11 times>, "\001", '\000' <repeats 49 times>
(gdb) p a[0]
$2 = 64 '@'
(gdb) disas
Dump of assembler code for function main:
   0x0000555555555169 <+0>:     endbr64
   0x000055555555516d <+4>:     push   %rbp
   0x000055555555516e <+5>:     mov    %rsp,%rbp
   0x0000555555555171 <+8>:     sub    $0x70,%rsp
   0x0000555555555175 <+12>:    mov    %fs:0x28,%rax
   0x000055555555517e <+21>:    mov    %rax,-0x8(%rbp)
   0x0000555555555182 <+25>:    xor    %eax,%eax
   0x0000555555555184 <+27>:    movq   $0x0,-0x70(%rbp)
   0x000055555555518c <+35>:    movq   $0x0,-0x68(%rbp)
   0x0000555555555194 <+43>:    movq   $0x0,-0x60(%rbp)
   0x000055555555519c <+51>:    movq   $0x0,-0x58(%rbp)
   0x00005555555551a4 <+59>:    movq   $0x0,-0x50(%rbp)
   0x00005555555551ac <+67>:    movq   $0x0,-0x48(%rbp)
   0x00005555555551b4 <+75>:    movq   $0x0,-0x40(%rbp)
   0x00005555555551bc <+83>:    movq   $0x0,-0x38(%rbp)
   0x00005555555551c4 <+91>:    movq   $0x0,-0x30(%rbp)
   0x00005555555551cc <+99>:    movq   $0x0,-0x28(%rbp)
   0x00005555555551d4 <+107>:   movq   $0x0,-0x20(%rbp)
   0x00005555555551dc <+115>:   movq   $0x0,-0x18(%rbp)
   0x00005555555551e4 <+123>:   movl   $0x0,-0x10(%rbp)
=> 0x00005555555551eb <+130>:   movzbl -0x70(%rbp),%eax
   0x00005555555551ef <+134>:   movsbl %al,%eax
   0x00005555555551f2 <+137>:   mov    %eax,%esi
   0x00005555555551f4 <+139>:   lea    0xe09(%rip),%rdi        # 0x555555556004
   0x00005555555551fb <+146>:   mov    $0x0,%eax
   0x0000555555555200 <+151>:   callq  0x555555555070 <printf@plt>
   0x0000555555555205 <+156>:   mov    $0x0,%eax
   0x000055555555520a <+161>:   mov    -0x8(%rbp),%rdx
(gdb) q

$ gcc -g 1.c
$ gdb ./a.out
(gdb) r

Breakpoint 1, main () at 1.c:3
3       {
(gdb) n
4               char a[100] = {0};
(gdb)
5               printf("%d\n", a[0]);
(gdb) p a
$1 = '\000' <repeats 99 times>

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

end of thread, other threads:[~2021-03-08  9:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08  4:49 [Bug debug/99457] New: gcc/gdb -gstabs+ is buggy jay.krell at cornell dot edu
2021-03-08  5:27 ` [Bug debug/99457] " pinskia at gcc dot gnu.org
2021-03-08  5:29 ` pinskia at gcc dot gnu.org
2021-03-08  8:52 ` jakub at gcc dot gnu.org
2021-03-08  9:26 ` jay.krell at cornell dot edu
2021-03-08  9:58 ` rguenth 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).