mirror of
https://github.com/reactos/reactos.git
synced 2026-10-04 08:43:10 +08:00
- Re-enable the breakpoint in vDbgPrintExWithPrefixInternal() as this works properly now. Without this breakpoint some break-in requests got lost if the break-in occurred when handling a debug print (happened a lot at boot). - Implement Command String support for DbgCommandString() -- we now handle every debug service call. - Implement NtSetDebugFilterState() and NtQueryDebugFilterState() for KD, meaning we now support debug filters properly. - Implement KdRefreshDebuggerNotPresent(), KdChangeOption() and KdPowerTransition(). Stub KdSystemDebugControl() to return error status instead of hanging the system. - Stub the rest of the KD API to print a warning and return a failure packet instead of hanging. - Set and respect KdpContextSent when getting and setting the thread context -- WinDbg doesn't seem to rely on this, but better safe than sorry. - Support MP when getting and setting the thread context too -- if the context is operation is for another processor than the current, just get it through the KiProcessorBlock array. - Initialize the MajorVersion in the KD version block more properly -- the high byte is the major identifier (0 for NT). Add the required DBGKD_MAJOR_TYPES enumeration to wdbgexts.h. - Simplify setting and clearing the InDbgPrint flag in the TEB to minimize the impact on kernel execution; use 2 dedicated routines instead of a generic one. - KdpSymbol doesn't return anything, so don't return an ignore status from KdpReportLoadSymbolsStateChange. - Expose the KdpDefaultRetries and Kd_WIN2000_Mask variables to the registry and add them to KDBG too (unused there). - No reason to implement KdpSysGetVersion per architecture; move it back to the generic code. - Add some ARM offsets to the debugger data block that (N/A on other architectures). - Fix the default size of the DbgPrint log buffer for free builds to save some space. It should be 4 KB for a free build and 32 KB for a checked build. - Move KeDisableInterrupts to cpu.c as it fits here more than in the IRQ support code in irqobj.c. - Use KeDisableInterrupts in KeFreezeExecution instead of checking the x86 EFLAG directly. svn path=/trunk/; revision=43912
122 lines
3.0 KiB
C
122 lines
3.0 KiB
C
/*
|
|
* PROJECT: ReactOS Kernel
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
* FILE: ntoskrnl/kd64/kdlock.c
|
|
* PURPOSE: KD64 Port Lock and Breakin Support
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
*/
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
#include <ntoskrnl.h>
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
|
|
|
VOID
|
|
NTAPI
|
|
KdpPortLock(VOID)
|
|
{
|
|
/* Acquire the lock */
|
|
KiAcquireSpinLock(&KdpDebuggerLock);
|
|
}
|
|
|
|
VOID
|
|
NTAPI
|
|
KdpPortUnlock(VOID)
|
|
{
|
|
/* Release the lock */
|
|
KiReleaseSpinLock(&KdpDebuggerLock);
|
|
}
|
|
|
|
BOOLEAN
|
|
NTAPI
|
|
KdpPollBreakInWithPortLock(VOID)
|
|
{
|
|
BOOLEAN DoBreak = FALSE;
|
|
|
|
/* First make sure that KD is enabled */
|
|
if (KdDebuggerEnabled)
|
|
{
|
|
/* Check if a CTRL-C is in the queue */
|
|
if (KdpContext.KdpControlCPending)
|
|
{
|
|
/* Set it and prepare for break */
|
|
DoBreak = TRUE;
|
|
KdpContext.KdpControlCPending = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* Now get a packet */
|
|
if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL) == KdPacketReceived)
|
|
{
|
|
/* Successful breakin */
|
|
DoBreak = TRUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Tell the caller to do a break */
|
|
return DoBreak;
|
|
}
|
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
BOOLEAN
|
|
NTAPI
|
|
KdPollBreakIn(VOID)
|
|
{
|
|
BOOLEAN DoBreak = FALSE, Enable;
|
|
|
|
/* First make sure that KD is enabled */
|
|
if (KdDebuggerEnabled)
|
|
{
|
|
/* Disable interrupts */
|
|
Enable = KeDisableInterrupts();
|
|
|
|
/* Check if a CTRL-C is in the queue */
|
|
if (KdpContext.KdpControlCPending)
|
|
{
|
|
/* Set it and prepare for break */
|
|
KdpControlCPressed = TRUE;
|
|
DoBreak = TRUE;
|
|
KdpContext.KdpControlCPending = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* Try to acquire the lock */
|
|
if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock))
|
|
{
|
|
/* Now get a packet */
|
|
if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL) == KdPacketReceived)
|
|
{
|
|
/* Successful breakin */
|
|
DoBreak = TRUE;
|
|
KdpControlCPressed = TRUE;
|
|
}
|
|
|
|
/* Let go of the port */
|
|
KdpPortUnlock();
|
|
}
|
|
}
|
|
|
|
/* Re-enable interrupts if they were enabled previously */
|
|
if (Enable) _enable();
|
|
}
|
|
|
|
/* Tell the caller to do a break */
|
|
return DoBreak;
|
|
}
|