2005-04-25 14:44:48 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Kernel
|
2015-10-04 11:54:25 +00:00
|
|
|
* FILE: ntoskrnl/kd/kdmain.c
|
2008-12-29 14:26:01 +00:00
|
|
|
* PURPOSE: Kernel Debugger Initialization
|
2005-05-09 01:38:29 +00:00
|
|
|
*
|
2005-04-25 14:44:48 +00:00
|
|
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2005-04-25 14:44:48 +00:00
|
|
|
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
//
|
|
|
|
// Retrieves the ComponentId and Level for BREAKPOINT_PRINT
|
|
|
|
// and OutputString and OutputStringLength for BREAKPOINT_PROMPT.
|
|
|
|
//
|
|
|
|
#if defined(_X86_)
|
|
|
|
|
|
|
|
//
|
|
|
|
// EBX/EDI on x86
|
|
|
|
//
|
|
|
|
#define KdpGetParameterThree(Context) ((Context)->Ebx)
|
|
|
|
#define KdpGetParameterFour(Context) ((Context)->Edi)
|
|
|
|
|
|
|
|
#elif defined(_AMD64_)
|
|
|
|
|
|
|
|
//
|
|
|
|
// R8/R9 on AMD64
|
|
|
|
//
|
|
|
|
#define KdpGetParameterThree(Context) ((Context)->R8)
|
|
|
|
#define KdpGetParameterFour(Context) ((Context)->R9)
|
|
|
|
|
|
|
|
#elif defined(_ARM_)
|
|
|
|
|
|
|
|
//
|
|
|
|
// R3/R4 on ARM
|
|
|
|
//
|
|
|
|
#define KdpGetParameterThree(Context) ((Context)->R3)
|
|
|
|
#define KdpGetParameterFour(Context) ((Context)->R4)
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error Unsupported Architecture
|
|
|
|
#endif
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* VARIABLES ***************************************************************/
|
|
|
|
|
2005-11-22 02:30:18 +00:00
|
|
|
BOOLEAN KdDebuggerEnabled = FALSE;
|
|
|
|
BOOLEAN KdEnteredDebugger = FALSE;
|
|
|
|
BOOLEAN KdDebuggerNotPresent = TRUE;
|
2007-01-24 19:48:34 +00:00
|
|
|
BOOLEAN KdBreakAfterSymbolLoad = FALSE;
|
2007-03-05 01:35:43 +00:00
|
|
|
BOOLEAN KdPitchDebugger = TRUE;
|
2009-10-17 14:31:38 +00:00
|
|
|
BOOLEAN KdIgnoreUmExceptions = FALSE;
|
2005-04-25 14:44:48 +00:00
|
|
|
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads);
|
- More sharing between ntdll/ntoskrnl: shared Dbg code.
- Added NtCreateDebugObject, NtDebugContinue, NtQueryDebugFilterState, NtSetDebugFilterState, NtWaitForDebugEvent to system call list.
- Added some debug constants to headers
- Updated RtlpCheckForActiveDebugger in ntoskrnl to return whatever we're expecting as the "normal" case.
- Added RtlpSetInDbgPrint to rtl support library for special DbgPrint implementation difference in user-mode
- Removed all the deprecated debug APIs in ntdll.
- Implemented NtQueryDebugFilterState and NtSetDebugFilterState based on royce's implementation.
- Started modifications on KeDebugService, and implemented DebugService in rtl
- Implemented all the Dbg* APIs in RTL.
- Implemented DbgUiConnectToDbg, DbgUiContinue, DbgUiWaitStateChange, DbgUiRemoteBreakin, DbgUiIssueRemoteBreakin
- Changed KD Print callbacks to also receive the length of the string.
Right now, one call that should be shared still isn't (the final DebugPrint call) because calling KeDebugService from kernel-mode seems to cause a hang. Also, DebugService does not currently cause an exception like it should (instead it still calls the Kdp handler), because those changes would've made the patch even bigger and are still untested.
svn path=/trunk/; revision=18078
2005-09-26 04:59:48 +00:00
|
|
|
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
#if 0
|
2008-01-08 09:51:53 +00:00
|
|
|
ULONG Kd_DEFAULT_MASK = 1 << DPFLTR_ERROR_LEVEL;
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
#endif
|
2008-01-08 09:51:53 +00:00
|
|
|
|
2020-03-07 16:18:33 +00:00
|
|
|
extern CPPORT PortInfo;
|
|
|
|
extern ANSI_STRING KdpLogFileName;
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
|
|
|
|
|
|
|
ULONG
|
2008-11-29 20:47:48 +00:00
|
|
|
NTAPI
|
2005-04-25 14:44:48 +00:00
|
|
|
KdpServiceDispatcher(ULONG Service,
|
- More sharing between ntdll/ntoskrnl: shared Dbg code.
- Added NtCreateDebugObject, NtDebugContinue, NtQueryDebugFilterState, NtSetDebugFilterState, NtWaitForDebugEvent to system call list.
- Added some debug constants to headers
- Updated RtlpCheckForActiveDebugger in ntoskrnl to return whatever we're expecting as the "normal" case.
- Added RtlpSetInDbgPrint to rtl support library for special DbgPrint implementation difference in user-mode
- Removed all the deprecated debug APIs in ntdll.
- Implemented NtQueryDebugFilterState and NtSetDebugFilterState based on royce's implementation.
- Started modifications on KeDebugService, and implemented DebugService in rtl
- Implemented all the Dbg* APIs in RTL.
- Implemented DbgUiConnectToDbg, DbgUiContinue, DbgUiWaitStateChange, DbgUiRemoteBreakin, DbgUiIssueRemoteBreakin
- Changed KD Print callbacks to also receive the length of the string.
Right now, one call that should be shared still isn't (the final DebugPrint call) because calling KeDebugService from kernel-mode seems to cause a hang. Also, DebugService does not currently cause an exception like it should (instead it still calls the Kdp handler), because those changes would've made the patch even bigger and are still untested.
svn path=/trunk/; revision=18078
2005-09-26 04:59:48 +00:00
|
|
|
PVOID Buffer1,
|
2017-12-14 10:43:57 +00:00
|
|
|
ULONG Buffer1Length,
|
|
|
|
KPROCESSOR_MODE PreviousMode)
|
2005-04-25 14:44:48 +00:00
|
|
|
{
|
|
|
|
ULONG Result = 0;
|
|
|
|
|
|
|
|
switch (Service)
|
|
|
|
{
|
- More sharing between ntdll/ntoskrnl: shared Dbg code.
- Added NtCreateDebugObject, NtDebugContinue, NtQueryDebugFilterState, NtSetDebugFilterState, NtWaitForDebugEvent to system call list.
- Added some debug constants to headers
- Updated RtlpCheckForActiveDebugger in ntoskrnl to return whatever we're expecting as the "normal" case.
- Added RtlpSetInDbgPrint to rtl support library for special DbgPrint implementation difference in user-mode
- Removed all the deprecated debug APIs in ntdll.
- Implemented NtQueryDebugFilterState and NtSetDebugFilterState based on royce's implementation.
- Started modifications on KeDebugService, and implemented DebugService in rtl
- Implemented all the Dbg* APIs in RTL.
- Implemented DbgUiConnectToDbg, DbgUiContinue, DbgUiWaitStateChange, DbgUiRemoteBreakin, DbgUiIssueRemoteBreakin
- Changed KD Print callbacks to also receive the length of the string.
Right now, one call that should be shared still isn't (the final DebugPrint call) because calling KeDebugService from kernel-mode seems to cause a hang. Also, DebugService does not currently cause an exception like it should (instead it still calls the Kdp handler), because those changes would've made the patch even bigger and are still untested.
svn path=/trunk/; revision=18078
2005-09-26 04:59:48 +00:00
|
|
|
case BREAKPOINT_PRINT: /* DbgPrint */
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
{
|
|
|
|
/* Call KDBG */
|
|
|
|
BOOLEAN Handled;
|
|
|
|
Result = KdpPrint(MAXULONG,
|
|
|
|
DPFLTR_INFO_LEVEL,
|
|
|
|
(PCHAR)Buffer1,
|
|
|
|
(USHORT)Buffer1Length,
|
|
|
|
PreviousMode,
|
|
|
|
NULL, // TrapFrame,
|
|
|
|
NULL, // ExceptionFrame,
|
|
|
|
&Handled);
|
2005-04-25 14:44:48 +00:00
|
|
|
break;
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2009-06-17 12:44:05 +00:00
|
|
|
#if DBG
|
2009-08-24 18:19:53 +00:00
|
|
|
case ' soR': /* ROS-INTERNAL */
|
2005-04-25 14:44:48 +00:00
|
|
|
{
|
2010-01-13 22:35:43 +00:00
|
|
|
switch ((ULONG_PTR)Buffer1)
|
2005-04-25 14:44:48 +00:00
|
|
|
{
|
|
|
|
case DumpAllThreads:
|
|
|
|
PspDumpThreads(TRUE);
|
|
|
|
break;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
case DumpUserThreads:
|
|
|
|
PspDumpThreads(FALSE);
|
|
|
|
break;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2010-11-02 14:58:39 +00:00
|
|
|
case KdSpare3:
|
|
|
|
MmDumpArmPfnDatabase(FALSE);
|
2009-06-27 09:54:56 +00:00
|
|
|
break;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-16 17:51:57 +00:00
|
|
|
break;
|
2005-04-25 14:44:48 +00:00
|
|
|
}
|
2008-12-16 15:25:51 +00:00
|
|
|
|
2015-08-28 14:01:58 +00:00
|
|
|
#if defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
|
2011-02-19 21:50:11 +00:00
|
|
|
/* Register a debug callback */
|
|
|
|
case 'CsoR':
|
|
|
|
{
|
|
|
|
switch (Buffer1Length)
|
|
|
|
{
|
|
|
|
case ID_Win32PreServiceHook:
|
|
|
|
KeWin32PreServiceHook = Buffer1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_Win32PostServiceHook:
|
|
|
|
KeWin32PostServiceHook = Buffer1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-08-28 14:01:58 +00:00
|
|
|
#endif
|
2011-02-19 21:50:11 +00:00
|
|
|
|
2008-12-16 15:25:51 +00:00
|
|
|
/* Special case for stack frame dumps */
|
2009-08-24 18:19:53 +00:00
|
|
|
case 'DsoR':
|
2008-12-16 15:25:51 +00:00
|
|
|
{
|
2019-11-18 00:33:06 +00:00
|
|
|
KeRosDumpStackFrames((PULONG_PTR)Buffer1, Buffer1Length);
|
2008-12-16 15:25:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-01 23:06:32 +00:00
|
|
|
|
2015-09-09 16:06:38 +00:00
|
|
|
#if defined(KDBG)
|
2012-10-01 23:06:32 +00:00
|
|
|
/* Register KDBG CLI callback */
|
|
|
|
case 'RbdK':
|
|
|
|
{
|
|
|
|
Result = KdbRegisterCliCallback(Buffer1, Buffer1Length);
|
2012-10-06 09:47:15 +00:00
|
|
|
break;
|
2012-10-01 23:06:32 +00:00
|
|
|
}
|
|
|
|
#endif /* KDBG */
|
|
|
|
#endif /* DBG */
|
2005-04-25 14:44:48 +00:00
|
|
|
default:
|
2013-01-01 16:42:07 +00:00
|
|
|
DPRINT1("Invalid debug service call!\n");
|
2013-10-13 23:04:13 +00:00
|
|
|
HalDisplayString("Invalid debug service call!\r\n");
|
2005-04-25 14:44:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2006-09-17 07:06:35 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
|
|
|
|
IN PKEXCEPTION_FRAME ExceptionFrame,
|
|
|
|
IN PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
IN PCONTEXT Context,
|
|
|
|
IN KPROCESSOR_MODE PreviousMode,
|
|
|
|
IN BOOLEAN SecondChance)
|
|
|
|
{
|
2009-06-22 13:47:10 +00:00
|
|
|
KD_CONTINUE_TYPE Return = kdHandleException;
|
2007-03-03 17:24:58 +00:00
|
|
|
ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
|
|
|
|
|
|
|
|
/* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
|
|
|
|
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
|
|
|
|
(ExceptionRecord->NumberParameters > 0) &&
|
|
|
|
((ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS) ||
|
|
|
|
(ExceptionCommand == BREAKPOINT_UNLOAD_SYMBOLS) ||
|
|
|
|
(ExceptionCommand == BREAKPOINT_COMMAND_STRING) ||
|
2009-10-23 22:51:39 +00:00
|
|
|
(ExceptionCommand == BREAKPOINT_PRINT) ||
|
|
|
|
(ExceptionCommand == BREAKPOINT_PROMPT)))
|
2007-03-03 17:24:58 +00:00
|
|
|
{
|
|
|
|
/* Check if this is a debug print */
|
|
|
|
if (ExceptionCommand == BREAKPOINT_PRINT)
|
|
|
|
{
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
/* Call KDBG */
|
|
|
|
NTSTATUS ReturnStatus;
|
|
|
|
BOOLEAN Handled;
|
|
|
|
ReturnStatus = KdpPrint((ULONG)KdpGetParameterThree(Context),
|
|
|
|
(ULONG)KdpGetParameterFour(Context),
|
|
|
|
(PCHAR)ExceptionRecord->ExceptionInformation[1],
|
|
|
|
(USHORT)ExceptionRecord->ExceptionInformation[2],
|
|
|
|
PreviousMode,
|
|
|
|
TrapFrame,
|
|
|
|
ExceptionFrame,
|
|
|
|
&Handled);
|
|
|
|
|
|
|
|
/* Update the return value for the caller */
|
|
|
|
KeSetContextReturnRegister(Context, ReturnStatus);
|
2007-03-03 17:24:58 +00:00
|
|
|
}
|
2009-10-23 22:51:39 +00:00
|
|
|
#ifdef KDBG
|
2007-07-06 09:02:16 +00:00
|
|
|
else if (ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS)
|
|
|
|
{
|
2017-12-08 13:45:26 +00:00
|
|
|
PKD_SYMBOLS_INFO SymbolsInfo;
|
|
|
|
KD_SYMBOLS_INFO CapturedSymbolsInfo;
|
2009-09-22 21:31:55 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
|
|
|
|
2017-12-08 13:45:26 +00:00
|
|
|
SymbolsInfo = (PKD_SYMBOLS_INFO)ExceptionRecord->ExceptionInformation[2];
|
|
|
|
if (PreviousMode != KernelMode)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForRead(SymbolsInfo,
|
|
|
|
sizeof(*SymbolsInfo),
|
|
|
|
1);
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
KdpMoveMemory(&CapturedSymbolsInfo,
|
2017-12-08 13:45:26 +00:00
|
|
|
SymbolsInfo,
|
|
|
|
sizeof(*SymbolsInfo));
|
|
|
|
SymbolsInfo = &CapturedSymbolsInfo;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
SymbolsInfo = NULL;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SymbolsInfo != NULL)
|
|
|
|
{
|
|
|
|
/* Load symbols. Currently implemented only for KDBG! */
|
|
|
|
if (KdbpSymFindModule(SymbolsInfo->BaseOfDll, NULL, -1, &LdrEntry))
|
|
|
|
{
|
|
|
|
KdbSymProcessSymbols(LdrEntry);
|
|
|
|
}
|
|
|
|
}
|
2007-07-06 09:02:16 +00:00
|
|
|
}
|
2009-10-23 22:51:39 +00:00
|
|
|
else if (ExceptionCommand == BREAKPOINT_PROMPT)
|
|
|
|
{
|
|
|
|
/* Call KDBG */
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
ULONG ReturnLength;
|
|
|
|
ReturnLength = KdpPrompt((PCHAR)ExceptionRecord->ExceptionInformation[1],
|
|
|
|
(USHORT)ExceptionRecord->ExceptionInformation[2],
|
|
|
|
(PCHAR)KdpGetParameterThree(Context),
|
|
|
|
(USHORT)KdpGetParameterFour(Context),
|
|
|
|
PreviousMode,
|
|
|
|
TrapFrame,
|
|
|
|
ExceptionFrame);
|
|
|
|
|
|
|
|
/* Update the return value for the caller */
|
|
|
|
KeSetContextReturnRegister(Context, ReturnLength);
|
2009-10-23 22:51:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-09-17 07:06:35 +00:00
|
|
|
|
2009-10-04 16:53:15 +00:00
|
|
|
/* This we can handle: simply bump the Program Counter */
|
|
|
|
KeSetContextPc(Context, KeGetContextPc(Context) + KD_BREAKPOINT_SIZE);
|
2007-03-03 19:49:36 +00:00
|
|
|
return TRUE;
|
2007-03-03 17:24:58 +00:00
|
|
|
}
|
2006-09-17 07:06:35 +00:00
|
|
|
|
2009-10-23 22:51:39 +00:00
|
|
|
#ifdef KDBG
|
|
|
|
/* Check if this is an assertion failure */
|
|
|
|
if (ExceptionRecord->ExceptionCode == STATUS_ASSERTION_FAILURE)
|
|
|
|
{
|
2014-10-16 21:33:32 +00:00
|
|
|
/* Bump EIP to the instruction following the int 2C */
|
2009-10-23 22:51:39 +00:00
|
|
|
Context->Eip += 2;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-17 07:06:35 +00:00
|
|
|
/* Get out of here if the Debugger isn't connected */
|
|
|
|
if (KdDebuggerNotPresent) return FALSE;
|
|
|
|
|
2009-06-22 11:32:58 +00:00
|
|
|
#ifdef KDBG
|
2006-09-17 07:06:35 +00:00
|
|
|
/* Call KDBG if available */
|
|
|
|
Return = KdbEnterDebuggerException(ExceptionRecord,
|
|
|
|
PreviousMode,
|
|
|
|
Context,
|
|
|
|
TrapFrame,
|
|
|
|
!SecondChance);
|
2009-06-22 11:32:58 +00:00
|
|
|
#else /* not KDBG */
|
|
|
|
if (WrapperInitRoutine)
|
|
|
|
{
|
|
|
|
/* Call GDB */
|
|
|
|
Return = WrapperTable.KdpExceptionRoutine(ExceptionRecord,
|
|
|
|
Context,
|
|
|
|
TrapFrame);
|
|
|
|
}
|
2020-03-29 22:03:02 +00:00
|
|
|
|
|
|
|
/* We'll manually dump the stack for the user... */
|
|
|
|
KeRosDumpStackFrames(NULL, 0);
|
2009-06-22 11:32:58 +00:00
|
|
|
#endif /* not KDBG */
|
2006-09-17 07:06:35 +00:00
|
|
|
|
2008-06-12 08:56:13 +00:00
|
|
|
/* Debugger didn't handle it, please handle! */
|
|
|
|
if (Return == kdHandleException) return FALSE;
|
|
|
|
|
|
|
|
/* Debugger handled it */
|
2008-06-11 11:34:04 +00:00
|
|
|
return TRUE;
|
2006-09-17 07:06:35 +00:00
|
|
|
}
|
|
|
|
|
2009-10-17 14:31:38 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KdIsThisAKdTrap(IN PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
IN PCONTEXT Context,
|
|
|
|
IN KPROCESSOR_MODE PreviousMode)
|
|
|
|
{
|
|
|
|
/* KDBG has its own mechanism for ignoring user mode exceptions */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* PUBLIC FUNCTIONS *********************************************************/
|
|
|
|
|
2019-05-20 10:17:22 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KdUpdateDataBlock(VOID)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.
For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.
KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
NtSetDebugFilterState() that now comes entirely from KD64.
- Remove KD variables that are now shared with KD64.
- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().
- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.
- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
KdpPrint() worker function that correctly probes and captures its arguments.
- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
by the shared code, until KD is removed and only the KD64 version of these
functions remain.
- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
helper compatible with KD64, that is called by the KD64 implementation of
KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
debugging, the prompt will appear on both. Before that the prompt was always
being displayed on COM port even if e.g. a SCREEN-only debug session was used...
- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().
KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
before using them elsewhere.
- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).
- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 21:55:36 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KdEnterDebugger(IN PKTRAP_FRAME TrapFrame,
|
|
|
|
IN PKEXCEPTION_FRAME ExceptionFrame)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KdExitDebugger(IN BOOLEAN Enable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
- Export KeI386MachineType and KeInitializeThreadedDpc
- Stubplement and export IoEnumerateRegisteredFiltersList, IoGetPagingIoPriority, KdRefreshDebuggerNotPresent, KeAcquireInStackQueuedSpinLockForDpc, KeReleaseInStackQueuedSpinLockForDpc, KeAcquireSpinLockForDpc, KeReleaseSpinLockForDpc, KeRegisterNmiCallback, KeDeregisterNmiCallback, KeInitializeCrashDumpHeader, KeTestSpinLock and MmAllocatePagesForMdlEx
- Add IO_PAGING_PRIORITY enumeration and PNMI_CALLBACK prototype to headers
svn path=/trunk/; revision=35103
2008-08-04 15:48:46 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KdRefreshDebuggerNotPresent(VOID)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
|
|
|
/* Just return whatever was set previously -- FIXME! */
|
|
|
|
return KdDebuggerNotPresent;
|
|
|
|
}
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2006-09-07 22:38:06 +00:00
|
|
|
NTSTATUS
|
2008-11-29 20:47:48 +00:00
|
|
|
NTAPI
|
2005-04-25 14:44:48 +00:00
|
|
|
KdDisableDebugger(VOID)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Raise IRQL */
|
|
|
|
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* TODO: Disable any breakpoints */
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Disable the Debugger */
|
|
|
|
KdDebuggerEnabled = FALSE;
|
2016-10-06 19:01:33 +00:00
|
|
|
SharedUserData->KdDebuggerEnabled = FALSE;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Lower the IRQL */
|
|
|
|
KeLowerIrql(OldIrql);
|
2006-09-07 22:38:06 +00:00
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
return STATUS_SUCCESS;
|
2005-04-25 14:44:48 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:17:22 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KdEnableDebuggerWithLock(IN BOOLEAN NeedLock)
|
|
|
|
{
|
|
|
|
return STATUS_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2006-09-07 22:38:06 +00:00
|
|
|
NTSTATUS
|
2008-11-29 20:47:48 +00:00
|
|
|
NTAPI
|
2005-04-25 14:44:48 +00:00
|
|
|
KdEnableDebugger(VOID)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Raise IRQL */
|
|
|
|
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* TODO: Re-enable any breakpoints */
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Enable the Debugger */
|
|
|
|
KdDebuggerEnabled = TRUE;
|
2016-10-06 19:01:33 +00:00
|
|
|
SharedUserData->KdDebuggerEnabled = TRUE;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* Lower the IRQL */
|
|
|
|
KeLowerIrql(OldIrql);
|
2006-09-07 22:38:06 +00:00
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
return STATUS_SUCCESS;
|
2005-04-25 14:44:48 +00:00
|
|
|
}
|
|
|
|
|
2007-03-04 19:54:39 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2007-03-04 19:20:03 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KdSystemDebugControl(IN SYSDBG_COMMAND Command,
|
|
|
|
IN PVOID InputBuffer,
|
|
|
|
IN ULONG InputBufferLength,
|
|
|
|
OUT PVOID OutputBuffer,
|
|
|
|
IN ULONG OutputBufferLength,
|
|
|
|
IN OUT PULONG ReturnLength,
|
|
|
|
IN KPROCESSOR_MODE PreviousMode)
|
|
|
|
{
|
|
|
|
/* HACK */
|
2017-12-14 10:43:57 +00:00
|
|
|
return KdpServiceDispatcher(Command,
|
|
|
|
InputBuffer,
|
|
|
|
InputBufferLength,
|
|
|
|
PreviousMode);
|
2007-03-04 19:20:03 +00:00
|
|
|
}
|
|
|
|
|
2006-09-17 07:06:35 +00:00
|
|
|
PKDEBUG_ROUTINE KiDebugRoutine = KdpEnterDebuggerException;
|
|
|
|
|
2020-03-07 16:18:33 +00:00
|
|
|
CODE_SEG("INIT")
|
|
|
|
PCHAR
|
|
|
|
NTAPI
|
|
|
|
KdpGetDebugMode(PCHAR Currentp2)
|
|
|
|
{
|
|
|
|
PCHAR p1, p2 = Currentp2;
|
|
|
|
ULONG Value;
|
|
|
|
|
|
|
|
/* Check for Screen Debugging */
|
|
|
|
if (!_strnicmp(p2, "SCREEN", 6))
|
|
|
|
{
|
|
|
|
/* Enable It */
|
|
|
|
p2 += 6;
|
|
|
|
KdpDebugMode.Screen = TRUE;
|
|
|
|
}
|
|
|
|
/* Check for Serial Debugging */
|
|
|
|
else if (!_strnicmp(p2, "COM", 3))
|
|
|
|
{
|
|
|
|
/* Gheck for a valid Serial Port */
|
|
|
|
p2 += 3;
|
|
|
|
if (*p2 != ':')
|
|
|
|
{
|
|
|
|
Value = (ULONG)atol(p2);
|
|
|
|
if (Value > 0 && Value < 5)
|
|
|
|
{
|
|
|
|
/* Valid port found, enable Serial Debugging */
|
|
|
|
KdpDebugMode.Serial = TRUE;
|
|
|
|
|
|
|
|
/* Set the port to use */
|
|
|
|
SerialPortNumber = Value;
|
|
|
|
KdpPort = Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Value = strtoul(p2 + 1, NULL, 0);
|
|
|
|
if (Value)
|
|
|
|
{
|
|
|
|
KdpDebugMode.Serial = TRUE;
|
|
|
|
SerialPortInfo.Address = UlongToPtr(Value);
|
|
|
|
SerialPortNumber = 0;
|
|
|
|
KdpPort = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check for Debug Log Debugging */
|
|
|
|
else if (!_strnicmp(p2, "FILE", 4))
|
|
|
|
{
|
|
|
|
/* Enable It */
|
|
|
|
p2 += 4;
|
|
|
|
KdpDebugMode.File = TRUE;
|
|
|
|
if (*p2 == ':')
|
|
|
|
{
|
|
|
|
p2++;
|
|
|
|
p1 = p2;
|
|
|
|
while (*p2 != '\0' && *p2 != ' ') p2++;
|
|
|
|
KdpLogFileName.MaximumLength = KdpLogFileName.Length = p2 - p1;
|
|
|
|
KdpLogFileName.Buffer = p1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check for BOCHS Debugging */
|
|
|
|
else if (!_strnicmp(p2, "BOCHS", 5))
|
|
|
|
{
|
|
|
|
/* Enable It */
|
|
|
|
p2 += 5;
|
|
|
|
KdpDebugMode.Bochs = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p2;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:39:37 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KdDebuggerInitialize0(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
|
|
|
{
|
2020-03-07 16:18:33 +00:00
|
|
|
ULONG Value;
|
|
|
|
ULONG i;
|
|
|
|
PCHAR CommandLine, Port = NULL, BaudRate = NULL, Irq = NULL;
|
|
|
|
|
|
|
|
if (LoaderBlock)
|
|
|
|
{
|
|
|
|
/* Check if we have a command line */
|
|
|
|
CommandLine = LoaderBlock->LoadOptions;
|
|
|
|
if (CommandLine)
|
|
|
|
{
|
|
|
|
/* Upcase it */
|
|
|
|
_strupr(CommandLine);
|
|
|
|
|
|
|
|
/* Get the port and baud rate */
|
|
|
|
Port = strstr(CommandLine, "DEBUGPORT");
|
|
|
|
BaudRate = strstr(CommandLine, "BAUDRATE");
|
|
|
|
Irq = strstr(CommandLine, "IRQ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we got the /DEBUGPORT parameter(s) */
|
|
|
|
while (Port)
|
|
|
|
{
|
|
|
|
/* Move past the actual string, to reach the port*/
|
|
|
|
Port += sizeof("DEBUGPORT") - 1;
|
|
|
|
|
|
|
|
/* Now get past any spaces and skip the equal sign */
|
|
|
|
while (*Port == ' ') Port++;
|
|
|
|
Port++;
|
|
|
|
|
|
|
|
/* Get the debug mode and wrapper */
|
|
|
|
Port = KdpGetDebugMode(Port);
|
|
|
|
Port = strstr(Port, "DEBUGPORT");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use serial port then */
|
|
|
|
if (KdpDebugMode.Value == 0)
|
|
|
|
KdpDebugMode.Serial = TRUE;
|
|
|
|
|
|
|
|
/* Check if we got a baud rate */
|
|
|
|
if (BaudRate)
|
|
|
|
{
|
|
|
|
/* Move past the actual string, to reach the rate */
|
|
|
|
BaudRate += sizeof("BAUDRATE") - 1;
|
|
|
|
|
|
|
|
/* Now get past any spaces */
|
|
|
|
while (*BaudRate == ' ') BaudRate++;
|
|
|
|
|
|
|
|
/* And make sure we have a rate */
|
|
|
|
if (*BaudRate)
|
|
|
|
{
|
|
|
|
/* Read and set it */
|
|
|
|
Value = atol(BaudRate + 1);
|
|
|
|
if (Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check Serial Port Settings [IRQ] */
|
|
|
|
if (Irq)
|
|
|
|
{
|
|
|
|
/* Move past the actual string, to reach the rate */
|
|
|
|
Irq += sizeof("IRQ") - 1;
|
|
|
|
|
|
|
|
/* Now get past any spaces */
|
|
|
|
while (*Irq == ' ') Irq++;
|
|
|
|
|
|
|
|
/* And make sure we have an IRQ */
|
|
|
|
if (*Irq)
|
|
|
|
{
|
|
|
|
/* Read and set it */
|
|
|
|
Value = atol(Irq + 1);
|
|
|
|
if (Value) KdpPortIrq = Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call Providers at Phase 0 */
|
|
|
|
for (i = 0; i < KdMax; i++)
|
|
|
|
{
|
|
|
|
InitRoutines[i](&DispatchTable[i], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
2020-03-07 10:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KdDebuggerInitialize1(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
|
|
|
{
|
2020-03-07 17:00:20 +00:00
|
|
|
PLIST_ENTRY CurrentEntry;
|
|
|
|
PKD_DISPATCH_TABLE CurrentTable;
|
|
|
|
|
|
|
|
/* Call the registered handlers */
|
|
|
|
CurrentEntry = KdProviders.Flink;
|
|
|
|
while (CurrentEntry != &KdProviders)
|
|
|
|
{
|
|
|
|
/* Get the current table */
|
|
|
|
CurrentTable = CONTAINING_RECORD(CurrentEntry,
|
|
|
|
KD_DISPATCH_TABLE,
|
|
|
|
KdProvidersList);
|
|
|
|
|
|
|
|
/* Call it */
|
|
|
|
CurrentTable->KdpInitRoutine(CurrentTable, 1);
|
|
|
|
|
|
|
|
/* Next Table */
|
|
|
|
CurrentEntry = CurrentEntry->Flink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the Wrapper Init Routine */
|
|
|
|
if (WrapperInitRoutine)
|
|
|
|
WrapperTable.KdpInitRoutine(&WrapperTable, 1);
|
|
|
|
return STATUS_SUCCESS;
|
2020-03-07 10:39:37 +00:00
|
|
|
}
|
|
|
|
|
2005-04-25 14:44:48 +00:00
|
|
|
/* EOF */
|