[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 07/45] windbg: added chardev
From: |
Mihail Abakumov |
Subject: |
[Qemu-devel] [PATCH v3 07/45] windbg: added chardev |
Date: |
Tue, 21 Nov 2017 17:07:55 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Added chardev for listening to windbg. Target device is a parameter in the
'-windbg' option.
Signed-off-by: Mihail Abakumov <address@hidden>
Acked-by: Alistair Francis <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
Signed-off-by: Dmitriy Koltunov <address@hidden>
---
windbgstub.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/windbgstub.c b/windbgstub.c
index 0863da73fd..e30b8500e0 100755
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -20,12 +20,26 @@
typedef struct WindbgState {
bool is_loaded;
+ CharBackend chr;
+
uint32_t ctrl_packet_id;
uint32_t data_packet_id;
} WindbgState;
static WindbgState *windbg_state;
+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)
+{
+ if (windbg_state->is_loaded) {
+ /* T0D0: parse data */
+ }
+}
+
static void windbg_exit(void)
{
g_free(windbg_state);
@@ -33,15 +47,31 @@ 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->ctrl_packet_id = RESET_PACKET_ID;
windbg_state->data_packet_id = INITIAL_PACKET_ID;
+ chr = qemu_chr_new_noreplay(WINDBG, device);
+ 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;
}
- Re: [Qemu-devel] [PATCH v3 01/45] windbg: added empty windbgstub files, (continued)
- [Qemu-devel] [PATCH v3 06/45] windbg: added WindbgState, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 07/45] windbg: added chardev,
Mihail Abakumov <=
- [Qemu-devel] [PATCH v3 10/45] windbg: structures for parsing data stream, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 08/45] windbg: hook to wrmsr operation, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 09/45] windbg: handler of fs/gs register, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 11/45] windbg: parsing data stream, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 12/45] windbg: send data and control packets, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 14/45] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 13/45] windbg: handler of parsing context, Mihail Abakumov, 2017/11/21
- [Qemu-devel] [PATCH v3 15/45] windbg: sized data buffer, Mihail Abakumov, 2017/11/21