I have several Watch Expressions that I am following through a debug session. However, I noticed that some of the expressions were not updating as they should have in the code. I confirmed this by doing a command line gdb session (which is the same debugger that I am using in CDT: gdb/mi).
All I was following were simple indices in nested for loops, just like below:
for ( int i = 0; i<num_rows; i++ )
{
<code> for ( int j = 0; j < 4; j++ )
{
<code>
}
}
"i" and "j" were not updating properly in the Expressions view.
I am running eclipse Galileo with CDT Version 6.0.0.200909110608 in a Linux environment. Any idea why the above occurs? Does a later version of CDT solve the problem?
Yes, there are some optimizer options set for the gcc compiler in the Makefile.
If optimization is turned you will get funny results during debug. Because the compiler might rearrange your code and omit some variables. I guess the second loop in your example with constant length of 4 will be completely replaced in the optimized code.