11

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?

3
  • "and then that executable gets called"? You mean your breakpoints get fired? When you attach, that executable has already been called, that's why you were able to attach. :) Commented Sep 7, 2010 at 0:06
  • Yes,I want to know how my bp get fired. Commented Sep 7, 2010 at 0:07
  • Reading the OP's comment, I see I edited his question poorly. Changed. Commented Sep 7, 2010 at 0:12

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Which is visual studio using,soft or hard?
I'm sure that Visual Studio uses hard breakpoints (I once got the error message: the hardware does not support monitoring the requested number of bytes). Not sure about soft break points, but I assume VS also uses these.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.