Author: hbelusca
Date: Fri Dec 25 18:43:16 2015
New Revision: 70417

URL: http://svn.reactos.org/svn/reactos?rev=70417&view=rev
Log:
[KDCOM]
For MSVC builds (using KDCOM kd64 WinDbg protocol): Bail out for droppable 
packets after a given number of retries, if no debugger is attached (list of 
droppable packets can be found in 
http://articles.sysprogs.org/kdvmware/kdcom.shtml section "KDCOM protocol", 
subsection "Droppable packets").
CORE-10541 #resolve #comment Finally fixed in revision r70417!
CORE-7106

Modified:
    trunk/reactos/drivers/base/kdcom/kddll.c

Modified: trunk/reactos/drivers/base/kdcom/kddll.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kdcom/kddll.c?rev=70417&r1=70416&r2=70417&view=diff
==============================================================================
--- trunk/reactos/drivers/base/kdcom/kddll.c    [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kdcom/kddll.c    [iso-8859-1] Fri Dec 25 
18:43:16 2015
@@ -11,7 +11,7 @@
 /* GLOBALS 
********************************************************************/
 
 ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID;
-ULONG RemotePacketId = INITIAL_PACKET_ID;
+ULONG RemotePacketId  = INITIAL_PACKET_ID;
 
 
 /* PRIVATE FUNCTIONS 
**********************************************************/
@@ -90,7 +90,7 @@
     ULONG Checksum;
 
     /* Special handling for breakin packet */
-    if(PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
+    if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
     {
         return KdpPollBreakIn();
     }
@@ -170,14 +170,14 @@
                         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");
+                    KDDBGPRINT("KdReceivePacket - got PACKET_TYPE_KD_RESET\n");
+                    CurrentPacketId = INITIAL_PACKET_ID;
+                    RemotePacketId  = INITIAL_PACKET_ID;
                     KdpSendControlPacket(PACKET_TYPE_KD_RESET, 0);
-                    CurrentPacketId = INITIAL_PACKET_ID;
-                    RemotePacketId = INITIAL_PACKET_ID;
                     /* Fall through */
 
                 case PACKET_TYPE_KD_RESEND:
@@ -187,7 +187,8 @@
 
                 default:
                     KDDBGPRINT("KdReceivePacket - got unknown control 
packet\n");
-                    return KDP_PACKET_RESEND;
+                    /* We got an invalid packet, ignore it and start over */
+                    continue;
             }
         }
 
@@ -218,7 +219,7 @@
 
         /* 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. */
@@ -277,7 +278,7 @@
         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;
         }
@@ -369,6 +370,7 @@
         {
             /* Packet received, we can quit the loop */
             CurrentPacketId &= ~SYNC_PACKET_ID;
+            Retries = KdContext->KdpDefaultRetries;
             break;
         }
         else if (KdStatus == KDP_PACKET_TIMEOUT)
@@ -383,10 +385,36 @@
              */
             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 */


Reply via email to