UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
android_debugger.cpp
Go to the documentation of this file.
1 /* This function will dump stack trace to logcat and continue running on Android OS */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <ctype.h>
6 #include <signal.h>
7 #include <errno.h>
8 #include <android/log.h>
9 #include "android_debugger.h"
10 
11 /* TODO: it does not work */
12 
13 static sighandler_t debuggerHandler;
14 
15 static void mySignalHandler (int sig)
16 {
17  debuggerHandler(sig);
18  signal( sig, debuggerHandler );
19 }
20 
22 {
23  __android_log_print(ANDROID_LOG_INFO, "UFOAI", "Backtrace on Android does not work currently, you need to actually crash your code to get backtrace");
24  /*
25  debuggerHandler = signal(SIGSEGV, mySignalHandler);
26  __android_log_print(ANDROID_LOG_INFO, "UFOAI", "Backtrace (run command \"arm-eabi-gdb libapplication.so -ex 'list *0xaabbccdd'\" where aabbccdd is a stack address below):");
27  if (debuggerHandler == SIG_IGN || debuggerHandler == SIG_DFL || debuggerHandler == SIG_ERR) {
28  __android_log_print(ANDROID_LOG_INFO, "UFOAI", "Getting backtrace failed, you have very custom or broken Android firmware");
29  signal(SIGSEGV, debuggerHandler);
30  return;
31  }
32  raise(SIGSEGV);
33  */
34 }
static sighandler_t debuggerHandler
#define FILE
Definition: test_webapi.cpp:30
static void mySignalHandler(int sig)
void androidDumpBacktrace(FILE *out)