From 3608c3030af6af9580d2864722248f7ea3a21da8 Mon Sep 17 00:00:00 2001
From: Andrew Cook <ariscop@gmail.com>
Date: Tue, 19 Apr 2016 15:20:15 +1000
Subject: [PATCH] Don't wait for reply in kdgdb

---
 reactos/drivers/base/kdgdb/gdb_send.c | 163 ++++++++++++++--------------------
 1 file changed, 65 insertions(+), 98 deletions(-)

diff --git a/reactos/drivers/base/kdgdb/gdb_send.c b/reactos/drivers/base/kdgdb/gdb_send.c
index dfbc7b6..a3c9540 100644
--- a/reactos/drivers/base/kdgdb/gdb_send.c
+++ b/reactos/drivers/base/kdgdb/gdb_send.c
@@ -50,34 +50,23 @@ exception_code_to_gdb(NTSTATUS code, char* out)
 void
 send_gdb_packet(_In_ CHAR* Buffer)
 {
-    UCHAR ack;
-
-    do {
-        CHAR* ptr = Buffer;
-        CHAR check_sum = 0;
-
-        KdpSendByte('$');
-
-        /* Calculate checksum */
-        check_sum = 0;
-        while (*ptr)
-        {
-            check_sum += *ptr;
-            KdpSendByte(*ptr++);
-        }
-
-        /* append it */
-        KdpSendByte('#');
-        KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
-        KdpSendByte(hex_chars[check_sum & 0xf]);
-
-        /* Wait for acknowledgement */
-        if (KdpReceiveByte(&ack) != KdPacketReceived)
-        {
-            KD_DEBUGGER_NOT_PRESENT = TRUE;
-            break;
-        }
-    } while (ack != '+');
+    CHAR* ptr = Buffer;
+    CHAR check_sum = 0;
+
+    KdpSendByte('$');
+
+    /* Calculate checksum */
+    check_sum = 0;
+    while (*ptr)
+    {
+        check_sum += *ptr;
+        KdpSendByte(*ptr++);
+    }
+
+    /* append it */
+    KdpSendByte('#');
+    KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
+    KdpSendByte(hex_chars[check_sum & 0xf]);
 }
 
 void
@@ -85,82 +74,60 @@ send_gdb_memory(
     _In_ VOID* Buffer,
     _In_ size_t Length)
 {
-    UCHAR ack;
-
-    do {
-        CHAR* ptr = Buffer;
-        CHAR check_sum = 0;
-        size_t len = Length;
-        CHAR Byte;
-
-        KdpSendByte('$');
-
-        /* Send the data */
-        check_sum = 0;
-        while (len--)
-        {
-            Byte = hex_chars[(*ptr >> 4) & 0xf];
-            KdpSendByte(Byte);
-            check_sum += Byte;
-            Byte = hex_chars[*ptr++ & 0xf];
-            KdpSendByte(Byte);
-            check_sum += Byte;
-        }
-
-        /* append check sum */
-        KdpSendByte('#');
-        KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
-        KdpSendByte(hex_chars[check_sum & 0xf]);
-
-        /* Wait for acknowledgement */
-        if (KdpReceiveByte(&ack) != KdPacketReceived)
-        {
-            KD_DEBUGGER_NOT_PRESENT = TRUE;
-            break;
-        }
-    } while (ack != '+');
+    CHAR* ptr = Buffer;
+    CHAR check_sum = 0;
+    size_t len = Length;
+    CHAR Byte;
+
+    KdpSendByte('$');
+
+    /* Send the data */
+    check_sum = 0;
+    while (len--)
+    {
+        Byte = hex_chars[(*ptr >> 4) & 0xf];
+        KdpSendByte(Byte);
+        check_sum += Byte;
+        Byte = hex_chars[*ptr++ & 0xf];
+        KdpSendByte(Byte);
+        check_sum += Byte;
+    }
+
+    /* append check sum */
+    KdpSendByte('#');
+    KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
+    KdpSendByte(hex_chars[check_sum & 0xf]);
 }
 
 void
 gdb_send_debug_io(
     _In_ PSTRING String)
 {
-    UCHAR ack;
-
-    do {
-        CHAR* ptr = String->Buffer;
-        CHAR check_sum;
-        USHORT Length = String->Length;
-        CHAR Byte;
-
-        KdpSendByte('$');
-
-        KdpSendByte('O');
-
-        /* Send the data */
-        check_sum = 'O';
-        while (Length--)
-        {
-            Byte = hex_chars[(*ptr >> 4) & 0xf];
-            KdpSendByte(Byte);
-            check_sum += Byte;
-            Byte = hex_chars[*ptr++ & 0xf];
-            KdpSendByte(Byte);
-            check_sum += Byte;
-        }
-
-        /* append check sum */
-        KdpSendByte('#');
-        KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
-        KdpSendByte(hex_chars[check_sum & 0xf]);
-
-        /* Wait for acknowledgement */
-        if (KdpReceiveByte(&ack) != KdPacketReceived)
-        {
-            KD_DEBUGGER_NOT_PRESENT = TRUE;
-            break;
-        }
-    } while (ack != '+');
+    CHAR* ptr = String->Buffer;
+    CHAR check_sum;
+    USHORT Length = String->Length;
+    CHAR Byte;
+
+    KdpSendByte('$');
+
+    KdpSendByte('O');
+
+    /* Send the data */
+    check_sum = 'O';
+    while (Length--)
+    {
+        Byte = hex_chars[(*ptr >> 4) & 0xf];
+        KdpSendByte(Byte);
+        check_sum += Byte;
+        Byte = hex_chars[*ptr++ & 0xf];
+        KdpSendByte(Byte);
+        check_sum += Byte;
+    }
+
+    /* append check sum */
+    KdpSendByte('#');
+    KdpSendByte(hex_chars[(check_sum >> 4) & 0xf]);
+    KdpSendByte(hex_chars[check_sum & 0xf]);
 }
 
 void
-- 
2.7.3

