Print stacktrace on crashes on Android

This commit is contained in:
SSimco 2023-07-03 10:44:53 +03:00
parent 29841a3fb2
commit 14fb7c8a2a
2 changed files with 13 additions and 5 deletions

View File

@ -10,6 +10,10 @@
#include "ELFSymbolTable.h"
#endif
#if __ANDROID__
#include <boost/stacktrace.hpp>
#endif // __ANDROID__
#if BOOST_OS_LINUX
void DemangleAndPrintBacktrace(char** backtrace, size_t size)
{
@ -61,7 +65,6 @@ void DemangleAndPrintBacktrace(char** backtrace, size_t size)
// handle signals that would dump core, print stacktrace and then dump depending on config
void handlerDumpingSignal(int sig, siginfo_t *info, void *context)
{
#if !__ANDROID__
if(!CrashLog_Create())
return; // give up if crashlog was already created
@ -75,7 +78,10 @@ void handlerDumpingSignal(int sig, siginfo_t *info, void *context)
// should never be the case
printf("Unknown core dumping signal!\n");
}
CrashLog_WriteLine(fmt::format("Error: signal {}:", sig));
#if __ANDROID__
CrashLog_WriteLine(to_string(boost::stacktrace::stacktrace()));
#else
void* backtraceArray[128];
size_t size;
@ -87,8 +93,6 @@ void handlerDumpingSignal(int sig, siginfo_t *info, void *context)
backtraceArray[0] = (void *)uc->uc_mcontext.gregs[REG_RIP];
#endif
CrashLog_WriteLine(fmt::format("Error: signal {}:", sig));
#if BOOST_OS_LINUX
char** symbol_trace = backtrace_symbols(backtraceArray, size);
@ -104,6 +108,7 @@ void handlerDumpingSignal(int sig, siginfo_t *info, void *context)
#else
backtrace_symbols_fd(backtraceArray, size, STDERR_FILENO);
#endif
#endif // __ANDROID__
std::cerr << fmt::format("\nStacktrace and additional info written to:") << std::endl;
std::cerr << cemuLog_GetLogFilePath().generic_string() << std::endl;
@ -119,7 +124,6 @@ void handlerDumpingSignal(int sig, siginfo_t *info, void *context)
raise(sig);
return;
}
#endif // __ANDROID__
// exit process ignoring all issues
_Exit(1);
}

View File

@ -35,6 +35,10 @@
"name": "boost-iostreams",
"platform" : "android"
},
{
"name": "boost-stacktrace",
"platform" : "android"
},
"boost-random",
"fmt",
"libpng",