http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53793
Bug #: 53793
Summary: [ARM] Debug info is wrong at optimization level -O1
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: shafi...@gmail.com
Compiler:
Arm linaro
Target: arm-none-eabi
Configured with:
/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/src/gcc/configure
--build=i686-linux-gnu --host=i686-pc-mingw32 --target=arm-none-eabi
--prefix=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/install-mingw
--enable-languages=c,c++ --disable-decimal-float --disable-libffi
--disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-lto --disable-nls
--disable-shared --disable-threads --disable-tls --with-gnu-as
--with-gnu-ld --with-headers=yes --with-newlib
--with-sysroot=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/install-mingw/arm-none-eabi
--with-libiconv-prefix=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-gmp=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-mpfr=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-mpc=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-ppl=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-cloog=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-libelf=/home/rat031/arm_gcc_051612/gcc-arm-none-eabi-4_6-2012q1-20120316/build-mingw/host-libs/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic
-lm' --with-pkgversion='GNU Tools for ARM Embedded Processors'
--with-extra-multilibs=armv6-m,armv7-m,armv7e-m,armv7-r
Thread model: single
gcc version 4.6.2 20120316 (release) [ARM/embedded-4_6-branch revision
185452] (GNU Tools for ARM Embedded Processors)
invocation line:
arm-none-eabi-gcc -Wl,-Map=output.map -mcpu=cortex-m0 -mthumb
-specs=rdimon.specs -lrdimon -lc -lrdimon test.c -g3 -gdwarf-2 -O1 -o
test.elf --save-temps -dA
Code:
void variables_local();
int main(void)
{
variables_local();
return 0;
}
void variables_local()
{
volatile int SizeOfInt = sizeof (int);
volatile int lint = 1024;
volatile float lfloat = 55.55f;
volatile double ldouble = 222.222;
volatile long llong = 123456789;
volatile unsigned luint = 256;
volatile char lchar = 'a';
volatile char *lstring = "hello";
volatile char mlarray[8] = "testing";
return;
}
gdb output:
Breakpoint 1, main () at test.c:14
14 variables_local();
(gdb) s
variables_local () at test.c:22
22 volatile int SizeOfInt = sizeof (int);
(gdb) s
23 volatile int lint = 1024;
(gdb) p SizeOfInt
$1 = 39211
(gdb) s
24 volatile float lfloat = 55.55f;
(gdb) p lint
$2 = 0
(gdb) s
25 volatile double ldouble = 222.222;
(gdb) p lfloat
$3 = 5.60519386e-045
(gdb) s
26 volatile long llong = 123456789;
(gdb) p ldouble
$4 = 518831996932.39624
(gdb) s
27 volatile unsigned luint = 256;
(gdb) p llong
$5 = 1080805146
(gdb) s
28 volatile char lchar = 'a';
(gdb) p luint
$6 = 2680059593
(gdb) s
30 volatile char mlarray[8] = "testing";
(gdb) p lchar
$7 = 97 'a'
(gdb) s
32 }
(gdb) p lchar
$8 = 159 'Y'
(gdb) p lint
$9 = 0
(gdb) p luint
$10 = 2680059593
(gdb)
Issue:
I think dwarf info generated doesn't take into account the push/pop instruction
variables_local:
.LFB1:
.file 1 "../Sources/main.c"
@ ../Sources/main.c:21
.loc 1 21 0
.cfi_startproc
push{r4, lr}
.LCFI0:
.cfi_def_cfa_offset 8
.cfi_offset 4, -8
.cfi_offset 14, -4
@ basic block 2
sub sp, sp, #16
.LCFI1:
.cfi_def_cfa_offset 24
@ ../Sources/main.c:22
.loc 1 22 0
mov r3, #4
str r3, [sp, #12]
.LVL0:
I see that in prologue/epilogue push/pop instructions are directly emitted on
to output file using asm_print, rather than into the rtl steam. Hence the dwarf
info generation code is not aware of such instructions.