EvoCorp Home    Delphi::Advance

 

 

   

 

Creating your own
Just in Time Debugger
Note: As presented, this code will only work under the WinNT/XP environments.
The Windows 9x environment registers just in time debugger information in Win.Ini, not the system registry. Therefore some minor modifications will be needed to automate registration on the Windows 9x platform.

So, what is Just in Time debugging?

Just-in-time, or JIT debugging is where an application crashes while not running under a debugger, and the system arranges to start up an available debugger in order to obtain a more information regarding what went wrong within the application.

For example, have you ever been running an application when all of a sudden the following window has popped up?

At this point the chances are that anything you've been doing within the application is considered "lost" and clicking on the Cancel button opens a thing called "Dr. Watson" (or for those of you with Delphi, Delphi).

When a program throws an unhandled exception the system automatically invokes the debugger specified in the registry for post-mortem debugging. In the case of Dr. Watson, it attaches itself to the application that crashed, generates a crash dump file and closes the application down. Applications that are able to report on, or debug unhandled exceptions in other applications are known as just in time debuggers.

JitDebugger shows you how to create a basic JIT reporting tool. Because JitDebugger represents an AeDebug process it cannot be run as a standalone application except for server registration and deregistration. Needless to say then that JitDebugger must be registered prior to testing the application.

Registering JitDebugger
  Registration
 
  JitDebugger /regserver
This registers JitDebugger as the default AeDebug JIT application, backing up existing JIT debugger information.
  Deregistration
 
  JitDebugger /unregserver
This removes JitDebugger from being the AeDebug JIT application, and restores the original JIT debugger and it's startup state (where applicable).

More Information

For more information on debugging unmanaged Win32 applications, please refer to this MSDN article.

Requirements

  • Delphi 6 minimum
    (This application can probably be compiled under earlier versions of Delphi without any problems, however I haven't been able to test this myself)
  • An unmanaged environment always helps, as .NET contains it's own ICorXxxx interfaces for exception handling and application profiling.

Download

The code for this article can be downloaded here.

Microsoft Internet Explorer is a registered trademark of Microsoft Corporation.