?
Solved

How do I bring up the debugger when code executes?

Posted on 2003-02-26
3
Medium Priority
?
195 Views
Last Modified: 2010-04-15
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
Comment
Question by:magdt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
ID: 8028073
>>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
 
LVL 86

Expert Comment

by:jkr
ID: 8028116
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
 

Author Comment

by:magdt
ID: 8043243
perfect, thanks for the help.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question