SolarBear
SolarBear

Reputation: 4619

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 constness of the parameter ? I find it strange that GDB would not even give me an address I could look at.

Thank you !

Upvotes: 4

Views: 2337

Answers (2)

Michael Burr
Michael Burr

Reputation: 340366

-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.

Upvotes: 4

Seth Robertson
Seth Robertson

Reputation: 31461

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

Upvotes: 2

Related Questions