<value optimized out> even with gcc -g -O0

Jan Kratochvil jan.kratochvil at redhat.com
Tue Feb 2 20:18:07 UTC 2010

On Mon, 01 Feb 2010 07:18:26 +0100, Chuck Anderson wrote:
> I'm trying to debug an issue for the upstream author of ocp and am 
> running into an issue where gdb is showing "<value optimized out>" for 
> variables even though I've compiled the program with gcc -g -O0.
> Compiler excerpts:
> gcc -g -O0 -fPIC -Wall -I.././ -I.././gnulib kickload.c -o kickload.o -c
> gcc -g -O0 -fPIC -Wall -I.././ -I.././gnulib compdate.c -o compdate.o -c
> ...
> gcc -g -O0 -fPIC -Wall -I./ -I./gnulib  -o ocp boot/kickload.o -pthread -ldl  goodies/helpc/ocphhc doc/opencp.dox ocp.hlp

If you list also the mixasm.c compilation line you would find:
gcc -g -O0 -fpic -Wall -I.././ -O mixasm.c -o mixasm.o -c

as there is explicit -O in dev/Makefile there.  After removing it getting
a valid dump with no <value optimized out>.

For the -O build found one <value optimized out> as correct and one <value
optimized out> as some bug in either gdb or gcc but that is out of the scope
of this mail thread.  -O0 -g works, NOTABUG.


#0  playmonoi16 (dst=0x71ff90, len=384, ch=0x72bfc0) at mixasm.c:1738
#1  0x00007ffff5d57cc7 in mixPlayChannel (dst=0x71ff90, len=384, ch=0x72bfc0, stereo=0) at mixasm.c:2022
#2  0x00007ffff5d55ba8 in putchn (chn=0x72bfc0, len=384, opt=0) at mix.c:129
#3  0x00007ffff5d55f14 in mixMixChanSamples (ch=0x7fffffffcc00, n=1, s=0x7ffff5d3fcc0, len=384, rate=22050, opt=0) at mix.c:180
#4  0x00007ffff405f312 in getchansample (this=0x7ffff4268a80, ch=9, buf=0x7ffff5d3fcc0, len=384, rate=22050, opt=0) at itplay.c:1817
#5  0x00007ffff4061fcd in itpGetLChanSample (ch=9, buf=0x7ffff5d3fcc0, len=384, rate=22050, opt=0) at itpplay.c:534
#6  0x00007ffff599375a in plDrawScopes () at cpiscope.c:365
#7  0x00007ffff5993fd0 in scoDraw () at cpiscope.c:464
#8  0x00007ffff598add2 in plmpDrawScreen () at cpiface.c:772
#9  0x00007ffff598ae30 in plmpCallBack () at cpiface.c:789
#10 0x00007ffff697be9e in _fsMain (argc=2, argv=0x7fffffffd088) at pfsmain.c:266
#11 0x00007ffff7dcc332 in init_modules (argc=2, argv=0x7fffffffd088) at pmain.c:207
#12 0x00007ffff7dcc472 in _bootup (argc=2, argv=0x7fffffffd088) at pmain.c:237
#13 0x00000000004022e0 in runocp (handle=0x6040d0, argc=2, argv=0x7fffffffd088) at kickload.c:518
#14 0x000000000040243a in main (argc=2, argv=0x7fffffffd088) at kickload.c:568

More information about the devel mailing list