Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does debugging work in Visual Studio?

I can attach Visual Studio to an executable, and then my breakpoints get called.

What's going on under the hood? What mechanism allows my breakpoints to fire?

like image 741
user198729 Avatar asked Sep 06 '10 23:09

user198729


People also ask

What does debugging do in Visual Studio?

The Visual Studio debugger helps you observe the run-time behavior of your program and find problems.

What is debugging and how does it work?

Definition: Debugging is the process of detecting and removing of existing and potential errors (also called as 'bugs') in a software code that can cause it to behave unexpectedly or crash. To prevent incorrect operation of a software or system, debugging is used to find and resolve bugs or defects.

What are the 4 stages of debugging?

Isolate the source of the bug. Identify the cause of the bug. Determine a fix for the bug. Apply the fix and test it.


1 Answers

There are two mechanisms that can be used to implement breakpoints:

  • hardware, by setting special registers in the processor. When encountering the instruction indicated in the special registers as breakpoint, an exception is thrown, which is caught by the debugger.
  • software, by replacing instructions by "int 3" instructions (see http://en.wikipedia.org/wiki/INT_(x86_instruction)). The "int 3" instruction also interrupts the flow of the application, which is caught by the debugger. To continue the application, the debugger will temporarily put back the original instruction.

See http://en.wikipedia.org/wiki/Breakpoint for more information.

like image 181
Patrick Avatar answered Oct 24 '22 21:10

Patrick