about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-10-03 11:35:41 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-10-03 11:35:41 +0200
commit6a5049b22c791abc4bdcf8268298f9ce3b873df1 (patch)
tree56b7bb0d723b98bac9293a49d53ae023243581cb /src
parent6cbcfc7ab80269a0d3b80ec920fa344f59609b61 (diff)
downloadbox64-6a5049b22c791abc4bdcf8268298f9ce3b873df1.tar.gz
box64-6a5049b22c791abc4bdcf8268298f9ce3b873df1.zip
[BOX32][TRACE] Some more improved trace
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64run_private.c5
-rwxr-xr-xsrc/emu/x86int3.c28
2 files changed, 32 insertions, 1 deletions
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index 5cb8141f..1d48598a 100644
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -1294,6 +1294,11 @@ void PrintTrace(x64emu_t* emu, uintptr_t ip, int dynarec)
                     uintptr_t nextaddr = *(uintptr_t*)(R_RAX+PK(2));
                     if(!printFunctionAddr(nextaddr, "=> "))
                         printf_log(LOG_NONE, " => %p", (void*)nextaddr);
+                } else if(PK(1)==0xE0) {
+                    uintptr_t nextaddr = R_RAX;
+                    if(is32bits) nextaddr &= 0xffffffff;
+                    if(!printFunctionAddr(nextaddr, "=> "))
+                        printf_log(LOG_NONE, " => %p", (void*)nextaddr);
                 } else if((PK(1)==0x14) && (PK(2)==0x25)) {
                     uintptr_t nextaddr = is32bits?(*(uint32_t*)(uintptr_t)PK32(3)):(*(uintptr_t*)(uintptr_t)PK32(3));
                     printf_log(LOG_NONE, " => %p", (void*)nextaddr);
diff --git a/src/emu/x86int3.c b/src/emu/x86int3.c
index 0b2cc1b1..255a6f4c 100755
--- a/src/emu/x86int3.c
+++ b/src/emu/x86int3.c
@@ -146,6 +146,18 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr)
                 } else  if(!strcmp(s, "chdir")) {
                     pu32=(uint32_t*)from_ptrv(R_ESP+4);
                     snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, pu32?((pu32==(uint32_t*)1)?"/1/":(char*)pu32):"/0/");
+                } else  if(!strcmp(s, "poll")) {
+                    pu32=from_ptrv(*(ptr_t*)from_ptrv(R_ESP+4));
+                    char tmp[50];
+                    char tmp2[50] = {0};
+                    uint32_t n = from_ptri(uint32_t, R_ESP+8);
+                    for(int ii=0; ii<n; ++ii) {
+                        snprintf(tmp, 49, "%s%d/0x%hx", ii?" ,":"", ((int*)pu32)[ii*2], ((uint16_t*)pu32)[ii*4+2]);
+                        strncat(tmp2, tmp, 49);
+                    }
+                    snprintf(buff, 255, "%04d|%p: Calling %s(%p[%s], %u, %d)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(R_ESP+4), tmp2, from_ptri(uint32_t, R_ESP+8), from_ptri(int, R_ESP+12));
+                    post = 12;
+                    perr = 1;
                 } else  if(strstr(s, "getenv")==s) {
                     snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)));
                     post = 2;
@@ -226,7 +238,7 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr)
                     snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %p, %d)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), *(int*)from_ptr(R_ESP+12));
                     ret_fmt = 1;
                 } else  if(strstr(s, "memcmp")==s) {
-                    snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p, %lu)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), *(ulong*)from_ptr(R_ESP+12));
+                    snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p, %lu)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptri(ulong, R_ESP+12));
                     ret_fmt = 1;
                 } else  if(strstr(s, "strstr")==s) {
                     snprintf(buff, 255, "%04d|%p: Calling %s(%p\"%.127s\", \"%.127s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)));
@@ -352,6 +364,7 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr)
                     snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)));
                 } else if(!strcmp(s, "recv")) {
                     snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, 0x%x, %d)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptri(int, R_ESP+4), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptri(uint32_t, R_ESP+12), from_ptri(int, R_ESP+16));
+                    post = 13;
                 } else  if(!strcmp(s, "syscall")) {
                     snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, %p, %p...)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, *(int32_t*)from_ptr(R_ESP+4), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+12)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+16)));
                     perr = 1;
@@ -399,6 +412,19 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr)
                             break;
                     case 11: snprintf(buff2, 63, " [%d / %d / %d /%d]", pu32[0], pu32[1], pu32[2], pu32[3]);
                             break;
+                    case 12: if(R_EAX>0) {
+                        char tmp[50];
+                        char tmp2[50] = {0};
+                        uint32_t n = from_ptri(uint32_t, R_ESP+8);
+                        for(int ii=0; ii<n; ++ii) {
+                            snprintf(tmp, 49, "%s%d/0x%hx", ii?" ,":"", pu32[ii*2], pu32[ii*2+1]>>16);
+                            strncat(tmp2, tmp, 49);
+                        }
+                        snprintf(buff2, 63, "[%s]", tmp2);
+                    }
+                    case 13: if(R_EAX==0x25E)
+                                snprintf(buff2, 63, "%s", "here");
+                            break;
                 }
                 if(perr==1 && ((int)R_EAX)<0)
                     snprintf(buff3, 63, " (errno=%d:\"%s\")", errno, strerror(errno));