#include <ostream>
#include <string>
+/**
+ * Abstract base class for objects which support being printed
+ * to a stream for debugging. Primarily used to support PrintReq
+ * in memory system.
+ */
class Printable
{
public:
}
}
-MemTest *
-MemTestParams::create()
-{
- return new MemTest(this);
-}
-
void
MemTest::printAddr(Addr a)
{
cachePort.printAddr(a);
}
+
+
+MemTest *
+MemTestParams::create()
+{
+ return new MemTest(this);
+}
virtual Port *getPort(const std::string &if_name, int idx = -1);
+ /**
+ * Print state of address in memory system via PrintReq (for
+ * debugging).
+ */
void printAddr(Addr a);
protected:
}
+void
+AtomicSimpleCPU::printAddr(Addr a)
+{
+ dcachePort.printAddr(a);
+}
+
+
////////////////////////////////////////////////////////////////////////
//
// AtomicSimpleCPU Simulation Object
int size, unsigned flags);
Fault translateDataWriteAddr(Addr vaddr, Addr &paddr,
int size, unsigned flags);
+
+ /**
+ * Print state of address in memory system via PrintReq (for
+ * debugging).
+ */
+ void printAddr(Addr a);
};
#endif // __CPU_SIMPLE_ATOMIC_HH__
}
+void
+TimingSimpleCPU::printAddr(Addr a)
+{
+ dcachePort.printAddr(a);
+}
+
+
////////////////////////////////////////////////////////////////////////
//
// TimingSimpleCPU Simulation Object
void completeDataAccess(PacketPtr );
void advanceInst(Fault fault);
+ /**
+ * Print state of address in memory system via PrintReq (for
+ * debugging).
+ */
+ void printAddr(Addr a);
+
private:
typedef EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch> FetchEvent;
}
};
+/**
+ * Simple class to provide virtual print() method on cache blocks
+ * without allocating a vtable pointer for every single cache block.
+ * Just wrap the CacheBlk object in an instance of this before passing
+ * to a function that requires a Printable object.
+ */
class CacheBlkPrintWrapper : public Printable
{
CacheBlk *blk;
virtual ~SenderState() {}
};
+ /**
+ * Object used to maintain state of a PrintReq. The senderState
+ * field of a PrintReq should always be of this type.
+ */
class PrintReqState : public SenderState {
+ /** An entry in the label stack. */
class LabelStackEntry {
public:
const std::string label;
PrintReqState(std::ostream &os, int verbosity = 0);
~PrintReqState();
+ /** Returns the current line prefix. */
const std::string &curPrefix() { return *curPrefixPtr; }
+
+ /** Push a label onto the label stack, and prepend the given
+ * prefix string onto the current prefix. Labels will only be
+ * printed if an object within the label's scope is
+ * printed. */
void pushLabel(const std::string &lbl,
const std::string &prefix = " ");
+ /** Pop a label off the label stack. */
void popLabel();
+ /** Print all of the pending unprinted labels on the
+ * stack. Called by printObj(), so normally not called by
+ * users unless bypassing printObj(). */
void printLabels();
+ /** Print a Printable object to os, because it matched the
+ * address on a PrintReq. */
void printObj(Printable *obj);
};
/**
* Check a functional request against a memory value stored in
- * another packet (i.e. an in-transit request or response). If
- * possible, the request will be satisfied and transformed
- * in-place into a response (at which point no further checking
- * need be done).
- *
- * @return True if the memory location addressed by the request
- * overlaps with the location addressed by otherPkt.
+ * another packet (i.e. an in-transit request or response).
*/
bool checkFunctional(PacketPtr otherPkt) {
return checkFunctional(otherPkt,
otherPkt->getPtr<uint8_t>() : NULL);
}
+ /**
+ * Push label for PrintReq (safe to call unconditionally).
+ */
void pushLabel(const std::string &lbl) {
if (isPrint()) {
dynamic_cast<PrintReqState*>(senderState)->pushLabel(lbl);
}
}
+ /**
+ * Pop label for PrintReq (safe to call unconditionally).
+ */
void popLabel() {
if (isPrint()) {
dynamic_cast<PrintReqState*>(senderState)->popLabel();
TRACE_PACKET("Write");
pkt->makeAtomicResponse();
} else if (pkt->isPrint()) {
- Packet::PrintReqState *prs = dynamic_cast<Packet::PrintReqState*>(pkt->senderState);
+ Packet::PrintReqState *prs =
+ dynamic_cast<Packet::PrintReqState*>(pkt->senderState);
+ // Need to call printLabels() explicitly since we're not going
+ // through printObj().
prs->printLabels();
+ // Right now we just print the single byte at the specified address.
ccprintf(prs->os, "%s%#x\n", prs->curPrefix(), *hostAddr);
} else {
panic("PhysicalMemory: unimplemented functional command %s",
/**
* Find the SimObject with the given name and return a pointer to
- * it. Priarily used for interactive debugging. Argument is
+ * it. Primarily used for interactive debugging. Argument is
* char* rather than std::string to make it callable from gdb.
*/
static SimObject *find(const char *name);