about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-04-11 18:31:59 +0200
committerGitHub <noreply@github.com>2021-04-11 18:31:59 +0200
commit76903904d07afc332ac98c863d494eff353e1e5d (patch)
tree2965f6175befb434a15376e55f5b87b27fa098e4 /src/emu
parentae221ed5bd1e530ff7f90af30b633bb21801e42b (diff)
parenta42f232b1efb155a0aebbf6b882e97ce7e516a3b (diff)
downloadbox64-76903904d07afc332ac98c863d494eff353e1e5d.tar.gz
box64-76903904d07afc332ac98c863d494eff353e1e5d.zip
Merge pull request #6 from rajdakin/generalImprovements
General improvements to box64 and fixed some SDL2 functions
Diffstat (limited to 'src/emu')
-rwxr-xr-xsrc/emu/x64emu.c34
-rwxr-xr-xsrc/emu/x64primop.h4
-rwxr-xr-xsrc/emu/x64run_private.c2
-rw-r--r--src/emu/x64rundc.c4
4 files changed, 26 insertions, 18 deletions
diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c
index 2f95b518..c1f3946c 100755
--- a/src/emu/x64emu.c
+++ b/src/emu/x64emu.c
@@ -17,6 +17,9 @@
 #include "x64run_private.h"
 #include "callback.h"
 #include "bridge.h"
+#ifdef HAVE_TRACE
+#include "x64trace.h"
+#endif
 #ifdef DYNAREC
 #include "custommem.h"
 #endif
@@ -412,8 +415,19 @@ void StopEmu(x64emu_t* emu, const char* reason)
     emu->quit = 1;
     printf_log(LOG_NONE, "%s", reason);
     // dump stuff...
-    printf_log(LOG_NONE, "CPU Regs=%s\n", DumpCPURegs(emu, R_RIP));
-    // TODO: stack, memory/instruction around EIP, etc..
+    printf_log(LOG_NONE, "==== CPU Registers ====\n%s\n", DumpCPURegs(emu, R_RIP));
+    printf_log(LOG_NONE, "======== Stack ========\nStack is from %lX to %lX\n", R_RBP, R_RSP);
+    if (R_RBP == R_RSP) {
+        printf_log(LOG_NONE, "RBP = RSP: leaf function detected; next 128 bytes should be either data or random.\n");
+    } else {
+        // TODO: display stack if operation should be allowed (to avoid crashes)
+        /* for (uint64_t *sp = R_RBP; sp >= R_RSP; --sp) {
+        } */
+    }
+    printf_log(LOG_NONE, "Old IP: %tX\n", emu->old_ip);
+#ifdef HAVE_TRACE
+    printf_log(LOG_NONE, "%s\n", DecodeX64Trace(my_context->dec, emu->old_ip));
+#endif
 }
 
 void UnimpOpcode(x64emu_t* emu)
@@ -461,16 +475,16 @@ uint64_t ReadTSC(x64emu_t* emu)
 {
     //TODO: implement hardware counter read?
     // Read the TimeStamp Counter as 64bits.
-    // this is supposed to be the number of instrunctions executed since last reset
-// fall back to gettime...
+    // this is supposed to be the number of instructions executed since last reset
+    // fall back to gettime...
 #ifndef NOGETCLOCK
-  struct timespec ts;
-  clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
-  return (uint64_t)(ts.tv_sec) * 1000000000LL + ts.tv_nsec;
+    struct timespec ts;
+    clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
+    return (uint64_t)(ts.tv_sec) * 1000000000LL + ts.tv_nsec;
 #else
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  return (uint64_t)(tv.tv_sec) * 1000000 + tv.tv_usec;
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    return (uint64_t)(tv.tv_sec) * 1000000 + tv.tv_usec;
 #endif
 }
 
diff --git a/src/emu/x64primop.h b/src/emu/x64primop.h
index 97264208..e42c7062 100755
--- a/src/emu/x64primop.h
+++ b/src/emu/x64primop.h
@@ -353,8 +353,6 @@ static inline uint16_t shr16(x64emu_t *emu, uint16_t d, uint8_t s)
 
 static inline uint32_t shr32(x64emu_t *emu, uint32_t d, uint8_t s)
 {
-	RESET_FLAGS(emu);	// TODO: Defered this one?
-
 	emu->df = d_shr32;
 	emu->op1.u32 = d;
 
@@ -367,8 +365,6 @@ static inline uint32_t shr32(x64emu_t *emu, uint32_t d, uint8_t s)
 
 static inline uint64_t shr64(x64emu_t *emu, uint64_t d, uint8_t s)
 {
-	RESET_FLAGS(emu);	// TODO: Defered this one?
-
 	emu->df = d_shr64;
 	emu->op1.u64 = d;
 
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index 9bf22e44..c6a7ac88 100755
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -30,8 +30,6 @@
 
 int32_t EXPORT my___libc_start_main(x64emu_t* emu, int *(main) (int, char * *, char * *), int argc, char * * ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end))
 {
-    //TODO: register rtld_fini
-    //TODO: register fini
     // let's cheat and set all args...
     if(init) {
         PushExit(emu);
diff --git a/src/emu/x64rundc.c b/src/emu/x64rundc.c
index da5b0fd9..9f581895 100644
--- a/src/emu/x64rundc.c
+++ b/src/emu/x64rundc.c
@@ -67,7 +67,7 @@ int RunDC(x64emu_t *emu, rex_t rex)
         case 0xDD:
         case 0xDE:
         case 0xDF:  /* FCOMP */
-            fpu_fcom(emu, ST(nextop&7).d);  // TODO: is this ok?
+            fpu_fcom(emu, ST(nextop&7).d);
             fpu_do_pop(emu);
             break;
         case 0xE0:
@@ -143,4 +143,4 @@ int RunDC(x64emu_t *emu, rex_t rex)
         }
     }
   return 0;
-}
\ No newline at end of file
+}