Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

excptdbg.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 excpdbg.c 00008 00009 Abstract: 00010 00011 This module implements an exception dispatcher logging facility 00012 00013 Author: 00014 00015 Kent Forschmiedt (kentf) 05-Oct-1995 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include "ntrtlp.h" 00022 00023 PLAST_EXCEPTION_LOG RtlpExceptionLog; 00024 ULONG RtlpExceptionLogCount; 00025 ULONG RtlpExceptionLogSize; 00026 00027 00028 VOID 00029 RtlInitializeExceptionLog( 00030 IN ULONG Entries 00031 ) 00032 /*++ 00033 00034 Routine Description: 00035 00036 This routine allocates space for the exception dispatcher logging 00037 facility, and records the address and size of the log area in globals 00038 where they can be found by the debugger. 00039 00040 If memory is not available, the table pointer will remain NULL 00041 and the logging functions will do nothing. 00042 00043 Arguments: 00044 00045 Entries - Supplies the number of entries to allocate for 00046 00047 Return Value: 00048 00049 None 00050 00051 --*/ 00052 { 00053 #if defined(NTOS_KERNEL_RUNTIME) 00054 RtlpExceptionLog = (PLAST_EXCEPTION_LOG)ExAllocatePoolWithTag( NonPagedPool, sizeof(LAST_EXCEPTION_LOG) * Entries, 'gbdE' ); 00055 #else 00056 //RtlpExceptionLog = (PLAST_EXCEPTION_LOG)RtlAllocateHeap( RtlProcessHeap(), 0, sizeof(LAST_EXCEPTION_LOG) * Entries ); 00057 #endif 00058 if (RtlpExceptionLog) { 00059 RtlpExceptionLogSize = Entries; 00060 } 00061 } 00062 00063 00064 ULONG 00065 RtlpLogExceptionHandler( 00066 IN PEXCEPTION_RECORD ExceptionRecord, 00067 IN PCONTEXT ContextRecord, 00068 IN ULONG_PTR ControlPc, 00069 IN PVOID HandlerData, 00070 IN ULONG Size 00071 ) 00072 /*++ 00073 00074 Routine Description: 00075 00076 Records the dispatching of exceptions to frame-based handlers. 00077 The debugger may inspect the table later and interpret the data 00078 to discover the address of the filters and handlers. 00079 00080 Arguments: 00081 00082 ExceptionRecord - Supplies an exception record 00083 00084 ContextRecord - Supplies the context at the exception 00085 00086 ControlPc - Supplies the PC where control left the frame being 00087 dispatched to. 00088 00089 HandlerData - Supplies a pointer to the host-dependent exception 00090 data. On the RISC machines this is a RUNTIME_FUNCTION record; 00091 on x86 it is the registration record from the stack frame. 00092 00093 Size - Supplies the size of HandlerData 00094 00095 Returns: 00096 00097 The index to the log entry used, so that if the handler returns 00098 a disposition it may be recorded. 00099 00100 --*/ 00101 { 00102 #if !defined(NTOS_KERNEL_RUNTIME) 00103 00104 return 0; 00105 00106 #else 00107 00108 ULONG LogIndex; 00109 00110 if (!RtlpExceptionLog) { 00111 return 0; 00112 } 00113 00114 ASSERT(Size <= MAX_EXCEPTION_LOG_DATA_SIZE * sizeof(ULONG)); 00115 00116 do { 00117 LogIndex = RtlpExceptionLogCount; 00118 } while (LogIndex != (ULONG)InterlockedCompareExchange( 00119 (PLONG)&RtlpExceptionLogCount, 00120 ((LogIndex + 1) % MAX_EXCEPTION_LOG), 00121 LogIndex)); 00122 00123 // 00124 // the debugger will have to interpret the exception handler 00125 // data, because it cannot be done safely here. 00126 // 00127 00128 RtlCopyMemory(RtlpExceptionLog[LogIndex].HandlerData, 00129 HandlerData, 00130 Size); 00131 RtlpExceptionLog[LogIndex].ExceptionRecord = *ExceptionRecord; 00132 RtlpExceptionLog[LogIndex].ContextRecord = *ContextRecord; 00133 RtlpExceptionLog[LogIndex].Disposition = -1; 00134 00135 return LogIndex; 00136 #endif // !NTOS_KERNEL_RUNTIME 00137 } 00138 00139 00140 VOID 00141 RtlpLogLastExceptionDisposition( 00142 ULONG LogIndex, 00143 EXCEPTION_DISPOSITION Disposition 00144 ) 00145 /*++ 00146 00147 Routine Description: 00148 00149 Records the disposition from an exception handler. 00150 00151 Arguments: 00152 00153 LogIndex - Supplies the entry number of the exception log record. 00154 00155 Disposition - Supplies the disposition code 00156 00157 Return Value: 00158 00159 None 00160 00161 --*/ 00162 00163 { 00164 // If MAX_EXCEPTION_LOG or more exceptions were dispatched while 00165 // this one was being handled, this disposition will get written 00166 // on the wrong record. Oh well. 00167 if (RtlpExceptionLog) { 00168 RtlpExceptionLog[LogIndex].Disposition = Disposition; 00169 } 00170 } 00171

Generated on Sat May 15 19:39:57 2004 for test by doxygen 1.3.7