]> git.cworth.org Git - apitrace/blobdiff - common/os_posix.cpp
Changed profile parsing to use stringstream instead of sscanf.
[apitrace] / common / os_posix.cpp
index 3eebbd862d4a78448b062a11ba10ce1232d8fcb8..7d39d8ada5e0ffafc0f730bcdd3e913744f734d2 100644 (file)
 #include <mach-o/dyld.h>
 #endif
 
+#ifdef ANDROID
+#include <android/log.h>
+#endif
+
 #ifndef PATH_MAX
 #warning PATH_MAX undefined
 #define PATH_MAX 4096
@@ -139,8 +143,17 @@ int execute(char * const * args)
             return -1;
         }
         int status = -1;
+        int ret;
         waitpid(pid, &status, 0);
-        return status;
+        if (WIFEXITED(status)) {
+            ret = WEXITSTATUS(status);
+        } else if (WIFSIGNALED(status)) {
+            // match shell return code
+            ret = WTERMSIG(status) + 128;
+        } else {
+            ret = 128;
+        }
+        return ret;
     }
 }
 
@@ -153,7 +166,11 @@ log(const char *format, ...)
     va_list ap;
     va_start(ap, format);
     fflush(stdout);
+#ifdef ANDROID
+    __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap);
+#else
     vfprintf(stderr, format, ap);
+#endif
     va_end(ap);
     logging = false;
 }