OSDN Git Service

am 7b5b1667: am d3548a38: Merge "Add e4crypt_set_user_crypto_policies, calls vdc...
[android-x86/system-extras.git] / simpleperf / environment.cpp
index 5830cdd..e139b03 100644 (file)
@@ -298,11 +298,11 @@ static bool GetThreadComm(pid_t pid, std::vector<ThreadComm>* thread_comms) {
     if (!ReadThreadNameAndTgid(status_file, &comm, &tgid)) {
       continue;
     }
+    CHECK_EQ(pid, tgid);
     ThreadComm thread;
     thread.tid = tid;
-    thread.tgid = tgid;
+    thread.pid = pid;
     thread.comm = comm;
-    thread.is_process = (tid == pid);
     thread_comms->push_back(thread);
   }
   return true;
@@ -401,3 +401,15 @@ bool GetValidThreadsFromThreadString(const std::string& tid_str, std::set<pid_t>
   }
   return true;
 }
+
+bool GetExecPath(std::string* exec_path) {
+  char path[PATH_MAX];
+  ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path));
+  if (path_len <= 0 || path_len >= static_cast<ssize_t>(sizeof(path))) {
+    PLOG(ERROR) << "readlink failed";
+    return false;
+  }
+  path[path_len] = '\0';
+  *exec_path = path;
+  return true;
+}