Problem with __asm { int 3 }

Started by
6 comments, last by tscott1213 21 years, 9 months ago
I am using a modified VERIFY macro to check the HRESULT return values of DirectX calls. The macro uses the following to break into the code: __asm { int 3 } However, I am getting an exception error when I run the program. Specifically, "GAME caused an exception 03H in ..." If I comment out the assembly call the program does not crash. If I use the debugger to execute the program to a point in the code well past the assembly call, the program runs fine and stops (as it should) with a "User breakpoint called from code at ..." message when it reaches the inline assembly call. Thanks Todd
Advertisement
Post the source involving int 3.
---visit #directxdev on afternet <- not just for directx, despite the name
Here is the source for the function called by the macro:

void ReportDirectXError(const char* title, HRESULT r, const char* file, int line, const char* str )
{
char tstr[1024];
char* fail = FAILED(r) ? "failure" : "(no failure)";
const char* hrStr = DXGetErrorString8( r );
sprintf( tstr, "*** %s %s ***\n%s\nreturn code: ''%s''\n%s (line %d)\n", title, fail, str, hrStr, file, line );
OutputDebugString( tstr );

if (FAILED(r))
{
__asm { int 3 }
}
}
Ok, so one of DX calls must be failing. Use the call stack (Alt-7) to see which one.
---visit #directxdev on afternet <- not just for directx, despite the name
If you use int 3 you get a breakpoint, which is what you see. The debugger handles these in Debug mode but not in Release mode. So the DirectX call is failing.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
I''m still a little confused....

1) I am compiling using a ''Debug'' profile so shouldn''t the breakpoint work even if I am not specifically running it from the debugger?

2) Why would the program execute if I comment out the inline assembly call?

3) Can you explain what you mean by the DirectX call is failing?

Thanks for the all the help.
Todd

The breakpoint exception is only caught by the Debugger if it''s attached to your app. If you just run the program you''ll get an unhandled exception.

If you comment it out the code making the breakpoint exception no longer gets run.

For some reason the HRESULT you pass into that function is an error code. You need to check the function that produced the error, and possibly put the HRESULT into the DirectX error lookup utility (comes with the SDK) to find out what happened.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Thank you!

This topic is closed to new replies.

Advertisement