[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 26/39] windbg: implement kd_api_get_context and k
From: |
Mikhail Abakumov |
Subject: |
[Qemu-devel] [PATCH v3 26/39] windbg: implement kd_api_get_context and kd_api_set_context |
Date: |
Thu, 06 Dec 2018 15:01:04 +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;
- [Qemu-devel] [PATCH v3 16/39] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE, (continued)
- [Qemu-devel] [PATCH v3 16/39] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 17/39] windbg: generate ExceptionStateChange and LoadSymbolsStateChange, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 18/39] windbg: implement windbg_process_control_packet, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 19/39] windbg: implement windbg_process_data_packet, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 20/39] windbg: implement windbg_process_manipulate_packet, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 21/39] windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 22/39] windbg: some kernel structures, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 23/39] windbg: add helper functions, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 24/39] windbg: [de]serialization cpu context, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 25/39] windbg: [de]serialization cpu spec registers, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 26/39] windbg: implement kd_api_get_context and kd_api_set_context,
Mikhail Abakumov <=
- [Qemu-devel] [PATCH v3 27/39] windbg: implement kd_api_get_context_ex and kd_api_set_context_ex, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 28/39] windbg: implement kd_api_read_control_space and kd_api_write_control_space, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 30/39] windbg: debug exception subscribing, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 29/39] windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 31/39] windbg: implement kd_api_continue, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 32/39] windbg: implement kd_api_read_io_space and kd_api_write_io_space, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 33/39] windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 35/39] windbg: implement kd_api_read_msr and kd_api_write_msr, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 34/39] windbg: implement kd_api_get_version, Mikhail Abakumov, 2018/12/06
- [Qemu-devel] [PATCH v3 36/39] windbg: implement kd_api_search_memory, Mikhail Abakumov, 2018/12/06