00041 :
00042
00043 This routine
is called whenever a exception
is dispatched and
the kernel
00044 debugger
is active.
00045
00046 Arguments:
00047
00048 TrapFrame - Supplies a pointer to a trap frame that describes
the
00049 trap.
00050
00051 ExceptionFrame - Supplies a pointer to a exception frame that describes
00052
the trap.
00053
00054 ExceptionRecord - Supplies a pointer to an exception record that
00055 describes
the exception.
00056
00057 ContextRecord - Supplies
the context at
the time of
the exception.
00058
00059 PreviousMode - Supplies
the previous processor mode.
00060
00061 SecondChance - Supplies a
boolean value that determines whether
this is
00062
the second chance (TRUE) that the exception has been raised.
00063
00064 Return Value:
00065
00066 A value of TRUE is returned if the exception is handled. Otherwise a
00067 value of FALSE is returned.
00068
00069 --*/
00070
00071 {
00072
00073 BOOLEAN Completion =
FALSE;
00074 BOOLEAN Enable;
00075 BOOLEAN UnloadSymbols =
FALSE;
00076 ULONGLONG OldStIIP, OldStIPSR;
00077 STRING Input;
00078 STRING Output;
00079 PKPRCB Prcb;
00080
00081
00082
00083
00084
00085
00086
KeFlushCurrentTb();
00087
00088
00089
00090
00091
00092
00093
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
00094 (ExceptionRecord->ExceptionInformation[0] >= DEBUG_PRINT_BREAKPOINT)) {
00095
00096
00097
00098
00099
00100
switch (ExceptionRecord->ExceptionInformation[0]) {
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
case DEBUG_PRINT_BREAKPOINT:
00114
00115
00116
00117
00118
00119
00120 RtlIa64IncrementIP((ULONG_PTR)ExceptionRecord->ExceptionAddress >> 2,
00121 ContextRecord->StIPSR,
00122 ContextRecord->StIIP);
00123
00124 Output.Buffer = (PCHAR)ContextRecord->IntT0;
00125 Output.Length = (
USHORT)ContextRecord->IntT1;
00126
00127
KdLogDbgPrint(&Output);
00128
00129
if (
KdDebuggerNotPresent ==
FALSE) {
00130
00131 Enable =
KdEnterDebugger(TrapFrame, ExceptionFrame);
00132
if (
KdpPrintString(&Output)) {
00133 ContextRecord->IntV0 = (ULONG)STATUS_BREAKPOINT;
00134
00135 }
else {
00136 ContextRecord->IntV0 = (ULONG)STATUS_SUCCESS;
00137 }
00138
KdExitDebugger(Enable);
00139
00140 }
else {
00141 ContextRecord->IntV0 = (ULONG)STATUS_DEVICE_NOT_CONNECTED;
00142 }
00143
00144
return TRUE;
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
case DEBUG_PROMPT_BREAKPOINT:
00156
00157
00158
00159
00160
00161
00162 RtlIa64IncrementIP((ULONG_PTR)ExceptionRecord->ExceptionAddress >> 2,
00163 ContextRecord->StIPSR,
00164 ContextRecord->StIIP);
00165
00166 Output.Buffer = (PCHAR)ContextRecord->IntT0;
00167 Output.Length = (
USHORT)ContextRecord->IntT1;
00168 Input.Buffer = (PCHAR)ContextRecord->IntT2;
00169 Input.MaximumLength = (
USHORT)ContextRecord->IntT3;
00170
00171
KdLogDbgPrint(&Output);
00172
00173 Enable =
KdEnterDebugger(TrapFrame, ExceptionFrame);
00174
00175
KdpPromptString(&Output, &Input);
00176
00177 ContextRecord->IntV0 = Input.Length;
00178
00179
KdExitDebugger(Enable);
00180
return TRUE;
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
case DEBUG_UNLOAD_SYMBOLS_BREAKPOINT:
00192 UnloadSymbols =
TRUE;
00193
00194
00195
00196
00197
00198
case DEBUG_LOAD_SYMBOLS_BREAKPOINT:
00199
00200
00201
00202
00203
00204
00205 Enable =
KdEnterDebugger(TrapFrame, ExceptionFrame);
00206 Prcb =
KeGetCurrentPrcb();
00207
KiSaveProcessorControlState(&Prcb->ProcessorState);
00208 OldStIPSR = ContextRecord->StIPSR;
00209 OldStIIP = ContextRecord->StIIP;
00210 RtlCopyMemory(&Prcb->ProcessorState.ContextFrame,
00211 ContextRecord,
00212
sizeof(CONTEXT));
00213
00214
if (
KdDebuggerNotPresent ==
FALSE) {
00215
KdpReportLoadSymbolsStateChange((PSTRING)ContextRecord->IntT0,
00216 (
PKD_SYMBOLS_INFO) ContextRecord->IntT1,
00217 UnloadSymbols,
00218 &Prcb->ProcessorState.ContextFrame);
00219
00220 }
00221
00222 RtlCopyMemory(ContextRecord,
00223 &Prcb->ProcessorState.ContextFrame,
00224
sizeof(CONTEXT));
00225
00226
KiRestoreProcessorControlState(&Prcb->ProcessorState);
00227
KdExitDebugger(Enable);
00228
00229
00230
00231
00232
00233
00234
if ((ContextRecord->StIIP == OldStIIP) &&
00235 ((ContextRecord->StIPSR & IPSR_RI_MASK) == (OldStIPSR & IPSR_RI_MASK))) {
00236 RtlIa64IncrementIP((ULONG_PTR)ExceptionRecord->ExceptionAddress >> 2,
00237 ContextRecord->StIPSR,
00238 ContextRecord->StIIP);
00239 }
00240
00241
return TRUE;
00242
00243
00244
00245
00246
00247
case BREAKIN_BREAKPOINT:
00248
00249
00250
00251
00252
00253
00254 RtlIa64IncrementIP((ULONG_PTR)ExceptionRecord->ExceptionAddress >> 2,
00255 ContextRecord->StIPSR,
00256 ContextRecord->StIIP);
00257
break;
00258
00259
00260
00261
00262
00263
default:
00264
break;
00265 }
00266
00267 }
00268
00269
00270
00271
00272
00273
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) ||
00274 (ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP) ||
00275 (
NtGlobalFlag & FLG_STOP_ON_EXCEPTION) ||
00276 SecondChance) {
00277
00278
00279
00280
00281
00282 Enable =
KdEnterDebugger(TrapFrame, ExceptionFrame);
00283 Prcb =
KeGetCurrentPrcb();
00284
KiSaveProcessorControlState(&Prcb->ProcessorState);
00285
00286 RtlCopyMemory(&Prcb->ProcessorState.ContextFrame,
00287 ContextRecord,
00288 sizeof (CONTEXT));
00289
00290 Completion =
KdpReportExceptionStateChange(
00291 ExceptionRecord,
00292 &Prcb->ProcessorState.ContextFrame,
00293 SecondChance);
00294
00295 RtlCopyMemory(ContextRecord,
00296 &Prcb->ProcessorState.ContextFrame,
00297 sizeof (CONTEXT));
00298
00299
KiRestoreProcessorControlState(&Prcb->ProcessorState);
00300
KdExitDebugger(Enable);
00301
00302
00303
KdpControlCPressed =
FALSE;
00304
00305 }
else {
00306
00307
00308
00309
00310
00311
00312
00313 }
00314
00315
00316
00317
00318
00319
00320
00321
if( SecondChance ){
00322
return Completion;
00323 }
else {
00324
return TRUE;
00325 }
00326 }