From 632af46137df1d1249950910e9ab24ad5c67630b Mon Sep 17 00:00:00 2001 From: KreitinnSoftware <80591934+KreitinnSoftware@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:44:28 -0300 Subject: [PATCH] [ANDROID] BOX64_SHOWBT Now show Emulated BT on Android (#1258) Co-authored-by: Pablo Carlos --- CMakeLists.txt | 2 +- src/libtools/signals.c | 7 +++++-- src/wrapped/wrappedlibc.c | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e2118a..a4ba222b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,6 +326,7 @@ set(ELFLOADER_SRC "${BOX64_ROOT}/src/elfs/elfloader.c" "${BOX64_ROOT}/src/elfs/elfparser.c" "${BOX64_ROOT}/src/elfs/elfload_dump.c" + "${BOX64_ROOT}/src/elfs/elfdwarf_private.c" "${BOX64_ROOT}/src/emu/x64compstrings.c" "${BOX64_ROOT}/src/emu/x64emu.c" "${BOX64_ROOT}/src/emu/x64int3.c" @@ -364,7 +365,6 @@ set(ELFLOADER_SRC if(NOT ANDROID) list(APPEND ELFLOADER_SRC "${BOX64_ROOT}/src/libtools/obstack.c" - "${BOX64_ROOT}/src/elfs/elfdwarf_private.c" ) endif() diff --git a/src/libtools/signals.c b/src/libtools/signals.c index dfec9f62..079a5780 100644 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -1550,13 +1550,15 @@ dynarec_log(/*LOG_DEBUG*/LOG_INFO, "Repeated SIGSEGV with Access error on %p for } } print_cycle_log(log_minimum); -#ifndef ANDROID + if((box64_showbt || sig==SIGABRT) && log_minimum<=box64_log) { // show native bt #define BT_BUF_SIZE 100 int nptrs; void *buffer[BT_BUF_SIZE]; char **strings; + + #ifndef ANDROID nptrs = backtrace(buffer, BT_BUF_SIZE); strings = backtrace_symbols(buffer, nptrs); if(strings) { @@ -1565,6 +1567,7 @@ dynarec_log(/*LOG_DEBUG*/LOG_INFO, "Repeated SIGSEGV with Access error on %p for free(strings); } else printf_log(log_minimum, "NativeBT: none (%d/%s)\n", errno, strerror(errno)); + #endif extern int my_backtrace_ip(x64emu_t* emu, void** buffer, int size); // in wrappedlibc extern char** my_backtrace_symbols(x64emu_t* emu, uintptr_t* buffer, int size); // save and set real RIP/RSP @@ -1619,7 +1622,7 @@ dynarec_log(/*LOG_DEBUG*/LOG_INFO, "Repeated SIGSEGV with Access error on %p for GO(RIP); #undef GO } -#endif + if(log_minimum<=box64_log) { static const char* reg_name[] = {"RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI", "RDI", " R8", " R9","R10","R11", "R12","R13","R14","R15"}; static const char* seg_name[] = {"ES", "CS", "SS", "DS", "FS", "GS"}; diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 1c7c5a25..4e615629 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -3095,7 +3095,6 @@ EXPORT long my_ptrace(x64emu_t* emu, int request, pid_t pid, void* addr, uint32_ // Backtrace stuff -#ifndef ANDROID #include "elfs/elfdwarf_private.h" EXPORT int my_backtrace(x64emu_t* emu, void** buffer, int size) { @@ -3221,7 +3220,6 @@ EXPORT void my_backtrace_symbols_fd(x64emu_t* emu, uintptr_t* buffer, int size, (void)dummy; } } -#endif EXPORT int my_iopl(x64emu_t* emu, int level) {