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

kdtrap.c File Reference

#include "kdp.h"

Go to the source code of this file.

Functions

BOOLEAN KdpTrap (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChance)
BOOLEAN KdIsThisAKdTrap (IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode)
BOOLEAN KdpStub (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChance)


Function Documentation

BOOLEAN KdIsThisAKdTrap IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN KPROCESSOR_MODE  PreviousMode
 

Definition at line 264 of file alpha/kdtrap.c.

References BREAKIN_BREAKPOINT, FALSE, KERNEL_BREAKPOINT, KernelMode, and TRUE.

00272 : 00273 00274 This routine is called whenever a user-mode exception occurs and 00275 it might be a kernel debugger exception (Like DbgPrint/DbgPrompt ). 00276 00277 Arguments: 00278 00279 ExceptionRecord - Supplies a pointer to an exception record that 00280 describes the exception. 00281 00282 ContextRecord - Supplies the context at the time of the exception. 00283 00284 PreviousMode - Supplies the previous processor mode. 00285 00286 Return Value: 00287 00288 A value of TRUE is returned if this is for the kernel debugger. 00289 Otherwise, a value of FALSE is returned. 00290 00291 --*/ 00292 00293 { 00294 00295 // 00296 // Isolate the breakpoint code from the breakpoint instruction which 00297 // is stored by the exception dispatch code in the information field 00298 // of the exception record. 00299 // 00300 00301 // 00302 // Switch on the breakpoint code. 00303 // 00304 00305 switch (ExceptionRecord->ExceptionInformation[0]) { 00306 00307 // 00308 // Kernel breakpoint code. 00309 // 00310 00311 case KERNEL_BREAKPOINT: 00312 case BREAKIN_BREAKPOINT: 00313 #if DEVL 00314 return TRUE; 00315 #else 00316 if (PreviousMode == KernelMode) { 00317 return TRUE; 00318 00319 } else { 00320 return FALSE; 00321 } 00322 #endif 00323 00324 // 00325 // Debug print code. 00326 // 00327 00328 case DEBUG_PRINT_BREAKPOINT: 00329 return TRUE; 00330 00331 // 00332 // Debug prompt code. 00333 // 00334 case DEBUG_PROMPT_BREAKPOINT: 00335 return TRUE; 00336 00337 // 00338 // Debug stop code. 00339 // 00340 00341 case DEBUG_STOP_BREAKPOINT: 00342 #if DEVL 00343 return TRUE; 00344 #else 00345 if (PreviousMode == KernelMode) { 00346 return TRUE; 00347 00348 } else { 00349 return FALSE; 00350 } 00351 #endif 00352 00353 // 00354 // Debug load symbols code. 00355 // 00356 00357 case DEBUG_LOAD_SYMBOLS_BREAKPOINT: 00358 if (PreviousMode == KernelMode) { 00359 return TRUE; 00360 00361 } else { 00362 return FALSE; 00363 } 00364 00365 // 00366 // Debug unload symbols code. 00367 // 00368 00369 case DEBUG_UNLOAD_SYMBOLS_BREAKPOINT: 00370 if (PreviousMode == KernelMode) { 00371 return TRUE; 00372 00373 } else { 00374 return FALSE; 00375 } 00376 // 00377 // All other codes. 00378 // 00379 00380 default: 00381 return FALSE; 00382 } 00383 }

BOOLEAN KdpStub IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame,
IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN KPROCESSOR_MODE  PreviousMode,
IN BOOLEAN  SecondChance
 

Definition at line 386 of file alpha/kdtrap.c.

Referenced by KdDisableDebugger(), and KdInitSystem().

00397 : 00398 00399 This routine provides a kernel debugger stub routine that catchs debug 00400 prints in checked systems when the kernel debugger is not active. 00401 00402 Arguments: 00403 00404 TrapFrame - Supplies a pointer to a trap frame that describes the 00405 trap. 00406 00407 ExceptionFrame - Supplies a pointer to a exception frame that describes 00408 the trap. 00409 00410 ExceptionRecord - Supplies a pointer to an exception record that 00411 describes the exception. 00412 00413 ContextRecord - Supplies the context at the time of the exception. 00414 00415 PreviousMode - Supplies the previous processor mode. 00416 00417 SecondChance - Supplies a boolean value that determines whether this is 00418 the second chance (TRUE) that the exception has been raised. 00419 00420 Return Value: 00421 00422 A value of TRUE is returned if the exception is handled. Otherwise a 00423 value of FALSE is returned. 00424 00425 --*/ 00426 00427 { 00428 00429 ULONG_PTR BreakpointCode; 00430 00431 // 00432 // Isolate the breakpoint code from the breakpoint instruction which 00433 // is stored by the exception dispatch code in the information field 00434 // of the exception record. 00435 // 00436 00437 BreakpointCode = ExceptionRecord->ExceptionInformation[0]; 00438 00439 // 00440 // If the breakpoint is a debug print, debug load symbols, or debug 00441 // unload symbols, then return TRUE. Otherwise, return FALSE; 00442 // 00443 00444 if ((BreakpointCode == DEBUG_PRINT_BREAKPOINT) || 00445 (BreakpointCode == DEBUG_LOAD_SYMBOLS_BREAKPOINT) || 00446 (BreakpointCode == DEBUG_UNLOAD_SYMBOLS_BREAKPOINT) || 00447 (BreakpointCode == KERNEL_BREAKPOINT)) { 00448 ContextRecord->Fir += 4; 00449 return TRUE; 00450 } else { 00451 if ( (BreakpointCode == DEBUG_STOP_BREAKPOINT) && 00452 (PreviousMode == KernelMode) ){ 00453 ContextRecord->Fir += 4; 00454 return TRUE; 00455 } else { 00456 return FALSE; 00457 } 00458 } 00459 } }

BOOLEAN KdpTrap IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame,
IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN KPROCESSOR_MODE  PreviousMode,
IN BOOLEAN  SecondChance
 

Definition at line 28 of file alpha/kdtrap.c.

Referenced by KdInitSystem().

00039 : 00040 00041 This routine is called whenever a exception is dispatched and the kernel 00042 debugger is active. 00043 00044 Arguments: 00045 00046 TrapFrame - Supplies a pointer to a trap frame that describes the 00047 trap. 00048 00049 ExceptionFrame - Supplies a pointer to a exception frame that describes 00050 the trap. 00051 00052 ExceptionRecord - Supplies a pointer to an exception record that 00053 describes the exception. 00054 00055 ContextRecord - Supplies the context at the time of the exception. 00056 00057 PreviousMode - Supplies the previous processor mode. 00058 00059 SecondChance - Supplies a boolean value that determines whether this is 00060 the second chance (TRUE) that the exception has been raised. 00061 00062 Return Value: 00063 00064 A value of TRUE is returned if the exception is handled. Otherwise a 00065 value of FALSE is returned. 00066 00067 --*/ 00068 00069 { 00070 00071 BOOLEAN Completion; 00072 BOOLEAN Enable; 00073 BOOLEAN UnloadSymbols = FALSE; 00074 STRING Input; 00075 ULONGLONG OldFir; 00076 STRING Output; 00077 PKPRCB Prcb; 00078 00079 // 00080 // Enter debugger and synchronize processor execution. 00081 // 00082 00083 // 00084 // If this is a breakpoint instruction, then check to determine if is 00085 // an internal command. 00086 // 00087 00088 if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) && 00089 (ExceptionRecord->ExceptionInformation[0] >= DEBUG_PRINT_BREAKPOINT)){ 00090 00091 // 00092 // Switch on the breakpoint code. 00093 // 00094 00095 switch (ExceptionRecord->ExceptionInformation[0]) { 00096 00097 // 00098 // Print a debug string. 00099 // 00100 // Arguments: 00101 // 00102 // a0 - Supplies a pointer to an output string buffer. 00103 // a1 - Supplies the length of the output string buffer. 00104 // 00105 00106 case DEBUG_PRINT_BREAKPOINT: 00107 ContextRecord->Fir += 4; 00108 Output.Buffer = (PCHAR)ContextRecord->IntA0; 00109 Output.Length = (USHORT)ContextRecord->IntA1; 00110 00111 KdLogDbgPrint(&Output); 00112 00113 if (KdDebuggerNotPresent == FALSE) { 00114 00115 Enable = KdEnterDebugger(TrapFrame, ExceptionFrame); 00116 if (KdpPrintString(&Output)) { 00117 ContextRecord->IntV0 = (ULONG)STATUS_BREAKPOINT; 00118 } else { 00119 ContextRecord->IntV0 = (ULONG)STATUS_SUCCESS; 00120 } 00121 KdExitDebugger(Enable); 00122 00123 } else { 00124 ContextRecord->IntV0 = (ULONG)STATUS_DEVICE_NOT_CONNECTED; 00125 } 00126 00127 return TRUE; 00128 00129 00130 // 00131 // Stop in the debugger 00132 // 00133 // As this is not a normal breakpoint we must increment the 00134 // context past the breakpoint instruction 00135 // 00136 00137 case BREAKIN_BREAKPOINT: 00138 ContextRecord->Fir += 4; 00139 break; 00140 00141 // 00142 // Print a debug prompt string, then input a string. 00143 // 00144 // a0 - Supplies a pointer to an output string buffer. 00145 // a1 - Supplies the length of the output string buffer.. 00146 // a2 - supplies a pointer to an input string buffer. 00147 // a3 - Supplies the length of the input string bufffer. 00148 // 00149 00150 case DEBUG_PROMPT_BREAKPOINT: 00151 ContextRecord->Fir += 4; 00152 Output.Buffer = (PCHAR)ContextRecord->IntA0; 00153 Output.Length = (USHORT)ContextRecord->IntA1; 00154 Input.Buffer = (PCHAR)ContextRecord->IntA2; 00155 Input.MaximumLength = (USHORT)ContextRecord->IntA3; 00156 00157 KdLogDbgPrint(&Output); 00158 00159 Enable = KdEnterDebugger(TrapFrame, ExceptionFrame); 00160 00161 KdpPromptString(&Output, &Input); 00162 00163 ContextRecord->IntV0 = Input.Length; 00164 00165 KdExitDebugger(Enable); 00166 return TRUE; 00167 00168 // 00169 // Load the symbolic information for an image. 00170 // 00171 // Arguments: 00172 // 00173 // a0 - Supplies a pointer to an output string descriptor. 00174 // a1 - Supplies a the base address of the image. 00175 // a2 - Supplies the current process id. 00176 // 00177 00178 case DEBUG_UNLOAD_SYMBOLS_BREAKPOINT: 00179 UnloadSymbols = TRUE; 00180 00181 // 00182 // Fall through 00183 // 00184 00185 case DEBUG_LOAD_SYMBOLS_BREAKPOINT: 00186 Enable = KdEnterDebugger(TrapFrame, ExceptionFrame); 00187 Prcb = KeGetCurrentPrcb(); 00188 OldFir = ContextRecord->Fir; 00189 RtlCopyMemory(&Prcb->ProcessorState.ContextFrame, 00190 ContextRecord, 00191 sizeof(CONTEXT)); 00192 00193 if (KdDebuggerNotPresent == FALSE) { 00194 KdpReportLoadSymbolsStateChange((PSTRING)ContextRecord->IntA0, 00195 (PKD_SYMBOLS_INFO) ContextRecord->IntA1, 00196 UnloadSymbols, 00197 &Prcb->ProcessorState.ContextFrame); 00198 00199 } 00200 00201 RtlCopyMemory(ContextRecord, 00202 &Prcb->ProcessorState.ContextFrame, 00203 sizeof(CONTEXT)); 00204 00205 KdExitDebugger(Enable); 00206 00207 // 00208 // If the kernel debugger did not update the FIR, then increment 00209 // past the breakpoint instruction. 00210 // 00211 00212 if (ContextRecord->Fir == OldFir) { 00213 ContextRecord->Fir += 4; 00214 } 00215 00216 return TRUE; 00217 00218 // 00219 // Unknown internal command. 00220 // 00221 00222 default: 00223 break; 00224 } 00225 } 00226 00227 // 00228 // Report state change to kernel debugger on host machine. 00229 // 00230 00231 Enable = KdEnterDebugger(TrapFrame, ExceptionFrame); 00232 Prcb = KeGetCurrentPrcb(); 00233 00234 RtlCopyMemory(&Prcb->ProcessorState.ContextFrame, 00235 ContextRecord, 00236 sizeof (CONTEXT)); 00237 00238 Completion = KdpReportExceptionStateChange(ExceptionRecord, 00239 &Prcb->ProcessorState.ContextFrame, 00240 SecondChance); 00241 00242 RtlCopyMemory(ContextRecord, 00243 &Prcb->ProcessorState.ContextFrame, 00244 sizeof(CONTEXT)); 00245 00246 KdExitDebugger(Enable); 00247 00248 KdpControlCPressed = FALSE; 00249 00250 // 00251 // Always return TRUE if this is the first chance to handle the 00252 // exception. Otherwise, return the completion status of the 00253 // state change reporting. 00254 // 00255 00256 if( SecondChance ){ 00257 return Completion; 00258 } else { 00259 return TRUE; 00260 } 00261 }


Generated on Sat May 15 19:44:27 2004 for test by doxygen 1.3.7