DebugBreak Improvement for x86 Platforms

[Previous] [Next]

I sometimes want to force a breakpoint in my code even when the process is not running under a debugger. You can do this in Windows by having a thread call the DebugBreak function. This function, which resides in Kernel32.dll, lets you attach a debugger to the process. Once the debugger is attached, the instruction pointer is positioned on the CPU instruction that caused the breakpoint. This instruction is contained in the DebugBreak function in Kernel32.dll, so to see my source code I must single-step out of the DebugBreak function.

On the x86 architecture, you perform a breakpoint by executing an "int 3" CPU instruction, so I redefine DebugBreak as this inline assembly language instruction. When my DebugBreak macro is executed, I do not call into Kernel32.dll; the breakpoint occurs right in my code, and the instruction pointer is positioned to the next C/C++ language statement. This improved DebugBreak macro just makes things a little more convenient.



Programming Server-Side Applications for Microsoft Windows 2000
Programming Server-Side Applications for Microsoft Windows 2000 (Microsoft Programming)
ISBN: 0735607532
EAN: 2147483647
Year: 2000
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net