• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How do I bring up the debugger when code executes?

I have a program that I wrote that works fine when it is run by itself.  I gave it out to a few people who added it to their scripts.  While it doesn't crash it does behave poorly from within scripts.  

What I would like to do is to put some type of statement inside my C program that would cause visual C++ debugger to be brought up so I can start debugging.

Is there such a statement?  I was told this is possible but I can't figure out how to do it.

Thanks,!
0
magdt
Asked:
magdt
  • 2
1 Solution
 
jkrCommented:
>>Is there such a statement?

Yes, it is 'DebugBreak();' or '__asm { int 3};' (both are actually the same). From the docs:

"DebugBreak
The DebugBreak function causes a breakpoint exception to occur in the current process so that the calling thread can signal the debugger and force it to take some action. If the process is not being debugged, the search logic of a standard exception handler is used. In most cases, this causes the calling process to terminate because of an unhandled breakpoint exception.

VOID DebugBreak(VOID)"
0
 
jkrCommented:
BTW, to elaborate: 'int 3' causes the CPU to issue a 'breakpoint' interrupt, which fires up the debugger. The above function does nothing but invoke that statement.
0
 
magdtAuthor Commented:
perfect, thanks for the help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now