Put the ProcessInfo and StackTrace objects into the ISA namespaces.

--HG--
extra : convert_revision : 1626703583f02a1c9823874290462c1b6bdb6c3c
This commit is contained in:
Gabe Black 2006-11-08 00:52:04 -05:00
parent 16a012e80d
commit f1a55570d3
6 changed files with 683 additions and 670 deletions

View file

@ -40,11 +40,12 @@
#include "sim/system.hh"
using namespace std;
using namespace AlphaISA;
ProcessInfo::ProcessInfo(ThreadContext *_tc)
: tc(_tc)
namespace AlphaISA
{
ProcessInfo::ProcessInfo(ThreadContext *_tc)
: tc(_tc)
{
Addr addr = 0;
VirtualPort *vp;
@ -72,11 +73,11 @@ ProcessInfo::ProcessInfo(ThreadContext *_tc)
name_off = vp->readGtoH<int32_t>(addr);
tc->delVirtPort(vp);
}
}
Addr
ProcessInfo::task(Addr ksp) const
{
Addr
ProcessInfo::task(Addr ksp) const
{
Addr base = ksp & ~0x3fff;
if (base == ULL(0xfffffc0000000000))
return 0;
@ -90,11 +91,11 @@ ProcessInfo::task(Addr ksp) const
tc->delVirtPort(vp);
return tsk;
}
}
int
ProcessInfo::pid(Addr ksp) const
{
int
ProcessInfo::pid(Addr ksp) const
{
Addr task = this->task(ksp);
if (!task)
return -1;
@ -108,11 +109,11 @@ ProcessInfo::pid(Addr ksp) const
tc->delVirtPort(vp);
return pd;
}
}
string
ProcessInfo::name(Addr ksp) const
{
string
ProcessInfo::name(Addr ksp) const
{
Addr task = this->task(ksp);
if (!task)
return "console";
@ -123,26 +124,26 @@ ProcessInfo::name(Addr ksp) const
return "startup";
return comm;
}
}
StackTrace::StackTrace()
StackTrace::StackTrace()
: tc(0), stack(64)
{
}
{
}
StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
: tc(0), stack(64)
{
{
trace(_tc, inst);
}
}
StackTrace::~StackTrace()
{
}
StackTrace::~StackTrace()
{
}
void
StackTrace::trace(ThreadContext *_tc, bool is_call)
{
void
StackTrace::trace(ThreadContext *_tc, bool is_call)
{
tc = _tc;
bool usermode = (tc->readMiscReg(AlphaISA::IPR_DTB_CM) & 0x18) != 0;
@ -213,11 +214,11 @@ StackTrace::trace(ThreadContext *_tc, bool is_call)
}
panic("unwinding too far");
}
}
bool
StackTrace::isEntry(Addr addr)
{
bool
StackTrace::isEntry(Addr addr)
{
if (addr == tc->readMiscReg(AlphaISA::IPR_PALtemp12))
return true;
@ -237,11 +238,11 @@ StackTrace::isEntry(Addr addr)
return true;
return false;
}
}
bool
StackTrace::decodeStack(MachInst inst, int &disp)
{
bool
StackTrace::decodeStack(MachInst inst, int &disp)
{
// lda $sp, -disp($sp)
//
// Opcode<31:26> == 0x08
@ -278,11 +279,11 @@ StackTrace::decodeStack(MachInst inst, int &disp)
return false;
return true;
}
}
bool
StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
{
bool
StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
{
// lda $stq, disp($sp)
//
// Opcode<31:26> == 0x08
@ -303,16 +304,16 @@ StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
}
return true;
}
}
/*
/*
* Decode the function prologue for the function we're in, and note
* which registers are stored where, and how large the stack frame is.
*/
bool
StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
bool
StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
int &size, Addr &ra)
{
{
size = 0;
ra = 0;
@ -339,12 +340,12 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
}
return true;
}
}
#if TRACING_ON
void
StackTrace::dump()
{
void
StackTrace::dump()
{
StringWrap name(tc->getCpuPtr()->name());
SymbolTable *symtab = tc->getSystemPtr()->kernelSymtab;
@ -364,5 +365,6 @@ StackTrace::dump()
DPRINTFN("%#x: %s\n", addr, symbol);
}
}
}
#endif
}

View file

@ -35,10 +35,13 @@
#include "cpu/static_inst.hh"
class ThreadContext;
class StackTrace;
class ProcessInfo
namespace AlphaISA
{
class StackTrace;
class ProcessInfo
{
private:
ThreadContext *tc;
@ -54,10 +57,10 @@ class ProcessInfo
Addr task(Addr ksp) const;
int pid(Addr ksp) const;
std::string name(Addr ksp) const;
};
};
class StackTrace
{
class StackTrace
{
protected:
typedef TheISA::MachInst MachInst;
private:
@ -103,11 +106,11 @@ class StackTrace
public:
void dprintf() {}
#endif
};
};
inline bool
StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
{
inline bool
StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
{
if (!inst->isCall() && !inst->isReturn())
return false;
@ -116,6 +119,7 @@ StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
trace(tc, !inst->isReturn());
return true;
}
}
#endif // __ARCH_ALPHA_STACKTRACE_HH__

View file

@ -40,11 +40,11 @@
#include "sim/system.hh"
using namespace std;
using namespace SparcISA;
ProcessInfo::ProcessInfo(ThreadContext *_tc)
: tc(_tc)
namespace SparcISA
{
ProcessInfo::ProcessInfo(ThreadContext *_tc)
: tc(_tc)
{
Addr addr = 0;
VirtualPort *vp;
@ -72,11 +72,11 @@ ProcessInfo::ProcessInfo(ThreadContext *_tc)
name_off = vp->readGtoH<int32_t>(addr);
tc->delVirtPort(vp);
}
}
Addr
ProcessInfo::task(Addr ksp) const
{
Addr
ProcessInfo::task(Addr ksp) const
{
Addr base = ksp & ~0x3fff;
if (base == ULL(0xfffffc0000000000))
return 0;
@ -90,11 +90,11 @@ ProcessInfo::task(Addr ksp) const
tc->delVirtPort(vp);
return tsk;
}
}
int
ProcessInfo::pid(Addr ksp) const
{
int
ProcessInfo::pid(Addr ksp) const
{
Addr task = this->task(ksp);
if (!task)
return -1;
@ -108,11 +108,11 @@ ProcessInfo::pid(Addr ksp) const
tc->delVirtPort(vp);
return pd;
}
}
string
ProcessInfo::name(Addr ksp) const
{
string
ProcessInfo::name(Addr ksp) const
{
Addr task = this->task(ksp);
if (!task)
return "console";
@ -123,26 +123,26 @@ ProcessInfo::name(Addr ksp) const
return "startup";
return comm;
}
}
StackTrace::StackTrace()
StackTrace::StackTrace()
: tc(0), stack(64)
{
}
{
}
StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
: tc(0), stack(64)
{
{
trace(_tc, inst);
}
}
StackTrace::~StackTrace()
{
}
StackTrace::~StackTrace()
{
}
void
StackTrace::trace(ThreadContext *_tc, bool is_call)
{
void
StackTrace::trace(ThreadContext *_tc, bool is_call)
{
#if 0
tc = _tc;
@ -215,11 +215,11 @@ StackTrace::trace(ThreadContext *_tc, bool is_call)
panic("unwinding too far");
#endif
}
}
bool
StackTrace::isEntry(Addr addr)
{
bool
StackTrace::isEntry(Addr addr)
{
#if 0
if (addr == tc->readMiscReg(AlphaISA::IPR_PALtemp12))
return true;
@ -240,11 +240,11 @@ StackTrace::isEntry(Addr addr)
return true;
#endif
return false;
}
}
bool
StackTrace::decodeStack(MachInst inst, int &disp)
{
bool
StackTrace::decodeStack(MachInst inst, int &disp)
{
// lda $sp, -disp($sp)
//
// Opcode<31:26> == 0x08
@ -281,11 +281,11 @@ StackTrace::decodeStack(MachInst inst, int &disp)
return false;
return true;
}
}
bool
StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
{
bool
StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
{
// lda $stq, disp($sp)
//
// Opcode<31:26> == 0x08
@ -306,16 +306,16 @@ StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
}
return true;
}
}
/*
/*
* Decode the function prologue for the function we're in, and note
* which registers are stored where, and how large the stack frame is.
*/
bool
StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
bool
StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
int &size, Addr &ra)
{
{
size = 0;
ra = 0;
@ -342,12 +342,12 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
}
return true;
}
}
#if TRACING_ON
void
StackTrace::dump()
{
void
StackTrace::dump()
{
StringWrap name(tc->getCpuPtr()->name());
SymbolTable *symtab = tc->getSystemPtr()->kernelSymtab;
@ -367,5 +367,6 @@ StackTrace::dump()
DPRINTFN("%#x: %s\n", addr, symbol);
}
}
}
#endif
}

View file

@ -35,10 +35,12 @@
#include "cpu/static_inst.hh"
class ThreadContext;
class StackTrace;
class ProcessInfo
namespace SparcISA
{
class StackTrace;
class ProcessInfo
{
private:
ThreadContext *tc;
@ -54,10 +56,10 @@ class ProcessInfo
Addr task(Addr ksp) const;
int pid(Addr ksp) const;
std::string name(Addr ksp) const;
};
};
class StackTrace
{
class StackTrace
{
protected:
typedef TheISA::MachInst MachInst;
private:
@ -103,11 +105,11 @@ class StackTrace
public:
void dprintf() {}
#endif
};
};
inline bool
StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
{
inline bool
StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
{
if (!inst->isCall() && !inst->isReturn())
return false;
@ -116,6 +118,7 @@ StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
trace(tc, !inst->isReturn());
return true;
}
}
#endif // __ARCH_SPARC_STACKTRACE_HH__

View file

@ -33,9 +33,9 @@
#include <map>
#include "arch/stacktrace.hh"
#include "cpu/static_inst.hh"
#include "sim/host.hh"
#include "arch/stacktrace.hh"
class ThreadContext;
@ -66,7 +66,7 @@ class FunctionProfile
const SymbolTable *symtab;
ProfileNode top;
std::map<Addr, Counter> pc_count;
StackTrace trace;
TheISA::StackTrace trace;
public:
FunctionProfile(const SymbolTable *symtab);

View file

@ -28,6 +28,9 @@
* Authors: Ali Saidi
*/
//To get endianness
#include "arch/isa_traits.hh"
#include "mem/port.hh"
#include "sim/byteswap.hh"
@ -35,7 +38,7 @@ template <typename T>
void
FunctionalPort::writeHtoG(Addr addr, T d)
{
d = htog(d);
d = TheISA::htog(d);
writeBlob(addr, (uint8_t*)&d, sizeof(T));
}
@ -46,6 +49,6 @@ FunctionalPort::readGtoH(Addr addr)
{
T d;
readBlob(addr, (uint8_t*)&d, sizeof(T));
return gtoh(d);
return TheISA::gtoh(d);
}