Patchwork [v3,08/39] windbg: implement windbg_on_load

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

Comments

Mihail Abakumov - Dec. 6, 2018, 11:59 a.m.
Define addresses that must be found on loading stage.

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

Patch

diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c
index e55054c63d..1c1631d7c1 100644
--- a/target/i386/windbgstub.c
+++ b/target/i386/windbgstub.c
@@ -12,11 +12,57 @@ 
 #include "qemu/osdep.h"
 #include "exec/windbgstub-utils.h"
 
+static InitedAddr KPCR;
+#ifdef TARGET_X86_64
+static InitedAddr kdDebuggerDataBlock;
+#else  /* TARGET_I386 */
+static InitedAddr kdVersion;
+#endif /* TARGET_I386 */
+
+static bool find_KPCR(CPUState *cs)
+{
+    return KPCR.is_init;
+}
+
+#ifdef TARGET_X86_64
+static bool find_kdDebuggerDataBlock(CPUState *cs)
+{
+    return kdDebuggerDataBlock.is_init;
+}
+#else  /* TARGET_I386 */
+static bool find_kdVersion(CPUState *cs)
+{
+    return kdVersion.is_init;
+}
+#endif /* TARGET_I386 */
+
 bool windbg_on_load(void)
 {
-    return false;
+    CPUState *cs = qemu_get_cpu(0);
+
+    if (!find_KPCR(cs)) {
+        return false;
+    }
+
+#ifdef TARGET_X86_64
+    if (!find_kdDebuggerDataBlock(cs)) {
+        return false;
+    }
+#else
+    if (!find_kdVersion(cs)) {
+        return false;
+    }
+#endif
+
+    return true;
 }
 
 void windbg_on_reset(void)
 {
+    KPCR.is_init = false;
+#ifdef TARGET_X86_64
+    kdDebuggerDataBlock.is_init = false;
+#else
+    kdVersion.is_init = false;
+#endif
 }