Re: gdb problems with -O1 on x86_64 architecture.

Tigran Aivazian
2005-05-10T14:32:52Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1688 bytes --]

Hi,

I thought it is worth showing how it behaves on -O2 compiled binary as
well:

# gcc -g -Wall -O2 -fno-optimize-sibling-calls uvar.c -o uvar-O2

(gdb) b kt_func3
Breakpoint 1 at 0x4004e0: file uvar.c, line 11.
(gdb) r
Starting program: /root/mod/uvar-O2

Breakpoint 1, kt_func3 (x1=0x11111133, x2=0x22222244, x3=0x33333355,
x4=0x44444466, x5=0x55555577, x6=0x66666688,
x7=0x77777799, x8=0x888888aa, x9=0x9566b560) at uvar.c:11
11 return (x1 + x2 + x3/2 + x4/4 + x5/5 + x6/6 + x7/7 + x8/8
+ x9/9);
(gdb) bt
#0 kt_func3 (x1=0x11111133, x2=0x22222244, x3=0x33333355, x4=0x44444466,
x5=0x55555577, x6=0x66666688, x7=0x77777799,
x8=0x888888aa, x9=0x9566b560) at uvar.c:11
#1 0x00000000004005d3 in kt_func2 (x1=<value optimized out>, x2=<value
optimized out>, x3=<value optimized out>,
x4=<value optimized out>, x5=<value optimized out>, x6=<value
optimized out>, x7=0x77777788, x8=0x88888899,
x9=0x999999aa) at uvar.c:16
#2 0x0000000000400623 in kt_func1 (x1=<value optimized out>, x2=<value
optimized out>, x3=<value optimized out>,
x4=<value optimized out>, x5=<value optimized out>, x6=<value
optimized out>, x7=0x77777777, x8=0x88888888,
x9=0x99999999) at uvar.c:22
#3 0x000000000040067a in main (argc=<value optimized out>, argv=<value
optimized out>) at uvar.c:30

As you see, it claims that x1,x2,x3,x4,x5,x6 are optimized out and
x7,x8,x9 are available and shows the correct values. This is for kt_func2
and kt_func1 functions, but for kt_func3 it shows all values correctly
except the last one --- x9 is garbage. But with -O0 it shows everything
correctly.

I attached the -O2 compiled uvar as well.

Kind regards
Tigran

[-- Attachment #2: uvar-O2 --]
[-- Type: APPLICATION/octet-stream, Size: 15978 bytes --]