Skip to contentSkip to conversation

x86 breakpoints and memory examination

PATCH In review Eddie Kohler 2 participants 2 messages Jan 13, 2008 – Jan 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 breakpoints and memory examination

Hi all,

The following patch is useful for whole-system mode debugging and breakpoint setting on i386 QEMU. It seems like both breakpoints and memory examination used semi-physical addresses, in that neither took account of segment translation. This patch (relative to 0.9.1) adds segment translation.

I'm not sure this is the right way to do it (in fact, I'm sure that the memory examination patch is the WRONG way to do it) and would appreciate pointers or advice.

Thanks,
Eddie Kohler

target-i386/helper2.c +1 -0
diff -ru qemu-0.9.1/target-i386/helper2.c qemu-0.9.1-p/target-i386/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;
target-i386/translate.c +1 -1
diff -ru qemu-0.9.1/target-i386/translate.c qemu-0.9.1-p/target-i386/translate.c
@@ -6758,7 +6758,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;
                 }
#1 lore raw

Hi..

Quoted 8 lines

The following patch is useful for whole-system mode debugging and breakpoint setting on i386 QEMU. It seems like both breakpoints and memory examination used semi-physical addresses, in that neither took account of segment translation. This patch (relative to 0.9.1) adds segment translation.

I'm not sure this is the right way to do it (in fact, I'm sure that the memory examination patch is the WRONG way to do it) and would appreciate pointers or advice.

I believe (IIRC) jasson wessel had fixed such problem about a year ago..but I agree that it seems qemu doesn't take segmentation into account (zero based segment start address, like most OS does these days I think). In this case, i think your patch does the right thing.

regards,

Mulyadi.