]> git.cworth.org Git - apitrace/blobdiff - common/os_posix.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / common / os_posix.cpp
index 261fe88c929409d796b8cbd82ed6ea574dfc9990..0d93b31bcafa6e56604fa639a7656d20128835ca 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
@@ -130,7 +134,11 @@ int execute(char * const * args)
     if (pid == 0) {
         // child
         execvp(args[0], args);
-        fprintf(stderr, "error: failed to execute %s\n", args[0]);
+        fprintf(stderr, "error: failed to execute:");
+        for (unsigned i = 0; args[i]; ++i) {
+            fprintf(stderr, " %s", args[i]);
+        }
+        fprintf(stderr, "\n");
         exit(-1);
     } else {
         // parent
@@ -139,8 +147,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,11 +170,19 @@ 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;
 }
 
+#if defined(__APPLE__)
+long long timeFrequency = 0LL;
+#endif
+
 void
 abort(void)
 {