http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61071
Bug ID: 61071
Summary: With certain configurations of variables on function's
stack, when debugging 32bit binary compiled with
'-fsanitize=address', some variables in gdb are
printed out as '<optimized out>' despite passing '-O0
-ggdb3' in compilation switches.
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: athantor+gccbugzilla at athi dot pl
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
Created attachment 32739
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32739&action=edit
testcase
Description:
With certain configurations of variables on function's stack, when debugging
32bit binary compiled with '-fsanitize=address', some variables in gdb are
printed out as '<optimized out>' despite passing '-O0 -ggdb3' in compilation
switches.
Problem occurres (for me) only when debugging 32bit binary; same code in 64bit
works OK. It doesn't matter if I'm cross compiling it 64b→32b nor if I compile
it natively on i386 version of Arch.
It was working OK with gcc <4.9.
Additional info:
Linux kk 3.14.2-1-ARCH #1 SMP PREEMPT Sun Apr 27 11:28:44 CEST 2014 x86_64
GNU/Linux
gcc 4.9.0
gdb 7.7
glibc 2.19
binutils 2.24
Steps to reproduce:
1) Compile attached source file with
gcc -m32 -Wall -Wextra -Wno-unused-variable -fsanitize=address -ggdb3 -O0 -o
test test.c
2) gdb it with:
gdb --ex 'b main' --ex 'r' --ex 'p d' --ex 'q' ./test
If you'll compile with ASAN, gdb will show that variable 'd' is optimized out
despite '-O0' in gcc switches:
Breakpoint 1, main () at test.c:10
10 int d = 4;
$1 = <optimized out>
remove '-fsanitize=address' from switches and gdb works as it should (ignore
uninitialized value):
Breakpoint 1, main () at test.c:10
10 int d = 4;
$1 = 134513883
What's funny, if I'll remove zeroing of the 't' array or decrease its size to
36B, then gdb starts to print 'd' OK.
In both cases debug info about the 'd' variable seems to be present in the
binary:
<2><be>: Abbrev Number: 8 (DW_TAG_variable)
<bf> DW_AT_name : d
<c1> DW_AT_decl_file : 1
<c2> DW_AT_decl_line : 11
<c3> DW_AT_type : <0x53>