When does gdb indicate a variable as "unavailable"?

I'm new to GDB and I haven't found a similar question yet, and my Googling was in vain, so here it goes.

I connect to a remote PowerPC-based board through a COM port using GDB and I hit a breakpoint. Here is my (very edited) GDB session.

(gdb) where #0 WaitForStuff () at graphfile.c:1234 #1 0x00012af4 in WaitForOtherStuff () at graph.c:2345 #2 0x001d0a7c in DrawScreens (DefaultScreenFct=0x2bef02 <DefaultFct>, SecondScreenFct=0x2bef02 <DefaultFct>, DrawBothPages=Variable "DrawBothPages" is not available. [...] (gdb) 

Here is the function declaration in frame # 2:

 void DrawScreens(void (*DefaultScreenFct)(void), void (*SecondScreenFct)(void), const BOOLEAN DrawBothPages); 

This is where I got lost: why is this variable “unavailable” and how can I make it “accessible”? I compiled the program using GCC with the -g3 switch, in case I need more information, but I get the same error. I also removed the -O flag we used. Could this be a BOOLEAN typedef (just a unsigned char )? Or perhaps a parameter const parameter? It is strange to me that GDB did not even give me an address that I could look at.

Thanks!

+4
source share
2 answers

-O enables optimization in GCC (this is equivalent to -O1 ).

You want to use -O0 to disable optimization (and by default).

In addition, PowerPC ABI is likely passing parameters to registers. I don't know if -O0 force GCC to display an argument in the stack's memory location in the function or not.

+4
source

Usually it is in the register and has been reset or smoothed to everything else.

+2
source

All Articles