diff mbox series

[10/39] windbg: implement find_kdVersion

Message ID 154350170644.8036.13476479435799387914.stgit@Misha-PC.lan02.inno
State New
Headers show
Series Windbg supporting | expand

Commit Message

Mikhail Abakumov Nov. 29, 2018, 2:28 p.m. UTC
Signed-off-by: Mikhail Abakumov <mikhail.abakumov@ispras.ru>
Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>
---
 target/i386/windbgstub.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c
index 15a90e521c..dc58f5a8cc 100644
--- a/target/i386/windbgstub.c
+++ b/target/i386/windbgstub.c
@@ -16,6 +16,7 @@ 
 #define OFFSET_KPCR_SELF 0x18
 #else  /* TARGET_I386 */
 #define OFFSET_KPCR_SELF 0x1C
+#define OFFSET_KPCR_VERSION 0x34
 #endif /* TARGET_I386 */
 
 #ifdef TARGET_X86_64
@@ -64,6 +65,16 @@  static bool find_kdDebuggerDataBlock(CPUState *cs)
 #else  /* TARGET_I386 */
 static bool find_kdVersion(CPUState *cs)
 {
+    if (!kdVersion.is_init && KPCR.is_init) {
+        kdVersion.addr = VMEM_ADDR(cs, KPCR.addr + OFFSET_KPCR_VERSION);
+        if (!kdVersion.addr) {
+            return false;
+        }
+        kdVersion.is_init = true;
+
+        DPRINTF("find kdVersion " FMT_ADDR, kdVersion.addr);
+    }
+
     return kdVersion.is_init;
 }
 #endif /* TARGET_I386 */