I am looking at a crash dump, and an important clue to how this crash occurred may be inside the value of a static variable (an integer in this case) inside a function. The problem is that the function with that static variable is is not in my call stack where the crash occurred so I can't just look at it directly. Is there a way to view the contents of this variable from the debugger from outside the function that declares it?
Edit:
Sample code has been requested
int funcitonWithStaticVar()
{
static int iRetVal;
if (iRetVal == 0)
{
iRetVal = initializeValue();
}
return iRetVal
}
void functionThatCrashes()
{
// Crash occurs in this function. The
// static variable in the other function
// may hold an important clue as to why
}
int foo()
{
functionWithStaticVar();
functionThatCrashes();
}
You can determine the address of the static variable by viewing the disassembly of the function that accesses it.