Debugging in EDK

Jul 06, 2007 2 Replies

Hi i am debuggin a simple program running on the Spartan3e starter kit :



int main() { int k = 3; int i = 2; int j = 4;



i = k; i = j+j+k; while(i < 15) { j--; i++; } return 0; }



The problem is that the value "k" after i step the first time is initialised to -1 and not 3 !! if i swap "int i = 2" with "int k = 3" then i = -1 and not 2 !! .. the rest of the code can be stepped thourg with no weird behaviour .. what can be the problem?



Make sure you compile the application with debugging symbols on (-g) and no optimisations (-O0).

Regards,

John

[...]

No problem: the compiler knows the value of the constants in "k" or "i", and uses the very basic "constant folding" optimisation, so it never needs to load "k" or "i" with the initial values.

The other post suggested turning the optimisations off; or it may be worth declaring "i" or "k" to be "volatile" to force the to use them (in case they were actually registers in hardware devices)

- Brian

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required