From 4f4e38ce40b9590d828ba1a326b9cd59da000e0c Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 3 Feb 2010 21:47:57 +0100 Subject: [PATCH] winedbg: Implemented is_step_over method for x86-64 CPU. --- programs/winedbg/be_x86_64.c | 57 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 4cc5162b167..a0e56371258 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -164,8 +164,61 @@ static const struct dbg_internal_var* be_x86_64_init_registers(CONTEXT* ctx) static unsigned be_x86_64_is_step_over_insn(const void* insn) { - dbg_printf("not done step_over_insn\n"); - return FALSE; + BYTE ch; + + for (;;) + { + if (!dbg_read_memory(insn, &ch, sizeof(ch))) return FALSE; + + switch (ch) + { + /* Skip all prefixes */ + case 0x2e: /* cs: */ + case 0x36: /* ss: */ + case 0x3e: /* ds: */ + case 0x26: /* es: */ + case 0x64: /* fs: */ + case 0x65: /* gs: */ + case 0x66: /* opcode size prefix */ + case 0x67: /* addr size prefix */ + case 0xf0: /* lock */ + case 0xf2: /* repne */ + case 0xf3: /* repe */ + insn = (const char*)insn + 1; + continue; + + /* Handle call instructions */ + case 0xcd: /* int */ + case 0xe8: /* call */ + case 0x9a: /* lcall : */ + return TRUE; + + case 0xff: /* call */ + if (!dbg_read_memory((const char*)insn + 1, &ch, sizeof(ch))) + return FALSE; + return (((ch & 0x38) == 0x10) || ((ch & 0x38) == 0x18)); + + /* Handle string instructions */ + case 0x6c: /* insb */ + case 0x6d: /* insw */ + case 0x6e: /* outsb */ + case 0x6f: /* outsw */ + case 0xa4: /* movsb */ + case 0xa5: /* movsw */ + case 0xa6: /* cmpsb */ + case 0xa7: /* cmpsw */ + case 0xaa: /* stosb */ + case 0xab: /* stosw */ + case 0xac: /* lodsb */ + case 0xad: /* lodsw */ + case 0xae: /* scasb */ + case 0xaf: /* scasw */ + return TRUE; + + default: + return FALSE; + } + } } static unsigned be_x86_64_is_function_return(const void* insn) -- 2.11.4.GIT