Fix all our unused parameter warnings so we let GCC report them.
There were a couple of genuine bugs here (fixed), plus there's a missing
feature in trace.cc that I've just added a TODO for.
Also note that I haven't touched the compilers; this warning is still
explicitly disabled for that code. I'll do that when there's less going
on in those directories.
Change-Id: Ic3570bf82411a07c7530bfaf1995ac995b9fc00f
diff --git a/src/utils.cc b/src/utils.cc
index 26fe605..c9a6e7e 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -741,7 +741,7 @@
void GetTaskStats(pid_t tid, int& utime, int& stime, int& task_cpu) {
utime = stime = task_cpu = 0;
std::string stats;
- if (!ReadFileToString(StringPrintf("/proc/self/task/%d/stat", GetTid()).c_str(), &stats)) {
+ if (!ReadFileToString(StringPrintf("/proc/self/task/%d/stat", tid).c_str(), &stats)) {
return;
}
// Skip the command, which may contain spaces.
@@ -754,6 +754,31 @@
task_cpu = strtoull(fields[36].c_str(), NULL, 10);
}
+std::string GetSchedulerGroupName(pid_t tid) {
+ // /proc/<pid>/cgroup looks like this:
+ // 2:devices:/
+ // 1:cpuacct,cpu:/
+ // We want the third field from the line whose second field contains the "cpu" token.
+ std::string cgroup_file;
+ if (!ReadFileToString(StringPrintf("/proc/self/task/%d/cgroup", tid), &cgroup_file)) {
+ return "";
+ }
+ std::vector<std::string> cgroup_lines;
+ Split(cgroup_file, '\n', cgroup_lines);
+ for (size_t i = 0; i < cgroup_lines.size(); ++i) {
+ std::vector<std::string> cgroup_fields;
+ Split(cgroup_lines[i], ':', cgroup_fields);
+ std::vector<std::string> cgroups;
+ Split(cgroup_fields[1], ',', cgroups);
+ for (size_t i = 0; i < cgroups.size(); ++i) {
+ if (cgroups[i] == "cpu") {
+ return cgroup_fields[2].substr(1); // Skip the leading slash.
+ }
+ }
+ }
+ return "";
+}
+
const char* GetAndroidRoot() {
const char* android_root = getenv("ANDROID_ROOT");
if (android_root == NULL) {