I don't program on windows, but it looks like cygwin maybe includes gdb:
Debugging Cygwin Programs
Anyway, you can install gdb on windows. Try opening a terminal (the one that cygwin uses) and type "gdb -v".
If it's there you're all set. I would say the first thing you want to do is set a breakpoint at this line:
Code:
nsteps = 200; /* simulate for a total of 2.0 sec */
step = 0.010; /* time between samples */
break #
where # is the line number. Now:
run
when it gets to the breakpoint:
print nsteps
it will certainly be 200 at this point. After that just keep using "next" (debugging is often tedious) to proceed to the next instruction. If your linked objects do not have debugging symbols* compiled, you may descend into those function calls and get some ???, ignore this (probably this won't happen with "next", it only happens with "step"). Keep using print nsteps at each line of your own code** (you do not have to keep typing "next" and "print" -- just enter to repeat, and there is a history, so you can use the up arrow to go back to a previous command, so all you need to do is use the up arrow and enter).
Eventually you'll find where nsteps value has mysteriously changed.
* you do need to compile with debugging options on for your own code.
** you may want to skip loops by setting another break lower down and then use cont to go straight to the next breakpoint.