Debuggers run as an endless loop that waits for a debugging event to occur. When a debugging event occurs, the loop breaks, and a corresponding event handler is called.
When an event handler is called, the debugger halts and awaits direction on how to continue. Some of the common events that a debugger must trap are these:
Memory violations (also called access violations or segmentation faults)
Exceptions generated by the debugged program
Each operating system has a different method for dispatching these events to a debugger, which will be covered in the operating system—specific chapters. In some operating systems, other events can be trapped as well, such as thread and process creation or the loading of a dynamic library ...