Patchwork [v3,17/39] windbg: generate ExceptionStateChange and LoadSymbolsStateChange

login
register
mail settings
Submitter Mihail Abakumov
Date Dec. 6, 2018, noon
Message ID <154409761380.5432.1067124865535256250.stgit@Misha-PC.lan02.inno>
Download mbox | patch
Permalink /patch/674005/
State New
Headers show

Comments

Mihail Abakumov - Dec. 6, 2018, noon
Signed-off-by: Mikhail Abakumov <mikhail.abakumov@ispras.ru>
Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>
---
 include/exec/windbgstub-utils.h |    3 +++
 target/i386/windbgstub.c        |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

Patch

diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h
index a28068eecd..794cb387b0 100644
--- a/include/exec/windbgstub-utils.h
+++ b/include/exec/windbgstub-utils.h
@@ -67,6 +67,9 @@  typedef struct PacketData {
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_ls(CPUState *cs);
+
 bool windbg_on_load(void);
 void windbg_on_reset(void);
 
diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c
index b2ac7a6d5f..37c5805818 100644
--- a/target/i386/windbgstub.c
+++ b/target/i386/windbgstub.c
@@ -161,7 +161,6 @@  void windbg_on_reset(void)
 #endif
 }
 
-__attribute__ ((unused)) /* unused yet */
 static void kd_init_state_change(CPUState *cs, DBGKD_ANY_WAIT_STATE_CHANGE *sc)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -201,3 +200,35 @@  static void kd_init_state_change(CPUState *cs, DBGKD_ANY_WAIT_STATE_CHANGE *sc)
     memset(cr->InstructionStream, 0, DBGKD_MAXSTREAM);
     stw_p(&cr->InstructionCount, 0);
 }
+
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs)
+{
+    DBGKD_ANY_WAIT_STATE_CHANGE *sc = g_new0(DBGKD_ANY_WAIT_STATE_CHANGE, 1);
+    DBGKM_EXCEPTION_RECORD64 *exc = &sc->u.Exception.ExceptionRecord;
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    kd_init_state_change(cs, sc);
+
+    stl_p(&sc->NewState, DbgKdExceptionStateChange);
+    sttul_p(&exc->ExceptionAddress, env->eip);
+
+    /* TODO: Fix this hardcoded value. */
+    stl_p(&exc->ExceptionCode, 0x80000003);
+
+    return sc;
+}
+
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_ls(CPUState *cs)
+{
+    DBGKD_ANY_WAIT_STATE_CHANGE *sc = g_new0(DBGKD_ANY_WAIT_STATE_CHANGE, 1);
+
+    kd_init_state_change(cs, sc);
+
+    stl_p(&sc->NewState, DbgKdLoadSymbolsStateChange);
+
+    /* TODO: Path to load symbold (with extra array). */
+    stl_p(&sc->u.LoadSymbols.PathNameLength, 0);
+
+    return sc;
+}