Skip to contentSkip to conversation

PATCH: allow i386 debugging when segment offset != 0

Qemu-devel Eddie Kohler 1 participant 1 message Mar 6, 2008

lore
Share & tools
lore
#0 lore raw

Hi all,

This patch makes QEMU's gdb debugging stub and CPU breakpoints work when the segment offset is not 0.

Previously, the debugging stub assumed the segment offset was 0, leading to very odd behavior.

This patch assumes that the code segment and data segment have the same offset. This is a reasonable assumption. Making the code work for different code and data offsets would be more invasive.

Please accept this patch (this is a resend.)

Eddie Kohler

Index: target-i386/helper2.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/helper2.c,v retrieving revision 1.62

helper2.c +1 -0
diff -u -r1.62 helper2.c
@@ -1081,6 +1081,7 @@
 {
     uint32_t pde_addr, pte_addr;
     uint32_t pde, pte, paddr, page_offset, page_size;
+    addr += env->segs[R_DS].base;
 
     if (env->cr[4] & CR4_PAE_MASK) {
         uint32_t pdpe_addr, pde_addr, pte_addr;

Index: target-i386/translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/translate.c,v retrieving revision 1.79

translate.c +1 -1
diff -u -r1.79 translate.c
@@ -6740,7 +6740,7 @@
     for(;;) {
         if (env->nb_breakpoints > 0) {
             for(j = 0; j < env->nb_breakpoints; j++) {
-                if (env->breakpoints[j] == pc_ptr) {
+                if (env->breakpoints[j] == pc_ptr - dc->cs_base) {
                     gen_debug(dc, pc_ptr - dc->cs_base);
                     break;
                 }