about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-11-15 15:34:00 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-11-15 15:34:00 +0100
commit8b0eec097bf9f9c9166e24d902394a3e85082c54 (patch)
tree6b1c97c8f99c0a1e651fcda0bfe02eac8e2a7293 /src/libtools
parenta39c8aa5c5521fde566cd736ff32e78ca5484960 (diff)
downloadbox64-8b0eec097bf9f9c9166e24d902394a3e85082c54.tar.gz
box64-8b0eec097bf9f9c9166e24d902394a3e85082c54.zip
[TRACE] More info on signal
Diffstat (limited to 'src/libtools')
-rw-r--r--src/libtools/signals.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libtools/signals.c b/src/libtools/signals.c
index dcf0ff2c..2460a494 100644
--- a/src/libtools/signals.c
+++ b/src/libtools/signals.c
@@ -1145,6 +1145,7 @@ void my_sigactionhandler_oldcode(x64emu_t* emu, int32_t sig, int simple, siginfo
     TRAP_x86_CACHEFLT   = 19   // SIMD exception (via SIGFPE) if CPU is SSE capable otherwise Cache flush exception (via SIGSEV)
     */
     uint32_t prot = getProtection((uintptr_t)info->si_addr);
+    uint32_t mmapped = getMmapped((uintptr_t)info->si_addr);
     uint32_t real_prot = 0;
     if(prot&PROT_READ) real_prot|=PROT_READ;
     if(prot&PROT_WRITE) real_prot|=PROT_WRITE;
@@ -1164,11 +1165,11 @@ void my_sigactionhandler_oldcode(x64emu_t* emu, int32_t sig, int simple, siginfo
             } else if (info->si_errno==0xecec) {
                 // no excute bit on segment
                 sigcontext->uc_mcontext.gregs[X64_ERR] = (real_prot&PROT_READ)?16:1; // EXECUTE_FAULT & READ_FAULT
-                sigcontext->uc_mcontext.gregs[X64_TRAPNO] = (getMmapped((uintptr_t)info->si_addr))?14:13;
+                sigcontext->uc_mcontext.gregs[X64_TRAPNO] = mmapped?14:13;
                 info2->si_errno = 0;
             }else {
                 sigcontext->uc_mcontext.gregs[X64_ERR] = (real_prot&PROT_READ)?16:1;//(info->si_errno==0x1234)?0:((info->si_errno==0xdead)?(0x2|(info->si_code<<3)):0x0010);    // execution flag issue (probably), unless it's a #GP(0)
-                sigcontext->uc_mcontext.gregs[X64_TRAPNO] = (getMmapped((uintptr_t)info->si_addr))?14:13;
+                sigcontext->uc_mcontext.gregs[X64_TRAPNO] = mmapped?14:13;
                 //sigcontext->uc_mcontext.gregs[X64_TRAPNO] = ((info->si_code==SEGV_ACCERR) || (info->si_errno==0x1234) || (info->si_errno==0xdead) || ((uintptr_t)info->si_addr==0))?13:14;
             }
         } else if(info->si_code==SEGV_ACCERR && !(prot&PROT_WRITE)) {
@@ -1223,7 +1224,7 @@ void my_sigactionhandler_oldcode(x64emu_t* emu, int32_t sig, int simple, siginfo
         sigcontext->uc_mcontext.gregs[X64_ERR] = 0;
     }
     //TODO: SIGABRT generate what?
-    printf_log((sig==10)?LOG_DEBUG:log_minimum, "Signal %d: si_addr=%p, TRAPNO=%d, ERR=%d, RIP=%p\n", sig, (void*)info2->si_addr, sigcontext->uc_mcontext.gregs[X64_TRAPNO], sigcontext->uc_mcontext.gregs[X64_ERR],sigcontext->uc_mcontext.gregs[X64_RIP]);
+    printf_log((sig==10)?LOG_DEBUG:log_minimum, "Signal %d: si_addr=%p, TRAPNO=%d, ERR=%d, RIP=%p, prot=%x, mmapped:%d\n", sig, (void*)info2->si_addr, sigcontext->uc_mcontext.gregs[X64_TRAPNO], sigcontext->uc_mcontext.gregs[X64_ERR],sigcontext->uc_mcontext.gregs[X64_RIP], prot, mmapped);
     // call the signal handler
     x64_ucontext_t sigcontext_copy = *sigcontext;
     // save old value from emu