Summary


This chapter covered crash handlers, which are exception handlers and unhandled exception filters. Crash handlers allow you to get more information about a crash and provide a better face to the user when your application does have problems. The key to debugging faster is also getting the information you need when confronted with a problem, and crash handlers allow you to do that.

C++ exceptions and SEH exceptions are sometimes confused. The C++ language specification provides C++ exceptions, whereas the operating system provides SEH; the two kinds of exception handling are completely different, though intertwined in the dirty implementation details.

I hope I was able to show you the ugly truth about the love affair with C++ exception handling and make you think twice about using it in your application. With the overhead associated with C++ exception handling, you'll take a performance hit. However, the fact that catch (...) eats SEH errors with the Microsoft compiler implementation means it's one of the most evil constructs you'll ever see in your code. Additionally, _set_se_translator doesn't work as advertised, so you need to avoid it. Even though some C++ and object-oriented purists might find my stance on C++ exception harsh, the only purity that matters in my opinion is shipping high-quality code on time. By avoiding C++ exception handling, you'll achieve the purest code of all.

The magic function that does the work to make crash handlers possible is SetUnhandledExceptionFilter, which allows you to set the final SEH exception filter. The final exception filter allows you to gain control right before the Application Error dialog box pops up so that you can record all sorts of great information about why you crashed. The CrashHandler code presented will make it easier to set unhandled exception filters and will do the hard work of translating the crash information for you so that you can concentrate on the display and the unique parts of your application.

Finally, one of the coolest new APIs around is MiniDumpWriteDump. It has a few idiosyncrasies, but I was able to take care of them and make your minidump creation and subsequent reading as smooth as possible. Armed with minidumps created exactly when you need them, you should be able to solve any problems encountered by your customers.




Debugging Applications for Microsoft. NET and Microsoft Windows
Debugging Applications for MicrosoftВ® .NET and Microsoft WindowsВ® (Pro-Developer)
ISBN: 0735615365
EAN: 2147483647
Year: 2003
Pages: 177
Authors: John Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net