简体   繁体   中英

When does gdb mark a variable as “not available”?

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

I'm connecting to a remote PowerPC-based board through a COM port, using GDB, and I've hit a breakpoint. Here's 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 declaration of the function at frame #2:

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

This is where I'm lost: why is this variable "not available" and how could I make it "available"? I've compiled the program using GCC with the -g3 switch just in case I needed more info but I get the same error. I've also removed the -O flag we used. Could it be the BOOLEAN typedef (simply an unsigned char )? Or possibly the const ness of the parameter? I find it strange that GDB would not even give me an address I could look at.

Thank you !

-O turns on optimization in GCC (it's equivalent to -O1 ).

You want to use -O0 to turn optimization off (and is the default).

Also, the PowerPC's ABI probably passes parameters in registers. I don't know if -O0 would cause GCC to mirror the argument onto a stack memory location in the function or not.

Usually it is in a register and which has been flushed or aliased to something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM