test: kd.h File Reference

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

# kd.h File Reference

Go to the source code of this file.

## Classes

struct | _KD_SYMBOLS_INFO
struct | _DEBUG_PARAMETERS

## Defines

#define | CP_GET_SUCCESS 0
#define | CP_GET_NODATA 1
#define | CP_GET_ERROR 2
#define | FREEZE_BACKUP 0x0001
#define | FREEZE_SKIPPED_PROCESSOR 0x0002
#define | FREEZE_FROZEN 0x0004
#define | KDPRINTBUFFERSIZE 4096

## Typedefs

typedef _KD_SYMBOLS_INFO | KD_SYMBOLS_INFO
typedef _KD_SYMBOLS_INFO * | PKD_SYMBOLS_INFO
typedef _DEBUG_PARAMETERS | DEBUG_PARAMETERS
typedef _DEBUG_PARAMETERS * | PDEBUG_PARAMETERS
typedef _DBGKD_DEBUG_DATA_HEADER64 * | PDBGKD_DEBUG_DATA_HEADER64

## Functions

BOOLEAN | KdInitSystem (IN PLOADER_PARAMETER_BLOCK LoaderBlock, BOOLEAN StopInDebugger)
BOOLEAN | KdEnterDebugger (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
VOID | KdExitDebugger (IN BOOLEAN Enable)
BOOLEAN | KdPollBreakIn (VOID)
BOOLEAN | KdIsThisAKdTrap (IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode)
VOID | KdSetOwedBreakpoints (VOID)
VOID | KdDeleteAllBreakpoints (VOID)
VOID | KdUpdateTimeSlipEvent (PVOID Event)
VOID | KdUpdateDataBlock (VOID)
ULONG_PTR | KdGetDataBlock (VOID)
BOOLEAN | KdRegisterDebuggerDataBlock (IN ULONG Tag, IN PDBGKD_DEBUG_DATA_HEADER64 DataHeader, IN ULONG Size)
VOID | KdDeregisterDebuggerDataBlock32 (IN PDBGKD_DEBUG_DATA_HEADER64 DataHeader)
VOID | KdDisableDebugger (VOID)
VOID | KdEnableDebugger (VOID)
VOID | KdLogDbgPrint (IN PSTRING String)

## Variables

BOOLEAN | KdPitchDebugger
BOOLEAN | KdDebuggerNotPresent
BOOLEAN | KdDebuggerEnabled
DEBUG_PARAMETERS | KdDebugParameters

## Define Documentation

#define CP_GET_ERROR 2

| Definition at line 32 of file kd.h. Referenced by KdpReceivePacket(), and KdpReceivePacketLeader().

#define CP_GET_NODATA 1

| Definition at line 31 of file kd.h. Referenced by KdpReceivePacket(), and KdpReceivePacketLeader().

#define CP_GET_SUCCESS 0

| Definition at line 30 of file kd.h. Referenced by KdPollBreakIn(), KdpPollBreakInWithPortLock(), KdpReceivePacket(), and KdpReceiveString().

#define FREEZE_BACKUP 0x0001

| Definition at line 40 of file kd.h. Referenced by KdEnterDebugger(), KeFreezeExecution(), and KeThawExecution().

#define FREEZE_FROZEN 0x0004

| Definition at line 42 of file kd.h. Referenced by KeFreezeExecution().

#define FREEZE_SKIPPED_PROCESSOR 0x0002

| Definition at line 41 of file kd.h. Referenced by KdEnterDebugger(), and KeFreezeExecution().

#define KDPRINTBUFFERSIZE 4096

| Definition at line 203 of file kd.h. Referenced by KdLogDbgPrint().

## Typedef Documentation

typedef struct _DEBUG_PARAMETERS DEBUG_PARAMETERS

typedef struct _KD_SYMBOLS_INFO KD_SYMBOLS_INFO

typedef struct _DBGKD_DEBUG_DATA_HEADER64* PDBGKD_DEBUG_DATA_HEADER64

| Definition at line 167 of file kd.h. Referenced by KdDeregisterDebuggerDataBlock(), and KdRegisterDebuggerDataBlock().

typedef struct _DEBUG_PARAMETERS * PDEBUG_PARAMETERS

typedef struct _KD_SYMBOLS_INFO * PKD_SYMBOLS_INFO

| Referenced by DebugLoadImageSymbols().

## Function Documentation

VOID KdDeleteAllBreakpoints | ( | VOID |  | ) |

Definition at line 1332 of file kdbreak.c.

References BreakpointsSuspended, FALSE, Handle, KdDebuggerEnabled, KdpDeleteBreakpoint(), and KdPitchDebugger.

    01335 {
    01336     ULONG Handle;
    01337
    01338     if (KdDebuggerEnabled == FALSE || KdPitchDebugger != FALSE) {
    01339         return;
    01340     }
    01341
    01342     BreakpointsSuspended = FALSE;
    01343
    01344     for ( Handle = 1; Handle <= BREAKPOINT_TABLE_SIZE; Handle++ ) {
    01345         KdpDeleteBreakpoint(Handle);
    01346     }
    01347
    01348     return;
    01349 } // KdDeleteAllBreakpoints

VOID KdDeregisterDebuggerDataBlock32 | ( | IN PDBGKD_DEBUG_DATA_HEADER64 | DataHeader | ) |

VOID KdDisableDebugger | ( | VOID |  | ) |

Definition at line 3240 of file kdapi.c.

References DISPATCH_LEVEL, FALSE, KdDebuggerEnabled, KdDisableCount, KdPitchDebugger, KdpPortLock(), KdpPortUnlock(), KdPreviouslyEnabled, KdpStub(), KdpSuspendAllBreakpoints(), KeLowerIrql(), KeRaiseIrql(), and KiDebugRoutine.

    03246                    :
    03247
    03248     This function is called to disable the debugger.
    03249
    03250 Arguments:
    03251
    03252     None.
    03253
    03254 Return Value:
    03255
    03256     None.
    03257
    03258 --*/
    03259
    03260 {
    03261     KIRQL oldIrql ;
    03262
    03263     KeRaiseIrql(DISPATCH_LEVEL, &oldIrql) ;
    03264     KdpPortLock();
    03265
    03266     if (!KdDisableCount) {
    03267
    03268         KdPreviouslyEnabled = KdDebuggerEnabled && (!KdPitchDebugger) ;
    03269         if (KdDebuggerEnabled) {
    03270
    03271             KdpSuspendAllBreakpoints() ;
    03272             KiDebugRoutine = KdpStub;
    03273             KdDebuggerEnabled = FALSE ;
    03274         }
    03275     }
    03276     KdDisableCount++ ;
    03277     KdpPortUnlock();
    03278     KeLowerIrql(oldIrql);
    03279 }

VOID KdEnableDebugger | ( | VOID |  | ) |

Definition at line 3282 of file kdapi.c.

References ASSERT, DISPATCH_LEVEL, FALSE, KdDisableCount, KdInitSystem(), KdpPortLock(), KdpPortUnlock(), KdpRestoreAllBreakpoints(), KdPreviouslyEnabled, KeLowerIrql(), KeRaiseIrql(), NULL, PoHiberInProgress, and TRUE.

    03287                    :
    03288
    03289     This function is called to reenable the debugger after a call to
    03290     KdDisableDebugger.
    03291
    03292 Arguments:
    03293
    03294     None.
    03295
    03296 Return Value:
    03297
    03298     None.
    03299
    03300 --*/
    03301 {
    03302     KIRQL oldIrql ;
    03303
    03304     KeRaiseIrql(DISPATCH_LEVEL, &oldIrql) ;
    03305     KdpPortLock();
    03306
    03307     ASSERT(KdDisableCount > 0) ;
    03308     KdDisableCount-- ;
    03309
    03310     if (!KdDisableCount) {
    03311         if (KdPreviouslyEnabled) {
    03312
    03313             //
    03314             // Ugly HACKHACK - Make sure the timers aren't reset.
    03315             //
    03316             PoHiberInProgress = TRUE ;
    03317             KdInitSystem(NULL, FALSE) ;
    03318             KdpRestoreAllBreakpoints();
    03319             PoHiberInProgress = FALSE ;
    03320         }
    03321     }
    03322     KdpPortUnlock();
    03323     KeLowerIrql(oldIrql);
    03324 }

BOOLEAN KdEnterDebugger | ( | IN PKTRAP_FRAME | TrapFrame,
|  | IN PKEXCEPTION_FRAME | ExceptionFrame
| ) |

Definition at line 303 of file kdapi.c.

References DPRINT, FALSE, FREEZE_BACKUP, FREEZE_SKIPPED_PROCESSOR, KdEnteredDebugger, KdpDebuggerLock, KdPortSave(), KdpPortLocked, KdpQueryPerformanceCounter(), KdTimerDifference, KdTimerStart, KdTimerStop, KeFreezeExecution(), KiFreezeFlag, KiTryToAcquireSpinLock(), TimeFields, and TRUE.

Referenced by KdpTrap(), and KdSetOwedBreakpoints().

    00310                    :
    00311
    00312     This function is used to enter the kernel debugger. Its purpose
    00313     is to freeze all other processors and aqcuire the kernel debugger
    00314     comm port.
    00315
    00316 Arguments:
    00317
    00318     TrapFrame - Supplies a pointer to a trap frame that describes the
    00319         trap.
    00320
    00321     ExceptionFrame - Supplies a pointer to an exception frame that
    00322         describes the trap.
    00323
    00324 Return Value:
    00325
    00326     Returns the previous interrupt enable.
    00327
    00328 --*/
    00329
    00330 {
    00331
    00332     BOOLEAN Enable;
    00333     TIME_FIELDS TimeFields;
    00334 #if DBG
    00335     extern ULONG KiFreezeFlag;
    00336 #endif
    00337
    00338     //
    00339     // HACKHACK - do some crude timer support
    00340     //            but not if called from KdSetOwedBreakpoints()
    00341     //
    00342
    00343     if (TrapFrame) {
    00344         KdTimerStop = KdpQueryPerformanceCounter (TrapFrame);
    00345         KdTimerDifference.QuadPart = KdTimerStop.QuadPart - KdTimerStart.QuadPart;
    00346     } else {
    00347         KdTimerStop.QuadPart = 0;
    00348     }
    00349
    00350     //
    00351     // Freeze all other processors, raise IRQL to HIGH_LEVEL, and save debug
    00352     // port state.  We lock the port so that KdPollBreakin and a debugger
    00353     // operation don't interfere with each other.
    00354     //
    00355
    00356     Enable = KeFreezeExecution(TrapFrame, ExceptionFrame);
    00357     KdpPortLocked = KiTryToAcquireSpinLock(&KdpDebuggerLock);
    00358     KdPortSave();
    00359     KdEnteredDebugger = TRUE;
    00360
    00361 #if DBG
    00362
    00363     if ((KiFreezeFlag & FREEZE_BACKUP) != 0) {
    00364         DPRINT(("FreezeLock was jammed!  Backup SpinLock was used!\n"));
    00365     }
    00366
    00367     if ((KiFreezeFlag & FREEZE_SKIPPED_PROCESSOR) != 0) {
    00368         DPRINT(("Some processors not frozen in debugger!\n"));
    00369     }
    00370
    00371     if (KdpPortLocked == FALSE) {
    00372         DPRINT(("Port lock was not acquired!\n"));
    00373     }
    00374
    00375 #endif
    00376
    00377     return Enable;
    00378 }

VOID KdExitDebugger | ( | IN BOOLEAN | Enable | ) |

Definition at line 381 of file kdapi.c.

References KdPortRestore(), KdpPortLocked, KdpPortUnlock(), KdpTimeSlipDpc, KdpTimeSlipPending, KdTimerStart, KdTimerStop, KeInsertQueueDpc(), KeQueryPerformanceCounter(), KeThawExecution(), NULL, PoHiberInProgress, and TimeFields.

Referenced by KdpTrap(), and KdSetOwedBreakpoints().

    00387                    :
    00388
    00389     This function is used to exit the kernel debugger. It is the reverse
    00390     of KdEnterDebugger.
    00391
    00392 Arguments:
    00393
    00394     Enable - Supplies the previous interrupt enable which is to be restored.
    00395
    00396 Return Value:
    00397
    00398     None.
    00399
    00400 --*/
    00401
    00402 {
    00403     ULONG ElapsedTime;
    00404     ULARGE_INTEGER TimeDifference;
    00405     TIME_FIELDS TimeFields;
    00406     ULONG Pending;
    00407
    00408     //
    00409     // restore stuff and exit
    00410     //
    00411
    00412     KdPortRestore();
    00413     if (KdpPortLocked) {
    00414         KdpPortUnlock();
    00415     }
    00416
    00417     KeThawExecution(Enable);
    00418
    00419     //
    00420     // Do some crude timer support.  If KdEnterDebugger didn't
    00421     // Query the performance counter, then don't do it here either.
    00422     //
    00423
    00424     if (KdTimerStop.QuadPart == 0) {
    00425         KdTimerStart = KdTimerStop;
    00426     } else {
    00427         KdTimerStart = KeQueryPerformanceCounter(NULL);
    00428     }
    00429
    00430     //
    00431     // Process a time slip
    00432     //
    00433
    00434     if (!PoHiberInProgress) {
    00435
    00436         Pending = InterlockedIncrement(&KdpTimeSlipPending);
    00437
    00438         //
    00439         // If there's wasn't a time slip pending, queue the DPC to handle it
    00440         //
    00441
    00442         if (Pending == 1) {
    00443             InterlockedIncrement(&KdpTimeSlipPending);
    00444             KeInsertQueueDpc(&KdpTimeSlipDpc, NULL, NULL);
    00445         }
    00446     }
    00447
    00448     return;
    00449 }

ULONG_PTR KdGetDataBlock | ( | VOID |  | ) |

Definition at line 55 of file 4/kdinit.c.

References KdDebuggerDataBlock.

Referenced by IoWriteCrashDump().

    00060                    :
    00061
    00062     We have to update this variable seperately since it is initialized at a
    00063     later time by PS.  PS will call us to update the data block.
    00064
    00065 --*/
    00066 {
    00067     return (ULONG_PTR)(&KdDebuggerDataBlock);
    00068 }

BOOLEAN KdInitSystem | ( | IN PLOADER_PARAMETER_BLOCK | LoaderBlock,
|  | BOOLEAN | StopInDebugger
| ) |

Definition at line 36 of file kdinit.c.

References _BREAKPOINT_ENTRY::Address, BAUD_OPTION, _DEBUG_PARAMETERS::BaudRate, _DEBUG_PARAMETERS::CommunicationPort, _BREAKPOINT_ENTRY::DirectoryTableBase, ExInitializeWorkItem, FALSE, _BREAKPOINT_ENTRY::Flags, Index, KdDebuggerDataBlock, KdDebuggerEnabled, KdDebugParameters, KDP_BREAKPOINT_VALUE, KdpBreakpointInstruction, KdpBreakpointTable, KdpDebuggerDataListHead, KdpDebuggerStructuresInitialized, KdPerformanceCounterRate, KdPitchDebugger, KdpNextPacketIdToSend, KdpNtosImageBase, KdPortInitialize(), KdpOweBreakpoint, KdpPacketIdExpected, KdpStub(), KdpSwitchProcessor(), KdpTimeSlipDpc, KdpTimeSlipDpcRoutine(), KdpTimeSlipTimer, KdpTimeSlipWork(), KdpTimeSlipWorkItem, KdpTrap(), KdRegisterDebuggerDataBlock(), KdTimerStart, KeInitializeDpc(), KeInitializeTimer(), KeQueryPerformanceCounter(), KiDebugRoutine, KiDebugSwitchRoutine, L, NULL, PORT_OPTION, strlen(), and TRUE.

Referenced by KdEnableDebugger(), KeBugCheckEx(), KeDumpMachineState(), KeEnterKernelDebugger(), and KiInitializeKernel().

    00043                    :
    00044
    00045     This routine initializes the portable kernel debugger.
    00046
    00047 Arguments:
    00048
    00049     LoaderBlock - Supplies a pointer to the LOADER_PARAMETER_BLOCK passed
    00050         in from the OS Loader.
    00051
    00052     StopInDebugger - Supplies a boolean value that determines whether a
    00053         debug message and breakpoint are generated.
    00054
    00055 Return Value:
    00056
    00057     None.
    00058
    00059 --*/
    00060
    00061 {
    00062
    00063     ULONG Index;
    00064     BOOLEAN Initialize;
    00065     PCHAR Options;
    00066     PCHAR BaudOption;
    00067     PCHAR PortOption;
    00068
    00069     //
    00070     // If kernel debugger is already initialized, then return.
    00071     //
    00072
    00073     if (KdDebuggerEnabled != FALSE) {
    00074         return TRUE;
    00075     }
    00076
    00077     KiDebugRoutine = KdpStub;
    00078
    00079     //
    00080     // Determine whether or not the debugger should be enabled.
    00081     //
    00082     // Note that if LoaderBlock == NULL, then KdInitSystem was called
    00083     // from BugCheck code. For this case the debugger is always enabled
    00084     // to report the bugcheck if possible.
    00085     //
    00086
    00087     if (LoaderBlock != NULL) {
    00088
    00089         KdpNtosImageBase =  CONTAINING_RECORD(
    00090                                     (LoaderBlock->LoadOrderListHead.Flink),
    00091                                     LDR_DATA_TABLE_ENTRY,
    00092                                     InLoadOrderLinks)->DllBase;
    00093
    00094         //
    00095         // Initialize the debugger data block list when called at startup time.
    00096         //
    00097
    00098         InitializeListHead(&KdpDebuggerDataListHead);
    00099
    00100         //
    00101         // Fill in and register the debugger's debugger data block.
    00102         // Most fields are already initialized, some fields will not be
    00103         // filled in until later.
    00104         //
    00105
    00106         KdDebuggerDataBlock.KernBase = (ULONG_PTR) KdpNtosImageBase;
    00107         KdDebuggerDataBlock.KeUserCallbackDispatcher = (ULONG_PTR) KeUserCallbackDispatcher;
    00108
    00109         KdRegisterDebuggerDataBlock(KDBG_TAG,
    00110                                     &KdDebuggerDataBlock.Header,
    00111                                     sizeof(KdDebuggerDataBlock));
    00112
    00113         if (LoaderBlock->LoadOptions != NULL) {
    00114             Options = LoaderBlock->LoadOptions;
    00115             _strupr(Options);
    00116
    00117             //
    00118             // If any of the port option, baud option, or debug is specified,
    00119             // then enable the debugger unless it is explictly disabled.
    00120             //
    00121
    00122             Initialize = TRUE;
    00123             PortOption = strstr(Options, PORT_OPTION);
    00124             BaudOption = strstr(Options, BAUD_OPTION);
    00125             if ((PortOption == NULL) && (BaudOption == NULL)) {
    00126                 if (strstr(Options, "DEBUG") == NULL) {
    00127                     Initialize = FALSE;
    00128                 }
    00129
    00130             } else {
    00131                 if (PortOption) {
    00132                     PortOption = strstr(PortOption, "COM");
    00133                     if (PortOption) {
    00134                         KdDebugParameters.CommunicationPort =
    00135                                                      atol(PortOption + 3);
    00136                     }
    00137                 }
    00138
    00139                 if (BaudOption) {
    00140                     BaudOption += strlen(BAUD_OPTION);
    00141                     while (*BaudOption == ' ') {
    00142                         BaudOption++;
    00143                     }
    00144
    00145                     if (*BaudOption != '\0') {
    00146                         KdDebugParameters.BaudRate = atol(BaudOption + 1);
    00147                     }
    00148                 }
    00149             }
    00150
    00151             //
    00152             // If the debugger is explicitly disabled, then set to NODEBUG.
    00153             //
    00154
    00155             if (strstr(Options, "NODEBUG")) {
    00156                 Initialize = FALSE;
    00157                 KdPitchDebugger = TRUE;
    00158             }
    00159
    00160             if (strstr(Options, "CRASHDEBUG")) {
    00161                 Initialize = FALSE;
    00162                 KdPitchDebugger = FALSE;
    00163             }
    00164
    00165         } else {
    00166
    00167             //
    00168             // If the load options are not specified, then set to NODEBUG.
    00169             //
    00170
    00171             KdPitchDebugger = TRUE;
    00172             Initialize = FALSE;
    00173         }
    00174
    00175     } else {
    00176         Initialize = TRUE;
    00177     }
    00178
    00179     if ((KdPortInitialize(&KdDebugParameters, LoaderBlock, Initialize) == FALSE) ||
    00180         (Initialize == FALSE)) {
    00181         return(TRUE);
    00182     }
    00183
    00184     //
    00185     // Set address of kernel debugger trap routine.
    00186     //
    00187
    00188     KiDebugRoutine = KdpTrap;
    00189
    00190     if (!KdpDebuggerStructuresInitialized) {
    00191
    00192         KiDebugSwitchRoutine = KdpSwitchProcessor;
    00193         KdpBreakpointInstruction = KDP_BREAKPOINT_VALUE;
    00194         KdpOweBreakpoint = FALSE;
    00195
    00196         //
    00197         // Initialize the breakpoint table.
    00198         //
    00199
    00200         for (Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index += 1) {
    00201             KdpBreakpointTable[Index].Flags = 0;
    00202             KdpBreakpointTable[Index].Address = NULL;
    00203             KdpBreakpointTable[Index].DirectoryTableBase = 0L;
    00204         }
    00205
    00206         //
    00207         // Initialize TimeSlip
    00208         //
    00209         KeInitializeDpc(&KdpTimeSlipDpc, KdpTimeSlipDpcRoutine, NULL);
    00210         KeInitializeTimer(&KdpTimeSlipTimer);
    00211         ExInitializeWorkItem(&KdpTimeSlipWorkItem, KdpTimeSlipWork, NULL);
    00212
    00213         KdpDebuggerStructuresInitialized = TRUE ;
    00214     }
    00215
    00216     //
    00217     //  Initialize timer facility - HACKHACK
    00218     //
    00219
    00220     KeQueryPerformanceCounter(&KdPerformanceCounterRate);
    00221     KdTimerStart.HighPart = 0L;
    00222     KdTimerStart.LowPart = 0L;
    00223
    00224     //
    00225     // Initialize ID for NEXT packet to send and Expect ID of next incoming
    00226     // packet.
    00227     //
    00228
    00229     KdpNextPacketIdToSend = INITIAL_PACKET_ID | SYNC_PACKET_ID;
    00230     KdpPacketIdExpected = INITIAL_PACKET_ID;
    00231
    00232     //
    00233     // Mark debugger enabled.
    00234     //
    00235     KdPitchDebugger = FALSE;
    00236     KdDebuggerEnabled = TRUE;
    00237     SharedUserData->KdDebuggerEnabled = TRUE;
    00238
    00239     //
    00240     // If requested, stop in the kernel debugger.
    00241     //
    00242
    00243     if (StopInDebugger) {
    00244         DbgBreakPoint();
    00245     }
    00246
    00247     return TRUE;
    00248 }

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.

Referenced by KiDispatchException().

    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 }

VOID KdLogDbgPrint | ( | IN PSTRING | String | ) |

Definition at line 379 of file kdinit.c.

References HIGH_LEVEL, KdpMoveMemory(), KdpPrintSpinLock, KDPRINTBUFFERSIZE, KdPrintCircularBuffer, KdPrintRolloverCount, KdPrintWritePointer, KeLowerIrql(), KeRaiseIrql(), KiTryToAcquireSpinLock(), and String.

Referenced by KdpTrap().

    00382 {
    00383     KIRQL OldIrql;
    00384     ULONG Length;
    00385     ULONG LengthCopied;
    00386
    00387     for (; ;) {
    00388         if (KeTestSpinLock (&KdpPrintSpinLock)) {
    00389             KeRaiseIrql (HIGH_LEVEL, &OldIrql);
    00390             if (KiTryToAcquireSpinLock(&KdpPrintSpinLock)) {
    00391                 break;          // got the lock
    00392             }
    00393             KeLowerIrql(OldIrql);
    00394         }
    00395     }
    00396
    00397     if (KdPrintCircularBuffer) {
    00398         Length = String->Length;
    00399         //
    00400         // truncate ridiculous strings
    00401         //
    00402         if (Length > KDPRINTBUFFERSIZE) {
    00403             Length = KDPRINTBUFFERSIZE;
    00404         }
    00405
    00406         if (KdPrintWritePointer + Length <= KdPrintCircularBuffer+KDPRINTBUFFERSIZE) {
    00407             LengthCopied = KdpMoveMemory(KdPrintWritePointer, String->Buffer, Length);
    00408             KdPrintWritePointer += LengthCopied;
    00409             if (KdPrintWritePointer >= KdPrintCircularBuffer+KDPRINTBUFFERSIZE) {
    00410                 KdPrintWritePointer = KdPrintCircularBuffer;
    00411                 KdPrintRolloverCount++;
    00412             }
    00413         } else {
    00414             ULONG First = (ULONG)(KdPrintCircularBuffer + KDPRINTBUFFERSIZE - KdPrintWritePointer);
    00415             LengthCopied = KdpMoveMemory(KdPrintWritePointer,
    00416                                          String->Buffer,
    00417                                          First);
    00418             if (LengthCopied == First) {
    00419                 LengthCopied += KdpMoveMemory(KdPrintCircularBuffer,
    00420                                               String->Buffer + First,
    00421                                               Length - First);
    00422             }
    00423             if (LengthCopied > First) {
    00424                 KdPrintWritePointer = KdPrintCircularBuffer + LengthCopied - First;
    00425                 KdPrintRolloverCount++;
    00426             } else {
    00427                 KdPrintWritePointer += LengthCopied;
    00428                 if (KdPrintWritePointer >= KdPrintCircularBuffer+KDPRINTBUFFERSIZE) {
    00429                     KdPrintWritePointer = KdPrintCircularBuffer;
    00430                     KdPrintRolloverCount++;
    00431                 }
    00432             }
    00433         }
    00434     }
    00435
    00436     KiReleaseSpinLock(&KdpPrintSpinLock);
    00437     KeLowerIrql(OldIrql);
    00438 }

BOOLEAN KdPollBreakIn | ( | VOID |  | ) |

Definition at line 93 of file kdlock.c.

References CP_GET_SUCCESS, FALSE, HIGH_LEVEL, KdDebuggerEnabled, KdpControlCPending, KdpControlCPressed, KdpDebuggerLock, KdPortPollByte(), KdpPortUnlock(), KeLowerIrql(), KeRaiseIrql(), KiDisableInterrupts(), KiRestoreInterrupts(), KiTryToAcquireSpinLock(), Status, and TRUE.

Referenced by KiInitializeKernel().

    00099                    :
    00100
    00101     This procedure raises IRQL to high_level, seizes the Debug port
    00102     spinlock, and checks to see if a breakin packet is pending.
    00103     If a packet is present, return TRUE, else FALSE.
    00104
    00105     A packet is present if:
    00106
    00107     There is a valid character which matches BREAK_CHAR.
    00108
    00109     N.B.    Interrupts must be OFF around this call
    00110
    00111 Return Value:
    00112
    00113     TRUE if breakin sequence present, caller should execute int-3.
    00114     FALSE if no breakin seen.
    00115
    00116 --*/
    00117
    00118 {
    00119     BOOLEAN BreakIn;
    00120     BOOLEAN Enable;
    00121     UCHAR   Input;
    00122     KIRQL   OldIrql;
    00123     ULONG   Status;
    00124
    00125     //
    00126     // If the debugger is enabled, see if a breakin by the kernel
    00127     // debugger is pending.
    00128     //
    00129
    00130     BreakIn = FALSE;
    00131     if (KdDebuggerEnabled != FALSE) {
    00132         Enable = KiDisableInterrupts();
    00133 #ifndef _X86_
    00134         KeRaiseIrql(HIGH_LEVEL, &OldIrql);
    00135 #endif
    00136         if (KdpControlCPending != FALSE) {
    00137             KdpControlCPressed = TRUE;
    00138             BreakIn = TRUE;
    00139             KdpControlCPending = FALSE;
    00140
    00141         } else {
    00142             if (KiTryToAcquireSpinLock(&KdpDebuggerLock) != FALSE) {
    00143                 Status = KdPortPollByte(&Input);
    00144                 if ((Status == CP_GET_SUCCESS) &&
    00145                     (Input == BREAKIN_PACKET_BYTE)) {
    00146                     BreakIn = TRUE;
    00147                     KdpControlCPressed = TRUE;
    00148                 }
    00149
    00150                 KdpPortUnlock();
    00151             }
    00152         }
    00153
    00154 #ifndef _X86_
    00155         KeLowerIrql(OldIrql);
    00156 #endif
    00157         KiRestoreInterrupts(Enable);
    00158     }
    00159
    00160     return BreakIn;
    00161 }

BOOLEAN KdRegisterDebuggerDataBlock | ( | IN ULONG | Tag,
|  | IN PDBGKD_DEBUG_DATA_HEADER64 | DataHeader,
|  | IN ULONG | Size
| ) |

Definition at line 287 of file 4/kdinit.c.

References FALSE, Header, KdpDataSpinLock, KdpDebuggerDataListHead, KeAcquireSpinLock, KeReleaseSpinLock(), List, PDBGKD_DEBUG_DATA_HEADER64, Size, and TRUE.

Referenced by KdInitSystem().

    00294                    :
    00295
    00296     This routine is called by a component or driver to register a
    00297     debugger data block.  The data block is made accessible to the
    00298     kernel debugger, thus providing a reliable method of exposing
    00299     random data to debugger extensions.
    00300
    00301 Arguments:
    00302
    00303     Tag - Supplies a unique 4 byte tag which is used to identify the
    00304             data block.
    00305
    00306     DataHeader - Supplies the address of the debugger data block header.
    00307             The OwnerTag field must contain a unique value, and the Size
    00308             field must contain the size of the data block, including the
    00309             header.  If this block is already present, or there is
    00310             already a block with the same value for OwnerTag, this one
    00311             will not be inserted.  If Size is incorrect, this code will
    00312             not notice, but the usermode side of the debugger might not
    00313             function correctly.
    00314
    00315     Size - Supplies the size of the data block, including the header.
    00316
    00317 Return Value:
    00318
    00319     TRUE if the block was added to the list, FALSE if not.
    00320
    00321 --*/
    00322 {
    00323     KIRQL OldIrql;
    00324     PLIST_ENTRY List;
    00325     PDBGKD_DEBUG_DATA_HEADER64 Header;
    00326
    00327     KeAcquireSpinLock(&KdpDataSpinLock, &OldIrql);
    00328
    00329     //
    00330     // Look for a record with the same tag or address
    00331     //
    00332
    00333     List = KdpDebuggerDataListHead.Flink;
    00334
    00335     while (List != &KdpDebuggerDataListHead) {
    00336
    00337         Header = CONTAINING_RECORD(List, DBGKD_DEBUG_DATA_HEADER64, List);
    00338
    00339         List = List->Flink;
    00340
    00341         if ((Header == DataHeader) || (Header->OwnerTag == Tag)) {
    00342             KeReleaseSpinLock(&KdpDataSpinLock, OldIrql);
    00343             return FALSE;
    00344         }
    00345     }
    00346
    00347     //
    00348     // It wasn't already there, so add it.
    00349     //
    00350
    00351     DataHeader->OwnerTag = Tag;
    00352     DataHeader->Size = Size;
    00353
    00354     InsertTailList(&KdpDebuggerDataListHead, (PLIST_ENTRY)(&DataHeader->List));
    00355
    00356     KeReleaseSpinLock(&KdpDataSpinLock, OldIrql);
    00357
    00358     return TRUE;
    00359 }

VOID KdSetOwedBreakpoints | ( | VOID |  | ) |

Definition at line 316 of file kdbreak.c.

References _BREAKPOINT_ENTRY::Address, _BREAKPOINT_ENTRY::Content, _BREAKPOINT_ENTRY::DirectoryTableBase, DPRINT, FALSE, _BREAKPOINT_ENTRY::Flags, GLOBAL_BREAKPOINT_LIMIT, Index, KD_BREAKPOINT_IA64_MOVL, KD_BREAKPOINT_IN_USE, KD_BREAKPOINT_NEEDS_REPLACE, KD_BREAKPOINT_NEEDS_WRITE, KD_BREAKPOINT_STATE_MASK, KD_BREAKPOINT_SUSPENDED, KdEnterDebugger(), KdExitDebugger(), KDP_BREAKPOINT_TYPE, KdpBreakpointInstruction, KdpBreakpointTable, KdpMoveMemory(), KdpOweBreakpoint, KeGetCurrentThread, MmDbgReleaseAddress(), MmDbgWriteCheck(), NULL, and TRUE.

    00322                    :
    00323
    00324     This function is called after returning from memory management calls
    00325     that may cause an inpage.  Its purpose is to store pending
    00326     breakpoints in pages just made valid.
    00327
    00328 Arguments:
    00329
    00330     None.
    00331
    00332 Return Value:
    00333
    00334     None.
    00335
    00336 --*/
    00337
    00338 {
    00339
    00340     KDP_BREAKPOINT_TYPE Content;
    00341     BOOLEAN Enable;
    00342     LONG Index;
    00343     ULONG_PTR Opaque;
    00344
    00345     //
    00346     // If we don't owe any breakpoints then return
    00347     //
    00348
    00349     if ( !KdpOweBreakpoint ) {
    00350         return;
    00351     }
    00352
    00353
    00354     //
    00355     // Freeze all other processors, disable interrupts, and save debug
    00356     // port state.
    00357     //
    00358
    00359     Enable = KdEnterDebugger(NULL, NULL);
    00360     KdpOweBreakpoint = FALSE;
    00361
    00362     //
    00363     // Search the breakpoint table for breakpoints that need to be
    00364     // written or replaced.
    00365     //
    00366
    00367     for (Index = 0; Index < BREAKPOINT_TABLE_SIZE; Index += 1) {
    00368         if (KdpBreakpointTable[Index].Flags &
    00369                 (KD_BREAKPOINT_NEEDS_WRITE | KD_BREAKPOINT_NEEDS_REPLACE) ) {
    00370
    00371             //
    00372             // Breakpoint needs to be written
    00373             //
    00374             //DPRINT(("KD: Breakpoint %d at 0x%08x: trying to %s after page in.\n",
    00375             //    Index,
    00376             //    KdpBreakpointTable[Index].Address,
    00377             //    (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_WRITE) ?
    00378             //        "set" : "clear"));
    00379
    00380             if ((KdpBreakpointTable[Index].Address >= (PVOID)GLOBAL_BREAKPOINT_LIMIT) ||
    00381                 (KdpBreakpointTable[Index].DirectoryTableBase ==
    00382                  KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0])) {
    00383
    00384                 //
    00385                 // Check to see if we have write access to the memory
    00386                 //
    00387                 if (MmDbgWriteCheck((PVOID)KdpBreakpointTable[Index].Address,                                       &Opaque) == NULL) {
    00388                     KdpOweBreakpoint = TRUE;
    00389                     //DPRINT(("KD: address not writeable.\n"));
    00390                     break;
    00391                 }
    00392
    00393                 MmDbgReleaseAddress(
    00394                         (PVOID)KdpBreakpointTable[Index].Address,
    00395                         Opaque
    00396                         );
    00397
    00398                 //
    00399                 // Breakpoint is global, or its directory base matches
    00400                 //
    00401
    00402                 if (KdpMoveMemory(
    00403                         (PCHAR)&Content,
    00404                         (PCHAR)KdpBreakpointTable[Index].Address,
    00405                         sizeof(KDP_BREAKPOINT_TYPE)
    00406                         ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00407
    00408                     //
    00409                     // Memory is still inaccessible (is this possible after
    00410                     // the call above to MmDbgWriteCheck?)
    00411                     //
    00412
    00413                     DPRINT(("KD: read from 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00414
    00415                     KdpOweBreakpoint = TRUE;
    00416
    00417                 } else {
    00418                     if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_NEEDS_WRITE) {
    00419                         KdpBreakpointTable[Index].Content = Content;
    00420 #if defined(_IA64_)
    00421                         switch ((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) {
    00422                         case 0:
    00423                             Content = (Content & ~(INST_SLOT0_MASK)) | (KdpBreakpointInstruction << 5);
    00424                             break;
    00425
    00426                         case 4:
    00427                             Content = (Content & ~(INST_SLOT1_MASK)) | (KdpBreakpointInstruction << 14);
    00428                             break;
    00429
    00430                         case 8:
    00431                             Content = (Content & ~(INST_SLOT2_MASK)) | (KdpBreakpointInstruction << 23);
    00432                             break;
    00433
    00434                         default:
    00435                             DPRINT(("KD: illegal instruction address 0x%08x\n", KdpBreakpointTable[Index].Address));
    00436                             return;
    00437                         }
    00438                         if (KdpMoveMemory(
    00439                                 (PCHAR)KdpBreakpointTable[Index].Address,
    00440                                 (PCHAR)&Content,
    00441                                 sizeof(KDP_BREAKPOINT_TYPE)
    00442                                 ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00443                             KdpOweBreakpoint = TRUE;
    00444                             DPRINT(("KD: write to 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00445                         }
    00446
    00447                         // read in intruction template if current instruction is NOT slot 0.
    00448                         // check for two-slot MOVL instruction. Reject request if attempt to
    00449                         // set break in slot 2 of MLI template.
    00450
    00451                         else if (((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) != 0) {
    00452                             KDP_BREAKPOINT_TYPE mBuf;
    00453                             PVOID BundleAddress;
    00454
    00455                             (ULONG_PTR)BundleAddress = (ULONG_PTR)KdpBreakpointTable[Index].Address  & ~(0xf);
    00456                             if (KdpMoveMemory(
    00457                                     (PCHAR)&mBuf,
    00458                                     (PCHAR)BundleAddress,
    00459                                     sizeof(KDP_BREAKPOINT_TYPE)
    00460                                     ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00461                                 KdpOweBreakpoint = TRUE;
    00462                                 DPRINT(("KD: read 0x%08x template failed\n", KdpBreakpointTable[Index].Address));
    00463                             } else {
    00464                                 if (((mBuf & INST_TEMPL_MASK) >> 1) == 0x2) {
    00465                                     if (((ULONG_PTR)KdpBreakpointTable[Index].Address  & 0xf) == 4) {
    00466                                         // if template= type 2 MLI, change to type 0
    00467                                         mBuf &= ~((INST_TEMPL_MASK >> 1) << 1);
    00468                                         KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IA64_MOVL;
    00469                                         if (KdpMoveMemory(
    00470                                             (PCHAR)BundleAddress,
    00471                                             (PCHAR)&mBuf,
    00472                                             sizeof(KDP_BREAKPOINT_TYPE)
    00473                                             ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00474                                             KdpOweBreakpoint = TRUE;
    00475                                             DPRINT(("KD: write to 0x%08x template failed\n", KdpBreakpointTable[Index].Address));
    00476                                         }
    00477                                         else {
    00478                                             KdpBreakpointTable[Index].Flags &= ~(KD_BREAKPOINT_STATE_MASK);
    00479                                             KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IN_USE;
    00480                                             //DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00481                                         }
    00482                                     } else {
    00483                                         // set breakpoint at slot 2 of MOVL is illegal
    00484                                         KdpOweBreakpoint = TRUE;
    00485                                         DPRINT(("KD: illegal attempt to set BP at slot 2 of 0x%08x\n", KdpBreakpointTable[Index].Address));
    00486                                     }
    00487                                 }
    00488                                 else {
    00489                                     KdpBreakpointTable[Index].Flags &= ~(KD_BREAKPOINT_STATE_MASK);
    00490                                     KdpBreakpointTable[Index].Flags |= KD_BREAKPOINT_IN_USE;
    00491                                     //DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00492                                 }
    00493                             }
    00494                         }
    00495 #else
    00496                         if (KdpMoveMemory(
    00497                                 (PCHAR)KdpBreakpointTable[Index].Address,
    00498                                 (PCHAR)&KdpBreakpointInstruction,
    00499                                 sizeof(KDP_BREAKPOINT_TYPE)
    00500                                 ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00501                             KdpOweBreakpoint = TRUE;
    00502                             DPRINT(("KD: write to 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00503                         } else {
    00504                             KdpBreakpointTable[Index].Flags = KD_BREAKPOINT_IN_USE;
    00505                             DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00506                         }
    00507 #endif
    00508                     } else {
    00509 #if defined(_IA64_)
    00510
    00511                         KDP_BREAKPOINT_TYPE mBuf;
    00512                         PVOID BundleAddress;
    00513
    00514                         // restore original instruction content
    00515
    00516                         // Read in memory since adjancent instructions in the same bundle may have
    00517                         // been modified after we save them.
    00518                         if (KdpMoveMemory(
    00519                                 (PCHAR)&mBuf,
    00520                                 (PCHAR)KdpBreakpointTable[Index].Address,
    00521                                 sizeof(KDP_BREAKPOINT_TYPE)) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00522                             KdpOweBreakpoint = TRUE;
    00523                             DPRINT(("KD: read 0x%08x template failed\n", KdpBreakpointTable[Index].Address));
    00524                         }
    00525                         else {
    00526                             switch ((ULONG_PTR)KdpBreakpointTable[Index].Address & 0xf) {
    00527                             case 0:
    00528                                 mBuf = (mBuf & ~(INST_SLOT0_MASK))
    00529                                              | (KdpBreakpointTable[Index].Content & INST_SLOT0_MASK);
    00530                                 break;
    00531
    00532                             case 4:
    00533                                 mBuf = (mBuf & ~(INST_SLOT1_MASK))
    00534                                              | (KdpBreakpointTable[Index].Content & INST_SLOT1_MASK);
    00535                                 break;
    00536
    00537                             case 8:
    00538                                 mBuf = (mBuf & ~(INST_SLOT2_MASK))
    00539                                              | (KdpBreakpointTable[Index].Content & INST_SLOT2_MASK);
    00540                                 break;
    00541
    00542                             default:
    00543                                 KdpOweBreakpoint = TRUE;
    00544                                 DPRINT(("KD: illegal instruction address 0x%08x\n", KdpBreakpointTable[Index].Address));
    00545                             }
    00546
    00547                             if (KdpMoveMemory(
    00548                                     (PCHAR)KdpBreakpointTable[Index].Address,
    00549                                     (PCHAR)&mBuf,
    00550                                     sizeof(KDP_BREAKPOINT_TYPE)) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00551                                 KdpOweBreakpoint = TRUE;
    00552                                 DPRINT(("KD: write to 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00553                             }
    00554                             else {
    00555                                  // restore template to MLI if displaced instruction was MOVL
    00556
    00557                                 if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_IA64_MOVL) {
    00558                                     (ULONG_PTR)BundleAddress = (ULONG_PTR)KdpBreakpointTable[Index].Address & ~(0xf);
    00559                                     if (KdpMoveMemory(
    00560                                             (PCHAR)&mBuf,
    00561                                             (PCHAR)BundleAddress,
    00562                                             sizeof(KDP_BREAKPOINT_TYPE)
    00563                                             ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00564                                         KdpOweBreakpoint = TRUE;
    00565                                         DPRINT(("KD: read template 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00566                                     }
    00567                                     else {
    00568                                         mBuf &= ~((INST_TEMPL_MASK >> 1) << 1); // set template to MLI
    00569                                         mBuf |= 0x4;
    00570
    00571                                         if (KdpMoveMemory(
    00572                                               (PCHAR)BundleAddress,
    00573                                               (PCHAR)&mBuf,
    00574                                               sizeof(KDP_BREAKPOINT_TYPE)
    00575                                               ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00576                                             KdpOweBreakpoint = TRUE;
    00577                                             DPRINT(("KD: write template to 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00578                                         } else {
    00579                                             //DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00580                                             if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) {
    00581                                                 KdpBreakpointTable[Index].Flags |= (KD_BREAKPOINT_SUSPENDED | KD_BREAKPOINT_IN_USE);
    00582                                             } else {
    00583                                                 KdpBreakpointTable[Index].Flags = 0;
    00584                                             }
    00585                                         }
    00586                                     }
    00587                                 } else {
    00588                                     //DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00589                                     if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) {
    00590                                         KdpBreakpointTable[Index].Flags |= (KD_BREAKPOINT_SUSPENDED | KD_BREAKPOINT_IN_USE);
    00591                                     } else {
    00592                                         KdpBreakpointTable[Index].Flags = 0;
    00593                                     }
    00594                                 }
    00595                             }
    00596                         }
    00597 #else
    00598                         if (KdpMoveMemory(
    00599                                 (PCHAR)KdpBreakpointTable[Index].Address,
    00600                                 (PCHAR)&KdpBreakpointTable[Index].Content,
    00601                                 sizeof(KDP_BREAKPOINT_TYPE)
    00602                                 ) != sizeof(KDP_BREAKPOINT_TYPE)) {
    00603                             KdpOweBreakpoint = TRUE;
    00604                             DPRINT(("KD: write to 0x%08x failed\n", KdpBreakpointTable[Index].Address));
    00605                         } else {
    00606                             //DPRINT(("KD: write to 0x%08x ok\n", KdpBreakpointTable[Index].Address));
    00607                             if (KdpBreakpointTable[Index].Flags & KD_BREAKPOINT_SUSPENDED) {
    00608                                 KdpBreakpointTable[Index].Flags = KD_BREAKPOINT_SUSPENDED | KD_BREAKPOINT_IN_USE;
    00609                             } else {
    00610                                 KdpBreakpointTable[Index].Flags = 0;
    00611                             }
    00612                         }
    00613 #endif // _IA64_
    00614
    00615                     }
    00616                 }
    00617
    00618             } else {
    00619
    00620                 //
    00621                 // Breakpoint is local and its directory base does not match
    00622                 //
    00623
    00624                 KdpOweBreakpoint = TRUE;
    00625             }
    00626         }
    00627     }
    00628
    00629     KdExitDebugger(Enable);
    00630     return;
    00631 }

VOID KdUpdateDataBlock | ( | VOID |  | ) |

Definition at line 38 of file 4/kdinit.c.

References KdDebuggerDataBlock, and KeUserCallbackDispatcher.

Referenced by PspInitializeSystemDll().

    00043                    :
    00044
    00045     We have to update this variable seperately since it is initialized at a
    00046     later time by PS.  PS will call us to update the data block.
    00047
    00048 --*/
    00049 {
    00050     KdDebuggerDataBlock.KeUserCallbackDispatcher = (ULONG_PTR) KeUserCallbackDispatcher;
    00051 }

VOID KdUpdateTimeSlipEvent | ( | PVOID | Event | ) |

Definition at line 453 of file kdapi.c.

References Event(), KdpTimeSlipEvent, KdpTimeSlipEventLock, KeAcquireSpinLock, KeReleaseSpinLock(), NULL, and ObDereferenceObject.

Referenced by NtSetSystemInformation().

    00459                    :
    00460
    00461     Update the reference to an event object which will be signalled when
    00462     the debugger has caused the system clock to skew.
    00463
    00464 Arguments:
    00465
    00466     Event - Supplies a pointer to an event object
    00467
    00468 Return Value:
    00469
    00470     None
    00471
    00472 --*/
    00473
    00474 {
    00475     KIRQL OldIrql;
    00476
    00477     KeAcquireSpinLock(&KdpTimeSlipEventLock, &OldIrql);
    00478
    00479     //
    00480     // Dereference the old event and forget about it.
    00481     // Remember the new event if there is one.
    00482     //
    00483
    00484     if (KdpTimeSlipEvent != NULL) {
    00485         ObDereferenceObject(KdpTimeSlipEvent);
    00486     }
    00487
    00488     KdpTimeSlipEvent = Event;
    00489
    00490     KeReleaseSpinLock(&KdpTimeSlipEventLock, OldIrql);
    00491 }

## Variable Documentation

BOOLEAN KdDebuggerEnabled

| Definition at line 134 of file kd.h. Referenced by IopDriverCorrectnessApplyControl(), IopDriverCorrectnessThrowBugCheck(), KdDeleteAllBreakpoints(), KdDisableDebugger(), KdInitSystem(), KdPollBreakIn(), KdpPollBreakInWithPortLock(), KeBugCheckEx(), KeEnterKernelDebugger(), NtClose(), NtQuerySystemInformation(), NtRaiseHardError(), and NtSystemDebugControl().

BOOLEAN KdDebuggerNotPresent

| Definition at line 133 of file kd.h. Referenced by KdpReceivePacketLeader(), KdpSendPacket(), KdpSendWaitContinue(), KdpTrap(), KeBugCheckEx(), MiEnsureAvailablePageOrWait(), and NtQuerySystemInformation().

DEBUG_PARAMETERS KdDebugParameters

| Definition at line 142 of file kd.h. Referenced by KdInitSystem().

BOOLEAN KdPitchDebugger

| Definition at line 66 of file kd.h. Referenced by KdDeleteAllBreakpoints(), KdDisableDebugger(), KdInitSystem(), KdpStub(), KeBugCheckEx(), KeEnterKernelDebugger(), and MiEnablePagingTheExecutive().