- Start turning KDBG into a KD wrapper (and thus removing where possible KDBG-specific hacks in various places of the kernel).

- KdbSymInit() became a general initialization routine.
- KdpEnterDebuggerException() is modified to:
  * Call KDBG's symbol-loading hook when BREAKPOINT_LOAD_SYMBOLS is hit.
  * If KDBG is turned on, and it's a breakpoint, the Eip is incremented (thus fixing the inability to "cont" after breaking into the KDBG debugger).

svn path=/trunk/; revision=27419
This commit is contained in:
Aleksey Bragin 2007-07-06 09:02:16 +00:00
parent 7df63f2bb1
commit 6d53c91bed
5 changed files with 32 additions and 10 deletions

View file

@ -109,13 +109,11 @@ typedef struct _KDB_MODULE_INFO
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME, MODULE)
# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
# define KDB_LOADERINIT_HOOK(NTOS, HAL) KdbSymInit(NTOS, HAL)
# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessBootSymbols(FILENAME)
#else
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) do { } while (0)
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
# define KDB_UNLOADDRIVER_HOOK(MODULE) do { } while (0)
# define KDB_LOADERINIT_HOOK(NTOS, HAL) do { } while (0)
# define KDB_SYMBOLFILE_HOOK(FILENAME) do { } while (0)
# define KDB_CREATE_THREAD_HOOK(CONTEXT) do { } while (0)
#endif
@ -211,7 +209,7 @@ KdpGdbStubInit(
VOID
STDCALL
KdbSymInit(
KdpKdbgInit(
struct _KD_DISPATCH_TABLE *DispatchTable,
ULONG BootPhase);
@ -267,7 +265,8 @@ BOOLEAN
#define KdSerial 1
#define KdFile 2
#define KdBochs 3
#define KdMax 4
#define KdKdbg 4
#define KdMax 5
/* KD Private Debug Modes */
typedef struct _KDP_DEBUG_MODE

View file

@ -37,7 +37,8 @@ KD_DISPATCH_TABLE DispatchTable[KdMax];
PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit,
KdpSerialInit,
KdpInitDebugLog,
KdpBochsInit};
KdpBochsInit,
KdpKdbgInit};
/* PRIVATE FUNCTIONS *********************************************************/

View file

@ -108,6 +108,7 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
{
KD_CONTINUE_TYPE Return;
ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
ULONG EipOld;
/* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
@ -125,6 +126,11 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
(PVOID)ExceptionRecord->ExceptionInformation[1],
ExceptionRecord->ExceptionInformation[2]);
}
else if (ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS)
{
/* Load symbols. Currently implemented only for KDBG! */
KDB_SYMBOLFILE_HOOK((PANSI_STRING)ExceptionRecord->ExceptionInformation[1]);
}
/* This we can handle: simply bump EIP */
Context->Eip++;
@ -134,6 +140,9 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
/* Get out of here if the Debugger isn't connected */
if (KdDebuggerNotPresent) return FALSE;
/* Save old EIP value */
EipOld = Context->Eip;
/* Call KDBG if available */
Return = KdbEnterDebuggerException(ExceptionRecord,
PreviousMode,
@ -141,6 +150,19 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
TrapFrame,
!SecondChance);
/* Bump EIP over int 3 if debugger did not already change it */
if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT)
{
#ifdef KDBG
if (Context->Eip == EipOld)
Context->Eip++;
#else
/* We simulate the original behaviour when KDBG is turned off.
Return var is set to kdHandleException, thus we always return FALSE */
Context->Eip = EipOld;
#endif
}
/* Convert return to BOOLEAN */
if (Return == kdContinue) return TRUE;
return FALSE;

View file

@ -1303,7 +1303,7 @@ KdbEnterDebuggerException(
* The breakpoint will point to the next instruction by default so
* point it back to the start of original instruction.
*/
TrapFrame->Eip--;
//TrapFrame->Eip--;
/*
* ... and restore the original instruction.
@ -1642,7 +1642,7 @@ KdbpSafeReadMemory(OUT PVOID Dest,
Status = _SEH_GetExceptionCode();
}
_SEH_END;
return Status;
}

View file

@ -684,8 +684,8 @@ KdbDebugPrint(PCH Message, ULONG Length)
*/
VOID
STDCALL
KdbSymInit(PKD_DISPATCH_TABLE DispatchTable,
ULONG BootPhase)
KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable,
ULONG BootPhase)
{
PCHAR p1, p2;
int Found;
@ -697,7 +697,7 @@ KdbSymInit(PKD_DISPATCH_TABLE DispatchTable,
if (BootPhase == 0)
{
/* Write out the functions that we support for now */
DispatchTable->KdpInitRoutine = KdbSymInit;
DispatchTable->KdpInitRoutine = KdpKdbgInit;
DispatchTable->KdpPrintRoutine = KdbDebugPrint;
/* Register as a Provider */