From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3667385480E; Mon, 8 Mar 2021 04:49:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3667385480E From: "jay.krell at cornell dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/99457] New: gcc/gdb -gstabs+ is buggy. Date: Mon, 08 Mar 2021 04:49:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jay.krell at cornell dot edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 04:49:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99457 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 int main() { char a[100] =3D {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] =3D {0}; (gdb) 5 printf("%d\n", a[0]); (gdb) p a $1 =3D "@\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' , "\001", '\000' (gdb) p a[0] $2 =3D 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) =3D> 0x00005555555551eb <+130>: movzbl -0x70(%rbp),%eax 0x00005555555551ef <+134>: movsbl %al,%eax 0x00005555555551f2 <+137>: mov %eax,%esi 0x00005555555551f4 <+139>: lea 0xe09(%rip),%rdi # 0x55555555= 6004 0x00005555555551fb <+146>: mov $0x0,%eax 0x0000555555555200 <+151>: callq 0x555555555070 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] =3D {0}; (gdb) 5 printf("%d\n", a[0]); (gdb) p a $1 =3D '\000' =