ARM: implement the ProcessInfo methods
authorAnthony Gutierrez <atgutier@umich.edu>
Mon, 11 Jun 2012 15:07:41 +0000 (11:07 -0400)
committerAnthony Gutierrez <atgutier@umich.edu>
Mon, 11 Jun 2012 15:07:41 +0000 (11:07 -0400)
src/arch/arm/stacktrace.cc

index 99ebcd7c5dc818c3e2c0a0682d83c1e0d42a5374..8575e13474d785008b6837011de479cad6c7627e 100644 (file)
@@ -74,19 +74,46 @@ namespace ArmISA
     Addr
     ProcessInfo::task(Addr ksp) const
     {
-        return 0;
+        Addr base = ksp & ~0x1fff;
+        if (base == ULL(0xffffffffc0000000))
+            return 0;
+
+        Addr tsk;
+
+        FSTranslatingPortProxy &vp = tc->getVirtProxy();
+        tsk = vp.readGtoH<Addr>(base + task_off);
+
+        return tsk;
     }
 
     int
     ProcessInfo::pid(Addr ksp) const
     {
-        return -1;
+        Addr task = this->task(ksp);
+        if (!task)
+            return -1;
+
+        uint16_t pd;
+
+        FSTranslatingPortProxy &vp = tc->getVirtProxy();
+        pd = vp.readGtoH<uint16_t>(task + pid_off);
+
+        return pd;
     }
 
     string
     ProcessInfo::name(Addr ksp) const
     {
-        return "Implement me";
+        Addr task = this->task(ksp);
+        if (!task)
+            return "unknown";
+
+        char comm[256];
+        CopyStringOut(tc, comm, task + name_off, sizeof(comm));
+        if (!comm[0])
+            return "startup";
+
+        return comm;
     }
 
     StackTrace::StackTrace()