namespace ArmISA
{
-static int32_t
-readSymbol(ThreadContext *tc, const std::string name)
-{
- PortProxy &vp = tc->getVirtProxy();
- const auto &symtab = tc->getSystemPtr()->workload->symtab(tc);
-
- auto it = symtab.find(name);
- panic_if(it == symtab.end(), "Thread info not compiled into kernel.");
-
- return vp.read<int32_t>(it->address, GuestByteOrder);
-}
-
-ProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc)
-{
- thread_info_size = readSymbol(tc, "thread_info_size");
- task_struct_size = readSymbol(tc, "task_struct_size");
- task_off = readSymbol(tc, "thread_info_task");
- pid_off = readSymbol(tc, "task_struct_pid");
- name_off = readSymbol(tc, "task_struct_comm");
-}
-
-Addr
-ProcessInfo::task(Addr ksp) const
-{
- Addr base = ksp & ~0x1fff;
- if (base == ULL(0xffffffffc0000000))
- return 0;
-
- Addr tsk;
-
- PortProxy &vp = tc->getVirtProxy();
- tsk = vp.read<Addr>(base + task_off, GuestByteOrder);
-
- return tsk;
-}
-
-int
-ProcessInfo::pid(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return -1;
-
- uint16_t pd;
-
- PortProxy &vp = tc->getVirtProxy();
- pd = vp.read<uint16_t>(task + pid_off, GuestByteOrder);
-
- return pd;
-}
-
-std::string
-ProcessInfo::name(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return "unknown";
-
- char comm[256];
- tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
- if (!comm[0])
- return "startup";
-
- return comm;
-}
-
StackTrace::StackTrace()
: tc(0), stack(64)
{
namespace ArmISA
{
-class StackTrace;
-
-class ProcessInfo
-{
- private:
- ThreadContext *tc;
-
- int thread_info_size;
- int task_struct_size;
- int task_off;
- int pid_off;
- int name_off;
-
- public:
- ProcessInfo(ThreadContext *_tc);
-
- Addr task(Addr ksp) const;
- int pid(Addr ksp) const;
- std::string name(Addr ksp) const;
-};
-
class StackTrace
{
protected:
using namespace MipsISA;
-ProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc)
-{}
-
-Addr
-ProcessInfo::task(Addr ksp) const
-{
- Addr base = ksp & ~0x3fff;
- if (base == ULL(0xfffffc0000000000))
- return 0;
-
- Addr tsk;
-
- PortProxy &vp = tc->getVirtProxy();
- tsk = vp.read<Addr>(base + task_off, GuestByteOrder);
-
- return tsk;
-}
-
-int
-ProcessInfo::pid(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return -1;
-
- uint16_t pd;
-
- PortProxy &vp = tc->getVirtProxy();
- pd = vp.read<uint16_t>(task + pid_off, GuestByteOrder);
-
- return pd;
-}
-
-std::string
-ProcessInfo::name(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return "console";
-
- char comm[256];
- tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
- if (!comm[0])
- return "startup";
-
- return comm;
-}
-
StackTrace::StackTrace()
: tc(0), stack(64)
{
namespace MipsISA
{
-class ProcessInfo
-{
- private:
- ThreadContext *tc;
-
- int task_off;
- int pid_off;
- int name_off;
-
- public:
- ProcessInfo(ThreadContext *_tc);
-
- Addr task(Addr ksp) const;
- int pid(Addr ksp) const;
- std::string name(Addr ksp) const;
-};
-
class StackTrace
{
protected:
namespace PowerISA {
-ProcessInfo::ProcessInfo(ThreadContext *_tc)
-{
- panic("ProcessInfo constructor not implemented.\n");
-}
-
-Addr
-ProcessInfo::task(Addr ksp) const
-{
- panic("ProcessInfo::task not implemented.\n");
- return 0;
-}
-
-int
-ProcessInfo::pid(Addr ksp) const
-{
- panic("ProcessInfo::pid not implemented.\n");
- return 0;
-}
-
-string
-ProcessInfo::name(Addr ksp) const
-{
- panic("ProcessInfo::name not implemented.\n");
- return "";
-}
-
StackTrace::StackTrace()
: tc(0), stack(64)
{
namespace PowerISA
{
-class ProcessInfo
-{
- public:
- ProcessInfo(ThreadContext *_tc);
-
- Addr task(Addr ksp) const;
- int pid(Addr ksp) const;
- std::string name(Addr ksp) const;
-};
-
class StackTrace
{
private:
namespace RiscvISA {
-ProcessInfo::ProcessInfo(ThreadContext *_tc)
-{
- panic("ProcessInfo constructor not implemented.\n");
-}
-
-Addr
-ProcessInfo::task(Addr ksp) const
-{
- panic("ProcessInfo::task not implemented.\n");
- return 0;
-}
-
-int
-ProcessInfo::pid(Addr ksp) const
-{
- panic("ProcessInfo::pid not implemented.\n");
- return 0;
-}
-
-string
-ProcessInfo::name(Addr ksp) const
-{
- panic("ProcessInfo::name not implemented.\n");
- return "";
-}
-
StackTrace::StackTrace()
: tc(0), stack(64)
{
namespace RiscvISA
{
-class ProcessInfo
-{
- public:
- ProcessInfo(ThreadContext *_tc);
-
- Addr task(Addr ksp) const;
- int pid(Addr ksp) const;
- std::string name(Addr ksp) const;
-};
-
class StackTrace
{
private:
namespace X86ISA
{
-static int32_t
-readSymbol(ThreadContext *tc, const std::string name)
-{
- PortProxy &vp = tc->getVirtProxy();
- const auto &symtab = tc->getSystemPtr()->workload->symtab(tc);
-
- auto it = symtab.find(name);
- panic_if(it == symtab.end(), "Thread info not compiled into kernel.");
-
- return vp.read<int32_t>(it->address, GuestByteOrder);
-}
-
-ProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc)
-{
- thread_info_size = readSymbol(tc, "thread_info_size");
- task_struct_size = readSymbol(tc, "task_struct_size");
- task_off = readSymbol(tc, "thread_info_task");
- pid_off = readSymbol(tc, "task_struct_pid");
- name_off = readSymbol(tc, "task_struct_comm");
-}
-
-Addr
-ProcessInfo::task(Addr ksp) const
-{
- Addr base = ksp & ~0x3fff;
- if (base == ULL(0xfffffc0000000000))
- return 0;
-
- Addr tsk;
-
- PortProxy &vp = tc->getVirtProxy();
- tsk = vp.read<Addr>(base + task_off, GuestByteOrder);
-
- return tsk;
-}
-
-int
-ProcessInfo::pid(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return -1;
-
- uint16_t pd;
-
- PortProxy &vp = tc->getVirtProxy();
- pd = vp.read<uint16_t>(task + pid_off, GuestByteOrder);
-
- return pd;
-}
-
-std::string
-ProcessInfo::name(Addr ksp) const
-{
- Addr task = this->task(ksp);
- if (!task)
- return "console";
-
- char comm[256];
- tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
- if (!comm[0])
- return "startup";
-
- return comm;
-}
-
StackTrace::StackTrace()
: tc(0), stack(64)
{
class ThreadContext;
namespace X86ISA
{
- class StackTrace;
-
- class ProcessInfo
- {
- private:
- ThreadContext *tc;
-
- int thread_info_size;
- int task_struct_size;
- int task_off;
- int pid_off;
- int name_off;
-
- public:
- ProcessInfo(ThreadContext *_tc);
-
- Addr task(Addr ksp) const;
- int pid(Addr ksp) const;
- std::string name(Addr ksp) const;
- };
-
class StackTrace
{
private: