[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/39] windbg: add chardev
From: |
Mikhail Abakumov |
Subject: |
[Qemu-devel] [PATCH v3 06/39] windbg: add chardev |
Date: |
Thu, 06 Dec 2018 14:59:12 +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;
}
- [Qemu-devel] [PATCH v3 00/39] Windbg supporting, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 01/39] windbg: add empty windbgstub files, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 02/39] windbg: add windbg's KD header file, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 03/39] windbg: add -windbg option, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 04/39] windbg: add helper features, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 05/39] windbg: add WindbgState, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 06/39] windbg: add chardev,
Mikhail Abakumov <=
- [Qemu-devel] [PATCH v3 07/39] windbg: hook to wrmsr operation, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 08/39] windbg: implement windbg_on_load, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 09/39] windbg: implement find_KPCR, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 10/39] windbg: implement find_kdVersion, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 11/39] windbg: add windbg_search_vmaddr, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 12/39] windbg: implement find_kdDebuggerDataBlock, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 13/39] windbg: parsing data stream, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 14/39] windbg: send data and control packets, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 15/39] windbg: handler of parsing context, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 16/39] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE, Mikhail Abakumov, 2018/12/06