Skip to main content
added 457 characters in body; edited body
Source Link
user1118321
  • 5k
  • 1
  • 20
  • 25

Is it possible to save partial calculations? If so, you could save out the set of calculations that you know to be good, then reload them during future sessions and continue debugging from there.

If the tests are reproducible, like the 1,058th element of the 99th array of the frobaz always ends up wrong, you could put a watchpoint on that memory location and kick off your calculations. While it's plowing through the slow calculations, you can examine the code manually to see if anything stands out. Eventually, it will stop when that element is modified. From there you can usually see where the bad input is coming from. (Probably a calculation with another bad element, so you get to try again with that element.)

Also, I highly recommend running a static analyzer on your code. It may well point out a problem in the code that you hadn't noticed and point out where the error is coming from. Other tools like valgrind, address sanitizer, etc. also help in this regard.

Edit it occurs to me that you can “freeze the machine” in a way. If you have a virtual machine you can start your app and run the calculations up to the point where you want to start debugging. Save the VMs state. Do your debugging. When you want to return to that state simply restore the VM to where you saved it and begin debugging again. Of course if you change any code you’ll need to run the calcs again up to the point where you want to debug.

Is it possible to save partial calculations? If so, you could save out the set of calculations that you know to be good, then reload them during future sessions and continue debugging from there.

If the tests are reproducible, like the 1,058th element of the 99th array of the frobaz always ends up wrong, you could put a watchpoint on that memory location and kick off your calculations. While it's plowing through the slow calculations, you can examine the code manually to see if anything stands out. Eventually, it will stop when that element is modified. From there you can usually see where the bad input is coming from. (Probably a calculation with another bad element, so you get to try again with that element.)

Also, I highly recommend running a static analyzer on your code. It may well point out a problem in the code that you hadn't noticed and point out where the error is coming from. Other tools like valgrind, address sanitizer, etc. also help in this regard.

Is it possible to save partial calculations? If so, you could save out the set of calculations that you know to be good, then reload them during future sessions and continue debugging from there.

If the tests are reproducible, like the 1,058th element of the 99th array of the frobaz always ends up wrong, you could put a watchpoint on that memory location and kick off your calculations. While it's plowing through the slow calculations, you can examine the code manually to see if anything stands out. Eventually, it will stop when that element is modified. From there you can usually see where the bad input is coming from. (Probably a calculation with another bad element, so you get to try again with that element.)

Also, I highly recommend running a static analyzer on your code. It may well point out a problem in the code that you hadn't noticed and point out where the error is coming from. Other tools like valgrind, address sanitizer, etc. also help in this regard.

Edit it occurs to me that you can “freeze the machine” in a way. If you have a virtual machine you can start your app and run the calculations up to the point where you want to start debugging. Save the VMs state. Do your debugging. When you want to return to that state simply restore the VM to where you saved it and begin debugging again. Of course if you change any code you’ll need to run the calcs again up to the point where you want to debug.

Source Link
user1118321
  • 5k
  • 1
  • 20
  • 25

Is it possible to save partial calculations? If so, you could save out the set of calculations that you know to be good, then reload them during future sessions and continue debugging from there.

If the tests are reproducible, like the 1,058th element of the 99th array of the frobaz always ends up wrong, you could put a watchpoint on that memory location and kick off your calculations. While it's plowing through the slow calculations, you can examine the code manually to see if anything stands out. Eventually, it will stop when that element is modified. From there you can usually see where the bad input is coming from. (Probably a calculation with another bad element, so you get to try again with that element.)

Also, I highly recommend running a static analyzer on your code. It may well point out a problem in the code that you hadn't noticed and point out where the error is coming from. Other tools like valgrind, address sanitizer, etc. also help in this regard.