mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
608032bd08
Raise IRQL before entering debugger, so that KeAcquireSpinLockAtDpcLevel works as expected. - HIGH_LEVEL since we don't know where we are coming from. Do not try to read debug symbol from files in KDBG. - There is no reason that this works if Mm didn't map it in the first place.
124 lines
3.1 KiB
C
124 lines
3.1 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
|
|
{
|
|
KIRQL OldIrql;
|
|
/* Try to acquire the lock */
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
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();
|
|
}
|
|
KeLowerIrql(OldIrql);
|
|
}
|
|
|
|
/* Re-enable interrupts if they were enabled previously */
|
|
if (Enable) _enable();
|
|
}
|
|
|
|
/* Tell the caller to do a break */
|
|
return DoBreak;
|
|
}
|