about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorrajdakin <rajdakin@gmail.com>2021-04-07 17:09:37 +0200
committerrajdakin <rajdakin@gmail.com>2021-04-07 17:09:37 +0200
commit79f2b8448a7eeea5f5e182e7ce2ceb15e8e29398 (patch)
tree6e6bd1ec24c472810b2c789d0603a96321624d73 /src/emu
parent7e09961ee7ac6841883b68123ad700609d2fd955 (diff)
downloadbox64-79f2b8448a7eeea5f5e182e7ce2ceb15e8e29398.tar.gz
box64-79f2b8448a7eeea5f5e182e7ce2ceb15e8e29398.zip
[TRACE] Added a new trace option
Diffstat (limited to 'src/emu')
-rwxr-xr-xsrc/emu/x64emu.c21
-rwxr-xr-xsrc/emu/x64emu_private.h3
2 files changed, 19 insertions, 5 deletions
diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c
index ebf378cf..f97f4383 100755
--- a/src/emu/x64emu.c
+++ b/src/emu/x64emu.c
@@ -108,6 +108,7 @@ void SetupX64Emu(x64emu_t *emu)
     printf_log(LOG_DEBUG, "Setup X86_64 Emu\n");
 }
 
+#ifdef HAVE_TRACE
 void SetTraceEmu(uintptr_t start, uintptr_t end)
 {
     if(my_context->zydis) {
@@ -122,6 +123,7 @@ void SetTraceEmu(uintptr_t start, uintptr_t end)
     trace_start = start;
     trace_end = end;
 }
+#endif
 
 void AddCleanup(x64emu_t *emu, void *p)
 {
@@ -335,12 +337,13 @@ void ResetFlags(x64emu_t *emu)
 const char* DumpCPURegs(x64emu_t* emu, uintptr_t ip)
 {
     static char buff[1000];
-    char* regname[] = {"RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI", "RDI", 
+    char* regname[] = {"RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI", "RDI",
                        " R8", " R9", "R10", "R11", "R12", "R13", "R14", "R15"};
     char tmp[160];
     buff[0] = '\0';
+#ifdef HAVE_TRACE
     if(trace_emm) {
-        // do emm reg is needed
+        // do emm reg if needed
         for(int i=0; i<8; ++i) {
             sprintf(tmp, "mm%d:%016lx", i, emu->mmx87[i].q);
             strcat(buff, tmp);
@@ -348,13 +351,14 @@ const char* DumpCPURegs(x64emu_t* emu, uintptr_t ip)
         }
     }
     if(trace_xmm) {
-        // do xmm reg is needed
+        // do xmm reg if needed
         for(int i=0; i<8; ++i) {
             sprintf(tmp, "%d:%016lx%016lx", i, emu->xmm[i].q[1], emu->xmm[i].q[0]);
             strcat(buff, tmp);
             if ((i&3)==3) strcat(buff, "\n"); else strcat(buff, " ");
         }
     }
+#endif
     // start with FPU regs...
     if(emu->fpu_stack) {
         for (int i=0; i<emu->fpu_stack; i++) {
@@ -368,7 +372,16 @@ const char* DumpCPURegs(x64emu_t* emu, uintptr_t ip)
         strcat(buff, "\n");
     }
     for (int i=_AX; i<=_R15; ++i) {
+#ifdef HAVE_TRACE
+        if (trace_regsdiff && (emu->regs[i].q[0] != emu->oldregs[i].q[0])) {
+            sprintf(tmp, "\e[1;35m%s=%016lx\e[m ", regname[i], emu->regs[i].q[0]);
+            emu->oldregs[i].q[0] = emu->regs[i].q[0];
+        } else {
+            sprintf(tmp, "%s=%016lx ", regname[i], emu->regs[i].q[0]);
+        }
+#else
         sprintf(tmp, "%s=%016lx ", regname[i], emu->regs[i].q[0]);
+#endif
         strcat(buff, tmp);
 
         if (i%5==4) {
@@ -466,4 +479,4 @@ void ResetSegmentsCache(x64emu_t *emu)
     if(!emu)
         return;
     memset(emu->segs_serial, 0, sizeof(emu->segs_serial));
-}
\ No newline at end of file
+}
diff --git a/src/emu/x64emu_private.h b/src/emu/x64emu_private.h
index cf7d459b..70d9576b 100755
--- a/src/emu/x64emu_private.h
+++ b/src/emu/x64emu_private.h
@@ -52,6 +52,7 @@ typedef struct x64emu_s {
     multiuint_t res;
     uint32_t    *x64emu_parity_tab; // helper
     #ifdef HAVE_TRACE
+    reg64_t     oldregs[16];
     uintptr_t   prev2_ip;
     #endif
     // segments
@@ -91,4 +92,4 @@ typedef struct x64emu_s {
 //#define INTR_RAISE_DIV0(emu) {emu->error |= ERR_DIVBY0; emu->quit=1;}
 #define INTR_RAISE_DIV0(emu) {emu->error |= ERR_DIVBY0;} // should rise a SIGFPE and not quit
 
-#endif //__X86EMU_PRIVATE_H_
\ No newline at end of file
+#endif //__X86EMU_PRIVATE_H_