00091 :
00092
00093 This routine
is called whenever a exception
is dispatched and
the kernel
00094 debugger
is active.
00095
00096 Arguments:
00097
00098 TrapFrame - Supplies a pointer to a trap frame that describes
the
00099 trap.
00100
00101 ExceptionFrame - Supplies a pointer to a exception frame that describes
00102
the trap.
00103
00104 ExceptionRecord - Supplies a pointer to an exception record that
00105 describes
the exception.
00106
00107 ContextRecord - Supplies
the context at
the time of
the exception.
00108
00109 PreviousMode - Supplies
the previous processor mode.
00110
00111 SecondChance - Supplies a
boolean value that determines whether
this is
00112
the second chance (TRUE) that the exception has been raised.
00113
00114 Return Value:
00115
00116 A value of TRUE is returned if the exception is handled. Otherwise a
00117 value of FALSE is returned.
00118
00119 --*/
00120
00121 {
00122
00123 BOOLEAN Completion;
00124 BOOLEAN Enable;
00125 BOOLEAN UnloadSymbols =
FALSE;
00126 ULONG OldIar;
00127 STRING Input;
00128 STRING Output;
00129 PKPRCB Prcb;
00130
00131
00132
00133
00134
00135
00136 re_enter_debugger:
00137 Enable =
KdEnterDebugger(TrapFrame, ExceptionFrame);
00138 Prcb =
KeGetCurrentPrcb();
00139
KiSaveProcessorState(TrapFrame, ExceptionFrame);
00140
KeFlushCurrentTb();
00141
00142
00143
00144
00145
00146
00147
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
00148 ((ExceptionRecord->ExceptionInformation[0] &
BREAKPOINT_CODE_MASK)
00149 >= DEBUG_PRINT_BREAKPOINT)) {
00150
00151
00152
00153
00154
00155
switch (ExceptionRecord->ExceptionInformation[0] &
BREAKPOINT_CODE_MASK) {
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
case DEBUG_PRINT_BREAKPOINT:
00167 ContextRecord->Iar += 4;
00168 Output.Buffer = (PCHAR)ContextRecord->Gpr3;
00169 Output.Length = (
USHORT)ContextRecord->Gpr4;
00170
if (
KdDebuggerNotPresent ==
FALSE) {
00171
if (
KdpPrintString(&Output)) {
00172 ContextRecord->Gpr3 = (ULONG)STATUS_BREAKPOINT;
00173
00174 }
else {
00175 ContextRecord->Gpr3 = (ULONG)STATUS_SUCCESS;
00176 }
00177
00178 }
else {
00179 ContextRecord->Gpr3 = (ULONG)STATUS_DEVICE_NOT_CONNECTED;
00180 }
00181
00182
KiRestoreProcessorState(TrapFrame, ExceptionFrame);
00183
KdExitDebugger(Enable);
00184
return TRUE;
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
case DEBUG_PROMPT_BREAKPOINT:
00196 ContextRecord->Iar += 4;
00197 Output.Buffer = (PCHAR)ContextRecord->Gpr3;
00198 Output.Length = (
USHORT)ContextRecord->Gpr4;
00199 Input.Buffer = (PCHAR)ContextRecord->Gpr5;
00200 Input.MaximumLength = (
USHORT)ContextRecord->Gpr6;
00201
KdpPromptString(&Output, &Input);
00202 ContextRecord->Gpr3 = Input.Length;
00203
KiRestoreProcessorState(TrapFrame, ExceptionFrame);
00204
KdExitDebugger(Enable);
00205
return TRUE;
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
case DEBUG_UNLOAD_SYMBOLS_BREAKPOINT:
00217 UnloadSymbols =
TRUE;
00218
00219
00220
00221
00222
00223
case DEBUG_LOAD_SYMBOLS_BREAKPOINT:
00224 OldIar = ContextRecord->Iar;
00225
if (
KdDebuggerNotPresent ==
FALSE) {
00226
KdpReportLoadSymbolsStateChange((PSTRING)ContextRecord->Gpr3,
00227 (
PKD_SYMBOLS_INFO) ContextRecord->Gpr4,
00228 UnloadSymbols,
00229 &Prcb->ProcessorState.ContextFrame);
00230
00231 }
00232
00233 RtlCopyMemory(ContextRecord,
00234 &Prcb->ProcessorState.ContextFrame,
00235
sizeof(CONTEXT));
00236
00237
KiRestoreProcessorState(TrapFrame, ExceptionFrame);
00238
KdExitDebugger(Enable);
00239
00240
00241
00242
00243
00244
00245
if (ContextRecord->Iar == OldIar) {
00246 ContextRecord->Iar += 4;
00247 }
00248
00249
return TRUE;
00250
00251
00252
00253
00254
00255
default:
00256
break;
00257 }
00258 }
00259
00260
00261
00262
00263
00264 Completion =
KdpReportExceptionStateChange(
00265 ExceptionRecord,
00266 &Prcb->ProcessorState.ContextFrame,
00267 SecondChance);
00268
00269 RtlCopyMemory(ContextRecord,
00270 &Prcb->ProcessorState.ContextFrame,
00271
sizeof(CONTEXT));
00272
00273
KiRestoreProcessorState(TrapFrame, ExceptionFrame);
00274
KdExitDebugger(Enable);
00275
00276
00277
00278
00279
00280
if (
KdpPageInAddress) {
00281
00282
if (KeGetCurrentIrql() <=
APC_LEVEL) {
00283
00284
00285
00286
00287
00288
00289
00290
KdpPageInData( (PUCHAR)KdpPageInAddress );
00291
KdpPageInAddress = 0;
00292
KdpControlCPending =
FALSE;
00293
goto re_enter_debugger;
00294
00295 }
else {
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
if (
KdpControlCPressed) {
00306
ExInitializeWorkItem(
00307 &KdpPageInWorkItem,
00308 (PWORKER_THREAD_ROUTINE) KdpPageInData,
00309 (PVOID) KdpPageInAddress
00310 );
00311
ExQueueWorkItem( &KdpPageInWorkItem, DelayedWorkQueue );
00312
KdpPageInAddress = 0;
00313 }
00314 }
00315 }
00316
00317
KdpControlCPressed =
FALSE;
00318
00319
return Completion;
00320 }