Makes objects known to the debugger GC roots, implements the THST message, and lets DDMS request stack traces.

This fills out correct data in all columns of the "Threads" table, and
double-clicking on a thread shows that thread's stack.

Change-Id: I48f63c3612e12d35269158dc3a283f07db28c8e7
diff --git a/src/utils.cc b/src/utils.cc
index a74e231..639339a 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -504,6 +504,22 @@
 #endif
 }
 
+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)) {
+    return;
+  }
+  // Skip the command, which may contain spaces.
+  stats = stats.substr(stats.find(')') + 2);
+  // Extract the three fields we care about.
+  std::vector<std::string> fields;
+  Split(stats, ' ', fields);
+  utime = strtoull(fields[11].c_str(), NULL, 10);
+  stime = strtoull(fields[12].c_str(), NULL, 10);
+  task_cpu = strtoull(fields[36].c_str(), NULL, 10);
+}
+
 std::string GetArtCacheOrDie() {
   const char* data_root = getenv("ANDROID_DATA");
   if (data_root == NULL) {