mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
- 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:
parent
7df63f2bb1
commit
6d53c91bed
5 changed files with 32 additions and 10 deletions
|
@ -109,13 +109,11 @@ typedef struct _KDB_MODULE_INFO
|
||||||
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
|
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) KdbSymLoadUserModuleSymbols(LDRMOD)
|
||||||
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME, MODULE)
|
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) KdbSymLoadDriverSymbols(FILENAME, MODULE)
|
||||||
# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
|
# define KDB_UNLOADDRIVER_HOOK(MODULE) KdbSymUnloadDriverSymbols(MODULE)
|
||||||
# define KDB_LOADERINIT_HOOK(NTOS, HAL) KdbSymInit(NTOS, HAL)
|
|
||||||
# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessBootSymbols(FILENAME)
|
# define KDB_SYMBOLFILE_HOOK(FILENAME) KdbSymProcessBootSymbols(FILENAME)
|
||||||
#else
|
#else
|
||||||
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) do { } while (0)
|
# define KDB_LOADUSERMODULE_HOOK(LDRMOD) do { } while (0)
|
||||||
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
|
# define KDB_LOADDRIVER_HOOK(FILENAME, MODULE) do { } while (0)
|
||||||
# define KDB_UNLOADDRIVER_HOOK(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_SYMBOLFILE_HOOK(FILENAME) do { } while (0)
|
||||||
# define KDB_CREATE_THREAD_HOOK(CONTEXT) do { } while (0)
|
# define KDB_CREATE_THREAD_HOOK(CONTEXT) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -211,7 +209,7 @@ KdpGdbStubInit(
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
KdbSymInit(
|
KdpKdbgInit(
|
||||||
struct _KD_DISPATCH_TABLE *DispatchTable,
|
struct _KD_DISPATCH_TABLE *DispatchTable,
|
||||||
ULONG BootPhase);
|
ULONG BootPhase);
|
||||||
|
|
||||||
|
@ -267,7 +265,8 @@ BOOLEAN
|
||||||
#define KdSerial 1
|
#define KdSerial 1
|
||||||
#define KdFile 2
|
#define KdFile 2
|
||||||
#define KdBochs 3
|
#define KdBochs 3
|
||||||
#define KdMax 4
|
#define KdKdbg 4
|
||||||
|
#define KdMax 5
|
||||||
|
|
||||||
/* KD Private Debug Modes */
|
/* KD Private Debug Modes */
|
||||||
typedef struct _KDP_DEBUG_MODE
|
typedef struct _KDP_DEBUG_MODE
|
||||||
|
|
|
@ -37,7 +37,8 @@ KD_DISPATCH_TABLE DispatchTable[KdMax];
|
||||||
PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit,
|
PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit,
|
||||||
KdpSerialInit,
|
KdpSerialInit,
|
||||||
KdpInitDebugLog,
|
KdpInitDebugLog,
|
||||||
KdpBochsInit};
|
KdpBochsInit,
|
||||||
|
KdpKdbgInit};
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
|
||||||
{
|
{
|
||||||
KD_CONTINUE_TYPE Return;
|
KD_CONTINUE_TYPE Return;
|
||||||
ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
|
ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
|
||||||
|
ULONG EipOld;
|
||||||
|
|
||||||
/* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
|
/* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
|
||||||
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
|
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
|
||||||
|
@ -125,6 +126,11 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
|
||||||
(PVOID)ExceptionRecord->ExceptionInformation[1],
|
(PVOID)ExceptionRecord->ExceptionInformation[1],
|
||||||
ExceptionRecord->ExceptionInformation[2]);
|
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 */
|
/* This we can handle: simply bump EIP */
|
||||||
Context->Eip++;
|
Context->Eip++;
|
||||||
|
@ -134,6 +140,9 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
|
||||||
/* Get out of here if the Debugger isn't connected */
|
/* Get out of here if the Debugger isn't connected */
|
||||||
if (KdDebuggerNotPresent) return FALSE;
|
if (KdDebuggerNotPresent) return FALSE;
|
||||||
|
|
||||||
|
/* Save old EIP value */
|
||||||
|
EipOld = Context->Eip;
|
||||||
|
|
||||||
/* Call KDBG if available */
|
/* Call KDBG if available */
|
||||||
Return = KdbEnterDebuggerException(ExceptionRecord,
|
Return = KdbEnterDebuggerException(ExceptionRecord,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
|
@ -141,6 +150,19 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
|
||||||
TrapFrame,
|
TrapFrame,
|
||||||
!SecondChance);
|
!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 */
|
/* Convert return to BOOLEAN */
|
||||||
if (Return == kdContinue) return TRUE;
|
if (Return == kdContinue) return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -1303,7 +1303,7 @@ KdbEnterDebuggerException(
|
||||||
* The breakpoint will point to the next instruction by default so
|
* The breakpoint will point to the next instruction by default so
|
||||||
* point it back to the start of original instruction.
|
* point it back to the start of original instruction.
|
||||||
*/
|
*/
|
||||||
TrapFrame->Eip--;
|
//TrapFrame->Eip--;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ... and restore the original instruction.
|
* ... and restore the original instruction.
|
||||||
|
@ -1642,7 +1642,7 @@ KdbpSafeReadMemory(OUT PVOID Dest,
|
||||||
Status = _SEH_GetExceptionCode();
|
Status = _SEH_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH_END;
|
_SEH_END;
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -684,8 +684,8 @@ KdbDebugPrint(PCH Message, ULONG Length)
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
KdbSymInit(PKD_DISPATCH_TABLE DispatchTable,
|
KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable,
|
||||||
ULONG BootPhase)
|
ULONG BootPhase)
|
||||||
{
|
{
|
||||||
PCHAR p1, p2;
|
PCHAR p1, p2;
|
||||||
int Found;
|
int Found;
|
||||||
|
@ -697,7 +697,7 @@ KdbSymInit(PKD_DISPATCH_TABLE DispatchTable,
|
||||||
if (BootPhase == 0)
|
if (BootPhase == 0)
|
||||||
{
|
{
|
||||||
/* Write out the functions that we support for now */
|
/* Write out the functions that we support for now */
|
||||||
DispatchTable->KdpInitRoutine = KdbSymInit;
|
DispatchTable->KdpInitRoutine = KdpKdbgInit;
|
||||||
DispatchTable->KdpPrintRoutine = KdbDebugPrint;
|
DispatchTable->KdpPrintRoutine = KdbDebugPrint;
|
||||||
|
|
||||||
/* Register as a Provider */
|
/* Register as a Provider */
|
||||||
|
|
Loading…
Reference in a new issue