As vart shows, it's a simple MessageBox.
Hi Elysia,
As you mentioned, assert in implemented by int 3, but I have not found code in assert (assert.h), which triggers int 3. Any ideas?
Thanks vart,
This is what I found from assert.h.
But it does not contain information as you mentioned, "followed by _DbgBreak", any ideas?Code:#define assert(_Expression) (void)( (!!(_Expression)) || (_wassert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0) )
regards,
George
This is UNICODE version of the same macro I have posted - you should look into the Assert.C file for _wassert function - I soppose It will have exactly the same code as the _assert function I have posted just using the wide-characters versions of string manipulation routines and MessageBox
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Thanks vart,
I have read the related code, it works in the following way,
1. generate and format message;
2. If user select abort, int 3 will be generated;
3. If user selects retry, debug break will be invoked.
My questions,
1. I do not know too much about int 3 and I can not find related information in MSDN and wikipedia, could you explain or recommend some materials about what will happen if we generate int 3 in our program?
2. Interested how debugbreak works. When we invoke this function, what will happen? Goes back to next break point or go back to some place else?
regards,
George
So _DbgBreak macro IS the place where the int 3 is calledCode:#define _DbgBreak() __asm { int 3 }
To read about interrupts - you can use the google search...
http://www.google.co.il/search?num=1....microsoft.com
http://msdn2.microsoft.com/en-us/library/cc266343.aspx
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Thanks vart!
Great resource! I have made some learning, a further confusion.
abort will raise(SIGABRT), i.e. sending signal SIGABRT, is signal SIGABRT the same as int 3 sent by DebugBreak?
http://msdn2.microsoft.com/en-us/library/k089yyh0.aspx
regards,
George
I haven't got the source code here, but I'm 99.9% sure that the code is essentially:
abort() should "quit your program immediately".Code:showerrormessage(); DebugBreak(); abort();
DebugBreak only really makes sense if you have a debugger registered on the system. It is not at all similar to abort(). Instead, it does exactly what it says: Breaks into the debugger, which means that you can for example see the call stack of how you got to the assert (or whatever contained the DebugBreak() call).
Note: In the case of a Windowed application, I believe an assert shows a dialog box that allows the user to "quit" or "debug" [and a third choice, that I don't remember].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
"Ignore", which continues execution (and in the case of assert(), prompty falls into the abort().)
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Thanks Mats and CornedBee,
1.
So abort() and int 3 are two different things. about() will cause program to end and int 3 will search for debugger, right?
2.
I want to test the function of Continue, as mentioned here.
http://msdn2.microsoft.com/zh-cn/lib...y6(en-us).aspx
I have written the following progam, and I expect when click continnue button, we will be able to debug the code in __except block. But, when execute the following code, there is even no dialog displayed to let me select whether or not to use Visual Studio 2008 to debug. Why and how to fix it?
Code:#include "Windows.h" int main() { int a; int b; int c; __try { a = 100; b = 200; c = 300; DebugBreak(); a = 400; } __except(GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { // No debugger is attached, so return FALSE // and continue. return FALSE; } return TRUE; }
regards,
George
So, what happens in your case? Note that if you start from inside the IDE, the application may fall straight back to debugger.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.