Patchwork [v3,05/39] windbg: add WindbgState

login
register
mail settings
Submitter Mihail Abakumov
Date Dec. 6, 2018, 11:59 a.m.
Message ID <154409754657.5432.6639535359256257810.stgit@Misha-PC.lan02.inno>
Download mbox | patch
Permalink /patch/673983/
State New
Headers show

Comments

Mihail Abakumov - Dec. 6, 2018, 11:59 a.m.
Add definition of the WindbgState struct and its initialization.

Signed-off-by: Mikhail Abakumov <mikhail.abakumov@ispras.ru>
Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>
---
 windbgstub.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Patch

diff --git a/windbgstub.c b/windbgstub.c
index 4673703b66..b073cc6a3f 100644
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -13,7 +13,38 @@ 
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
 
+typedef struct WindbgState {
+    bool is_loaded;
+    bool catched_breakin_byte;
+    uint32_t wait_packet_type;
+    uint32_t curr_packet_id;
+} WindbgState;
+
+static WindbgState *windbg_state;
+
+static void windbg_state_clean(WindbgState *state)
+{
+    state->is_loaded = false;
+    state->catched_breakin_byte = false;
+    state->wait_packet_type = 0;
+    state->curr_packet_id = INITIAL_PACKET_ID | SYNC_PACKET_ID;
+}
+
+static void windbg_exit(void)
+{
+    g_free(windbg_state);
+}
+
 int windbg_server_start(const char *device)
 {
+    if (windbg_state) {
+        WINDBG_ERROR("Multiple instances of windbg are not supported.");
+        exit(1);
+    }
+
+    windbg_state = g_new0(WindbgState, 1);
+    windbg_state_clean(windbg_state);
+
+    atexit(windbg_exit);
     return 0;
 }