質問

I am trying to debug a little c++ code I wrote.
It has several functions, all in the same c++ file, something like

static void b( int i ) {
     int k = i * 2;
}
static void a( int j ) {
     for( int l = 0; l < j ; l++ ) {
         b( l + j );
     }
}
int main( void ) {
    a( 4 );
    return 0;
}

I compiled the code in debug mode and I put a break point inside function b. The code compiles well and the debugger stops at the breakpoint BUT
when I try to examine the value of local variable k I get

CXX0017: Error: symbol "k" not found

I can see the value of i - the input argument.
Moreover, if I click of the calling function a in the call stack I can examine there both argument variable j and local variable l...

Has anyone ever came across such a wierd situation?

役に立ちましたか?

解決 2

I figured it out: I was dumb enough to corrupt my stack. I did it very elegantly, so I was still able to see the "call stack", but information regarding local variables in a specific frame was corrupted. Handling memory with more care and respect solved this annoying issue.

Thanks John for your effort.

他のヒント

It's likely that k is not constructed when your breakpoint hits and is destroyed before you get a chance to examine it.

Try adding a line of code after where k is being initialized, and break there instead.

static void b( int i ) {
     int k = i * 2;
     bool bk = true; // <== BREAKPOINT HERE
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top