Announcing Stack Overflow Documentation



Sign up and start helping → Learn more about Documentation →

I recently studied the Windows API functions for debugger implementation. Now I know how you can basically debug a program and read that programs memory.

I also found functions that handle certain "debug events" such as breakpoints (which from my understanding are function calls, that are implanted into the program that is to be debugged by the compiler).

BUT I do not see any functionality that would enable a debugger to step through a program (be it instruction-by-instruction or line-by-line).

I'm really curious about this and any help would be very appreciated !

Thank you in advance !


share|improve this question
1. Create breakpoint at next logical line. 2. Resume execution. 3. Remove breakpoint. – Billy ONeal Jan 23 '14 at 6:03
That would require the debugger to change the programs code (image in memory) after each instruction. I'm looking for something that maybe tells the OS or processor to throw an exception or an interrupt after every instruction. – Rafael Pasquay Jan 23 '14 at 6:11
up vote 3 down vote accepted

The x86 processor has what are known as hardware break-points. Basically, you can set a particular register. When the program counter reaches the value stored in the register, the program is interrupted and control given to the debugger. See this brief description for a better understanding. http://en.wikipedia.org/wiki/X86_debug_register

share|improve this answer
+1 all non-trivial processors have this feature. Cacheing/pipelining/multicore/etc mean that software-only breakpoints are not feasible. – Martin James Jan 23 '14 at 7:34
@MartinJames - Uh-huh, thanks. I didn't know that before, but for the reasons you mentioned it makes perfect sense. I don't even want to imagine the hell that trying to insert INT3's (or equivalent) all of the place in such an environment would be. o_O – enhzflep Jan 23 '14 at 7:41
Thank you! This is what I was looking for. – Rafael Pasquay Jan 23 '14 at 8:34

x86 has TF, Trace Flag. In this mode, every instruction generates an INT 1. This means you don't have to keep adjusting the hardware breakpoint register.

share|improve this answer

Your Answer


