While far from ideal, that seems to be what GDB and most other debuggers expect.
Signed-off-by: Ismael Luceno <ism...@iodev.co.uk> --- target-i386/gdbstub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target-i386/gdbstub.c b/target-i386/gdbstub.c index ff99cfb..754ea77 100644 --- a/target-i386/gdbstub.c +++ b/target-i386/gdbstub.c @@ -70,8 +70,11 @@ int x86_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) case IDX_IP_REG: if (TARGET_LONG_BITS == 64 && env->hflags & HF_CS64_MASK) { return gdb_get_reg64(mem_buf, env->eip); - } else { + } else if (env->hflags & HF_PE_MASK) { return gdb_get_reg32(mem_buf, env->eip); + } else { + return gdb_get_reg32(mem_buf, (env->segs[R_CS].selector << 4) + + env->eip); } case IDX_FLAGS_REG: return gdb_get_reg32(mem_buf, env->eflags); -- 2.4.5