Author Topic: [solved] how to set a loop counter for debugging?  (Read 6019 times)

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
[solved] how to set a loop counter for debugging?
« on: November 20, 2012, 12:45:55 pm »
Hi all.

If I have a loop, how can I set a counter to process the loop X times? I don't want to manually step through the loop X times. VC++ has an option for this, so does CB also have this option? It is a very convenient way to check the values of variables after a loop has done X times iterations.

EDIT: Basically what I want to do is to set a breakpoint in(or outside) a loop with the condition that the program breaks after X iterations of the loop.

Thanks in advance.
« Last Edit: November 20, 2012, 12:57:37 pm by cbuser2 »

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: how to set a loop counter for debugging?
« Reply #1 on: November 20, 2012, 12:51:12 pm »
edit breakpoint, Ignore count before break

Martin

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: how to set a loop counter for debugging?
« Reply #2 on: November 20, 2012, 12:53:50 pm »
edit breakpoint, Ignore count before break

Thanks. :D

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: how to set a loop counter for debugging?
« Reply #3 on: November 20, 2012, 12:55:00 pm »
See this image:

Also, you can see this manual about conditional breakpoint: http://www.delorie.com/gnu/docs/gdb/gdb_34.html
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: [solved] how make the program break after X iterations of a loop?
« Reply #4 on: November 20, 2012, 12:56:14 pm »
Thanks ollydbg! :)