Debugging Functions

Name Description
Diagnostic Functions
AssertKindOf AssertKindOf asserts that the specified object is of the specified type or inherits from that type. If this is not the case the function triggers an assertion failure. The overloaded procedure allows you to directly specify a class type instead of a class name.
Trace Trace sends the specified message to the debugger.
TraceFmt TraceFmt sends a message, formatted from the supplied format string and arguments array, to the debugger. The function uses the VCL Format() function to format the string and therefore you can use this function exactly like you would use Format(). See the Delphi help file for more information.
TraceLoc TraceLoc sends the specified message to the debugger but first prepends it with the source file location from which TraceLoc is called. For example, when calling TraceLoc from a method called TForm1.Button1Click located in unit1.pas like this: TraceLoc('Trace me.') the resulting string sent to the debugger will be: unit.pas:123 (TForm1.ButtonClick) "Trace me." assuming the TraceLoc statement is on line 123 in the source. Note that this function requires a detailed map file!
TraceLocFmt TraceFmt sends a message, formatted from the supplied format string and arguments array, to the debugger, but first prepends it with the source file location information. The function uses the VCL Format() function to format the string and therefore you can use this function exactly like you would use Format(). See the Delphi help file for more information. See TraceLoc for an example output.
Except Frame Info Routines
TJclExceptFrame (Class) TJclExceptFrame holds information on an except frame.
Function CodeLocation determines the location of the code for non efkOnException frames. The Delphi linker sometimes adds a JMP-instruction that jumps to handler. With this method you'll always get the location of the handler, inspite of a JMP- instruction being inserted or not.
Function HandlerInfo checks if an exception would be handled by the frame and where the handler is located. An efkFinally frame will never handle an exception (although the code would be executed). efkUnknown frames are assumed to handle the exception (there's no way of knowing for sure) as are efkAnyException and efkAutoException frames. For efkOnException the handler table is scanned to check for an appropiate handler.
TJclExceptFrameList (Class) TJclExceptFrameList holds a list of except frame items.
JclCreateExceptFrameList JclCreateExceptFrameList creates a list of all try...except and / or try...finally frames currently set. The resulting TJclExceptFrameList is also stored internally and can be obtained again by calling JclLastExceptFrameList.
JclLastExceptFrameList JclLastExceptFrameList retreives the last generated except frame list by a call through JclCreateExceptFrameList. Note that JclCreateExceptFrameList also get's called when an exception occurs and the global variable ExceptionFrameTrackingEnable is set to True.
Exception Hooking
JclExceptionsHooked JclExceptionsHooked determines if exceptions are currently hooked.
JclHookExceptions JclHookExceptions enables exception hooking. After a succesful call, all exceptions will be routed through an internal handler first. Note that to actually get notified of exceptions you should set at least one of the notify event variables to your own handler. Additionally you can also enable stack tracking and / or except frame tracking to occur automatically on any exception.
JclUnhookExceptions JclUnhookExceptions disables the exception hooking.
Miscellaneous
EnableCrashOnCtrlScroll EnableCrashOnCtrlScroll enables crashing Windows 2000 using the keyboard. After this has been enabled you can bugcheck Windows 2000 by holding down the right control key and pressing the scroll key twice. On the second press Windows will bugcheck with code 0x000000E2. Note that this function simply modifies a registry entry, to actually enable this 'feature' you must reboot first.
IsDebuggerAttached The IsDebuggerAttached function determines whether the calling process is running under the context of a debugger. Unlike the IsDebuggerPresent API function, this one also functions correctly under Windows 95.
IsHandleValid The IsHandleValid determines whether a handle is valid. The handle can point to any kind of Win32 object such as a file, mutex or console screen buffer. Note that the result of this function is only an indication of whether the handle points to a valid object. Since handles are reused by Win32 it is possible that the handle actually points to a different object than you thought. More reason to always set handles to 0 or INVALID_HANDLE_VALUE immediately after you close it.
Source Locations
__FILE__ __FILE__ returns the name of the source file in which the routine specified by Level exists. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
__FILE_OF_ADDR__ __FILE_OF_ADDR__ returns the name of the source code file given an address.
__LINE__ __LINE__ returns the line number within the source code file at which the routine specified by Level is currently executing. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
__LINE_OF_ADDR__ __LINE_OF_ADDR__ returns the line number in a source code file given an address.
__MAP__ __MAP__ combines the __FILE__, __MODULE, __PROC__ and __LINE__ routines into a single call.
__MAP_OF_ADDR__ __MAP_OF_ADDR__ combines the __FILE_OF_ADDR__, __MODULE_OF_ADDR__, __PROC_OF_ADDR__ and __LINE_OF_ADDR__ routines into a single call.
__MODULE__ __MODULE__ returns the name of the unit in which the routine specified by Level exists. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
__MODULE_OF_ADDR__ __MODULE_OF_ADDR__ returns the name of the module given an address.
__PROC__ __PROC__ returns the name of the procedure at the specified Level. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
__PROC_OF_ADDR__ __PROC_OF_ADDR__ returns the name of the procedure given an address.
Caller Caller returns the address of the calling routine at the specified level. Specifying level 0 results in the currently executing routine, level 1 results in the caller of the currently executing routine, level 2 results in the caller of the caller of the, well, you get the picture. The returned address is the address of the instruction at which execution continues when the function(s) return.
ClearLocationData ClearLocationData clears the list of debug information items created so far. All routines that request location information use this list. If many request for many different modules have been made, this could consume a lot of memory. By clearing the list, the memory is release, but items will be added for any location request made later on.
FileByLevel FileByLevel returns the name of the source file in which the routine specified by Level exists. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
FileOfAddr FileOfAddr returns the name of the source code file given an address.
GetLocationInfo GetLocationInfo returns a TJclLocationInfo structure for the specified address.
IsSystemModule IsSystemModule checks if the specified module is part of the current application. It does so by searching the list at LibModuleList (see Delphi Help).
GetLocationInfoStr GetLocationInfoStr returns location info in a formatted string. The string is formatted as: [Address] UnitName.ProcedureName (Line linenumber, "source file name"
LineByLevel returns the line number within the source code file at which the routine specified by Level is currently executing. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
LineOfAddr returns the line number in a source code file given an address.
MapByLevel MapByLevel combines the FileByLevel, ModuleByLevel, ProcByLevel and LineByLevel routines into a single call.
MapOfAddr combines the __FILE_OF_ADDR__, __MODULE_OF_ADDR__, __PROC_OF_ADDR__ and __LINE_OF_ADDR__ routines into a single call.
ModuleByLevel returns the name of the unit in which the routine specified by Level exists. Level 0 denotes the currently executing routine, 1 denotes the caller of the routine, 2 the caller of the caller, etc.
ModuleFromAddr TODO
ModuleOfAddr ModuleOfAddr returns the name of the module given an address.
Binary Debug Data
ConvertMapFileToJdbgFile ConvertMapFileToJdbgFile convert the specified text based map file to a Jcl binary debug file.
MinutesToMSecs MinutesToMSecs converts Minutes to milliseconds. The maximum value for Minutes is asserted to Minutes smaller than MaxInt / 60 / 1000
TJclBinDebugGenerator (Class) TJclBinDebugGenerator translates the text based map file created by the linker into a smaller, binary version. The result is saved in a memory stream.
TJclBinDebugScanner (Class) TJclBinDebugScanner is like the TJclMapScanner except that it scans a binary map file. The binary file can be generated from a text-based map file by instantiating a TJclBinDebugGenerator-object and saving the DataStream to a file.
TJclMapParser TJclMapParser is a class for a generic MAP-file parser. Items are reported to the user through event calls
TJclMapScanner TJclMapScanner is a map file scanner. The class scans the map file and holds the result for later reference
TJclDebugInfoBinary TJclDebugInfoBinary is the class to hold location information by scanning a Jcl binary debug data resource. It uses a TJclBinDebugScanner object to do so.
TJclDebugInfoExports TJclDebugInfoExports is the class to hold location information by scanning a Borland export header for the PE-image. It uses a TJclPeBorImage object to do so.
TJclDebugInfoList TJclDebugInfoList holds a list of TJclDebugInfoSource items requested. Items are created when needed, not when the list is created.
TJclDebugInfoMap TJclDebugInfoMap is the class to hold location information by scanning a text-based map file. It uses a TJclMapScanner object to do so.
TJclDebugInfoSource TJclDebugInfoSource is an abstract base class to hold location information. Instances of descendants are created by the TJclDebugInfoList-object.
Stack Info Routines
JclCreateStackList JclCreateStackList creates a list of all stack frames. The resulting TJclStackInfoList is also stored internally and can be obtained again by calling JclLastExceptStackList.
JclLastExceptStackList JclLastExceptStackList retreives the last generated stack info list by a call through JclCreateStackList. Note that JclCreateStackList also get's called when an exception occurs and the global variable StackTrackingEnable is set to True.
TJclStackInfoItem TStackInfoItem holds stack information.
TJclStackInfoList TStackInfoList holds a list of stack information items