1001010.com

one zero zero one zero one zero dot com
one hundred ten ten dot com
binary representation of ascii 'J' (74) dot com

home code projects photos wiki resumé tombstone ?
Individual Entry Archive: The Experiments of Jason De Arte - Evil Lawn Dart Master, Toy Maker and Professional Software Engineer
« prev: [div] instead of [p]
» next: gmail?
Code | Tuesday
Debugging an Unhanded Exception Filter
Posted by Jason on Tuesday October 26, 2004 03:55 PM  |  Permalink

The crash capturing api is very usefull as a foundation for you're own crash reporting system
WINBASEAPI LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter );.
It allows you to define a callback function to be used as a filter when NO OTHER code or debugger is present to catch the exception.
However that introduces a slight problem - debugging the filter function.
If you're in a debugger, it never gets called
If you're not in a debugger, no amount of assert()'s nor _asm {int 3} lines in the filter function will do any good. It's probably a good thing that it doesn't work anyways - horrible recursion could result.
So how do you debug the undebuggable?
Well, I pop up a message box from the UnhandeledExceptionFilter in debug builds and tell my debugger to attach to the process, set a breakpoint on the line after the MessageBox - and debug away!