
Debug a Failing Application #42
Chapter 5, Debugging
|
165
HACK
—Ben Von Handorf
HACK
#42
Debug a Failing Application Hack #42
Launch the debugger when an application starts to crash.
Just-in-time debugging, or JIT debugging for short, is the ability to attach to
a running program that has failed by throwing an unhandled exception. For
instance, you might be testing an application, but not running the applica-
tion in the debugger, and the application throws an exception. Without JIT
debugging, you would have to try and reproduce the error after restarting
the application in the debugger. With JIT debugging, you can immediately
attach to the program and investigate the exception.
JIT debugging does not have anything to do with Just-in-
time compilation; the abbreviation may mean the same thing
but represents vastly different things. Just-in-time compila-
tion is the part of the Common Language Runtime that com-
piles intermediate language into machine code “just in time”
for the machine to process it. (Literally when you call a
method, the JIT compiler checks to make sure the code for
that method exists; if it does not, then it is compiled from
the IL [Hack #63].)
Using JIT Debugging
Using JIT debugging is pretty simple. When you are running an application
that throws an unhandled exception, you will see the dialog shown in
Figure 5-30.
The Just-in-Time Debugging dialog offers you a number of different debug- ...