X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos_posix.cpp;h=0d93b31bcafa6e56604fa639a7656d20128835ca;hb=77373c35010d89e5ab3f030e4c60f8f6e3fdbe82;hp=e4de967b045fd67c3ff5837127a5ddc18ccf055a;hpb=1242ab5cbdc409e2fc2d787edc28c6ac2a8439d1;p=apitrace diff --git a/common/os_posix.cpp b/common/os_posix.cpp index e4de967..0d93b31 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -46,10 +46,6 @@ #ifdef ANDROID #include -#include -#include -#include -#include #endif #ifndef PATH_MAX @@ -101,68 +97,6 @@ getProcessName(void) return path; } -#ifdef ANDROID -static String -getZygoteProcessName(void) -{ - String path; - size_t size = PATH_MAX; - char *buf = path.buf(size); - ssize_t len; - - int fd = open("/proc/self/cmdline", O_RDONLY); - - assert(fd >= 0); - len = read(fd, buf, size - 1); - close(fd); - path.truncate(len); - - return path; -} - -static bool isZygoteProcess(void) -{ - os::String proc_name; - - proc_name = getProcessName(); - proc_name.trimDirectory(); - - return strcmp(proc_name, "app_process") == 0; -} - -bool apitrace_enabled(void) -{ - static pid_t cached_pid; - static bool enabled; - pid_t pid; - - pid = getpid(); - if (cached_pid == pid) - return enabled; - cached_pid = pid; - - if (!isZygoteProcess()) { - os::log("apitrace[%d]: enabled for standalone %s", pid, - (const char *)getProcessName()); - enabled = true; - return true; - } - - char target_proc_name[PROP_VALUE_MAX] = ""; - os::String proc_name; - - proc_name = getZygoteProcessName(); - proc_name.trimDirectory(); - - __system_property_get("debug.apitrace.procname", target_proc_name); - enabled = !strcmp(target_proc_name, proc_name); - os::log("apitrace[%d]: %s for %s", - pid, enabled ? "enabled" : "disabled", (const char *)proc_name); - - return enabled; -} -#endif - String getCurrentDir(void) { @@ -200,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