qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ismael Luceno <ismael@iodev.co.uk>
To: qemu-devel@nongnu.org
Cc: Ismael Luceno <ismael@iodev.co.uk>
Subject: [Qemu-devel] [PATCH] target-i386: gdbserver: Return CS:IP as EIP on 16-bit mode
Date: Tue, 14 Jul 2015 15:43:29 -0300	[thread overview]
Message-ID: <1436899409-27921-1-git-send-email-ismael@iodev.co.uk> (raw)

While far from ideal, that seems to be what GDB and most other debuggers expect.

Signed-off-by: Ismael Luceno <ismael@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

             reply	other threads:[~2015-07-14 18:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 18:43 Ismael Luceno [this message]
2015-07-23 18:35 ` [Qemu-devel] [PATCH] target-i386: gdbserver: Return CS:IP as EIP on 16-bit mode Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436899409-27921-1-git-send-email-ismael@iodev.co.uk \
    --to=ismael@iodev.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).