Changes between Version 1 and Version 2 of AssertHowto


Ignore:
Timestamp:
Apr 8, 2010, 11:23:11 AM (15 years ago)
Author:
Till Crueger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AssertHowto

    v1 v2  
    9999    * '''When compiling the program with $NON_GCC_COMPILER and then debugging it, it will unwind the stack. I need the backtrace however to find the bug'''
    100100
    101       The mechanism to preserve the stack is compiler specific. For now only a mechanism that is supported by gcc is implemented, because this compiler is widely used. For other compilers the program is simply exited, and the stack is destroyed. If you need a backtrace and you cannot use gcc you have to figure out a way to have your compiler produce a trap instruction in the program. You might want to use google to find out how to get your compiler to do that. For many compilers a _asm {int 3} is said to work. Also for VC++ the instruction __debugbreak() might produce a trap. Also dividing by zero is a hack that could be used as a last hope if you don't find a way to produce traps with your compiler even after a longer search. If you found a way to handle the traps you can then add the macro DEBUG_BREAK for your compiler and the stack will be preserved.
     101      The mechanism to preserve the stack is compiler specific. For now only a mechanism that is supported by gcc is implemented, because this compiler is widely used. For other compilers the program is simply exited, and the stack is destroyed. If you need a backtrace and you cannot use gcc you have to figure out a way to have your compiler produce a trap instruction in the program. You might want to use google to find out how to get your compiler to do that. For many compilers a _asm {int 3} is said to work. Also for VC++ the instruction {{{__debugbreak()}}} might produce a trap. Also dividing by zero is a hack that could be used as a last hope if you don't find a way to produce traps with your compiler even after a longer search. If you found a way to handle the traps you can then add the macro DEBUG_BREAK for your compiler and the stack will be preserved.
    102102
    103103    * '''I have a portion of the program that should never be executed. How can I assure this using assert. '''