How does debugging work in Visual Studio?

前端 未结 1 2001
抹茶落季
抹茶落季 2021-02-14 09:08

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?

相关标签:
1条回答
  • 2021-02-14 09:22

    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.

    0 讨论(0)
提交回复
热议问题