* PROJECT: ReactOS kernel
* FILE: drivers/base/kddll/kddll.c
* PURPOSE: Base functions for the kernel debugger.
- * PROGRAMMER: Timo Kreuzer (timo.kreuzer@ewactos.org)
+ * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
#include "kddll.h"
-#define NDEBUG
-#include <debug.h>
-
/* GLOBALS ********************************************************************/
-PFNDBGPRNT KdpDbgPrint = NULL;
ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID;
-ULONG RemotePacketId = INITIAL_PACKET_ID;
+ULONG RemotePacketId = INITIAL_PACKET_ID;
/* PRIVATE FUNCTIONS **********************************************************/
ULONG Checksum;
/* Special handling for breakin packet */
- if(PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
+ if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
{
return KdpPollBreakIn();
}
CurrentPacketId ^= 1;
return KDP_PACKET_RECEIVED;
}
- /* That's not what we were waiting for, start over. */
+ /* That's not what we were waiting for, start over */
continue;
case PACKET_TYPE_KD_RESET:
- KDDBGPRINT("KdReceivePacket - got a reset packet\n");
- KdpSendControlPacket(PACKET_TYPE_KD_RESET, 0);
+ KDDBGPRINT("KdReceivePacket - got PACKET_TYPE_KD_RESET\n");
CurrentPacketId = INITIAL_PACKET_ID;
- RemotePacketId = INITIAL_PACKET_ID;
+ RemotePacketId = INITIAL_PACKET_ID;
+ KdpSendControlPacket(PACKET_TYPE_KD_RESET, 0);
/* Fall through */
case PACKET_TYPE_KD_RESEND:
default:
KDDBGPRINT("KdReceivePacket - got unknown control packet\n");
- return KDP_PACKET_RESEND;
+ /* We got an invalid packet, ignore it and start over */
+ continue;
}
}
/* Receive the message header data */
KdStatus = KdpReceiveBuffer(MessageHeader->Buffer,
- MessageHeader->Length);
+ MessageHeader->Length);
if (KdStatus != KDP_PACKET_RECEIVED)
{
/* Didn't receive data. Packet needs to be resent. */
/* Calculate the length of the message data */
*DataLength = Packet.ByteCount - MessageHeader->Length;
- /* Shall we receive messsage data? */
+ /* Shall we receive message data? */
if (MessageData)
{
/* Set the length of the message data */
if (Packet.Checksum != Checksum)
{
KDDBGPRINT("KdReceivePacket - wrong cheksum, got %x, calculated %x\n",
- Packet.Checksum, Checksum);
+ Packet.Checksum, Checksum);
KdpSendControlPacket(PACKET_TYPE_KD_RESEND, 0);
continue;
}
/* Send the message header */
KdpSendBuffer(MessageHeader->Buffer, MessageHeader->Length);
- /* If we have meesage data, also send it */
+ /* If we have message data, also send it */
if (MessageData)
{
KdpSendBuffer(MessageData->Buffer, MessageData->Length);
{
/* Packet received, we can quit the loop */
CurrentPacketId &= ~SYNC_PACKET_ID;
+ Retries = KdContext->KdpDefaultRetries;
break;
}
else if (KdStatus == KDP_PACKET_TIMEOUT)
*/
if (Retries == 0)
{
- if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
+ ULONG MessageId = *(PULONG)MessageHeader->Buffer;
+ switch (PacketType)
{
- return;
+ case PACKET_TYPE_KD_DEBUG_IO:
+ {
+ if (MessageId != DbgKdPrintStringApi) continue;
+ break;
+ }
+
+ case PACKET_TYPE_KD_STATE_CHANGE32:
+ case PACKET_TYPE_KD_STATE_CHANGE64:
+ {
+ if (MessageId != DbgKdLoadSymbolsStateChange) continue;
+ break;
+ }
+
+ case PACKET_TYPE_KD_FILE_IO:
+ {
+ if (MessageId != DbgKdCreateFileApi) continue;
+ break;
+ }
}
+
+ /* Reset debugger state */
+ KD_DEBUGGER_NOT_PRESENT = TRUE;
+ SharedUserData->KdDebuggerEnabled &= ~0x00000002;
+ CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID;
+ RemotePacketId = INITIAL_PACKET_ID;
+
+ return;
}
}
// else (KdStatus == KDP_PACKET_RESEND) /* Resend the packet */