qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/39] windbg: add chardev


From: Mikhail Abakumov
Subject: [Qemu-devel] [PATCH 06/39] windbg: add chardev
Date: Thu, 29 Nov 2018 17:28:03 +0300
User-agent: StGit/0.17.1-dirty

Add chardev for listening to windbg client. Target device is a parameter
in the '-windbg' option.

Signed-off-by: Mikhail Abakumov <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
 windbgstub.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/windbgstub.c b/windbgstub.c
index b073cc6a3f..85e2215f73 100644
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -10,6 +10,10 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "chardev/char.h"
+#include "chardev/char-fe.h"
+#include "qemu/cutils.h"
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
 
@@ -18,6 +22,8 @@ typedef struct WindbgState {
     bool catched_breakin_byte;
     uint32_t wait_packet_type;
     uint32_t curr_packet_id;
+
+    CharBackend chr;
 } WindbgState;
 
 static WindbgState *windbg_state;
@@ -30,6 +36,15 @@ static void windbg_state_clean(WindbgState *state)
     state->curr_packet_id = INITIAL_PACKET_ID | SYNC_PACKET_ID;
 }
 
+static int windbg_chr_can_receive(void *opaque)
+{
+    return PACKET_MAX_SIZE;
+}
+
+static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size)
+{
+}
+
 static void windbg_exit(void)
 {
     g_free(windbg_state);
@@ -37,14 +52,30 @@ static void windbg_exit(void)
 
 int windbg_server_start(const char *device)
 {
+    Chardev *chr = NULL;
+
     if (windbg_state) {
         WINDBG_ERROR("Multiple instances of windbg are not supported.");
         exit(1);
     }
 
+    if (!strstart(device, "pipe:", NULL)) {
+        WINDBG_ERROR("Unsupported device. Supported only pipe.");
+        exit(1);
+    }
+
     windbg_state = g_new0(WindbgState, 1);
     windbg_state_clean(windbg_state);
 
+    chr = qemu_chr_new_noreplay("windbg", device, true);
+    if (!chr) {
+        return -1;
+    }
+
+    qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort);
+    qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive,
+                             windbg_chr_receive, NULL, NULL, NULL, NULL, true);
+
     atexit(windbg_exit);
     return 0;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]