Debugging in EDK

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?

Reply to
kislo
Loading thread data ...

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

Regards,

John

Reply to
John Williams

[...]

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

Reply to
Brian Drummond

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.