qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2 26/39] windbg: implement kd_api_get_context and kd


From: Mikhail Abakumov
Subject: [Qemu-devel] [PATCH 2 26/39] windbg: implement kd_api_get_context and kd_api_set_context
Date: Wed, 05 Dec 2018 15:54:29 +0300
User-agent: StGit/0.17.1-dirty

Signed-off-by: Mikhail Abakumov <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
 include/exec/windbgstub-utils.h |    2 ++
 target/i386/windbgstub.c        |   27 +++++++++++++++++++++++++++
 windbgstub.c                    |    8 ++++++++
 3 files changed, 37 insertions(+)

diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h
index 638b2b9a6f..a88e013de9 100644
--- a/include/exec/windbgstub-utils.h
+++ b/include/exec/windbgstub-utils.h
@@ -69,6 +69,8 @@ const char *kd_pkt_type_name(int id);
 
 void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
+void kd_api_get_context(CPUState *cs, PacketData *pd);
+void kd_api_set_context(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
 
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c
index a1d27b8aca..900950495f 100644
--- a/target/i386/windbgstub.c
+++ b/target/i386/windbgstub.c
@@ -896,6 +896,33 @@ GEN_WINDBG_KSPEC_REGS_RW(windbg_read_ks_regs, false)
 __attribute__ ((unused)) /* unused yet */
 GEN_WINDBG_KSPEC_REGS_RW(windbg_write_ks_regs, true)
 
+void kd_api_get_context(CPUState *cs, PacketData *pd)
+{
+    int err;
+
+    pd->extra_size = sizeof(CPU_CONTEXT);
+    err = windbg_read_context(cs, pd->extra, pd->extra_size,
+                              0, sizeof(CPU_CONTEXT));
+
+    if (err) {
+        pd->extra_size = 0;
+        pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL;
+    }
+}
+
+void kd_api_set_context(CPUState *cs, PacketData *pd)
+{
+    int err;
+
+    err = windbg_write_context(cs, pd->extra, pd->extra_size,
+                               0, sizeof(CPU_CONTEXT));
+    pd->extra_size = 0;
+
+    if (err) {
+        pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL;
+    }
+}
+
 static bool find_KPCR(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
diff --git a/windbgstub.c b/windbgstub.c
index 46400d9bad..70ebf3c0ad 100644
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -157,6 +157,14 @@ static void windbg_process_manipulate_packet(WindbgState 
*state)
         kd_api_write_virtual_memory(cs, data);
         break;
 
+    case DbgKdGetContextApi:
+        kd_api_get_context(cs, data);
+        break;
+
+    case DbgKdSetContextApi:
+        kd_api_set_context(cs, data);
+        break;
+
     default:
         kd_api_unsupported(cs, data);
         break;




reply via email to

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