39a40
> #include "base/cprintf.hh"
124c125,127
< { SET2(IsResponse, IsError), InvalidCmd, "BadAddressError" }
---
> { SET2(IsResponse, IsError), InvalidCmd, "BadAddressError" },
> /* PrintReq */
> { SET2(IsRequest, IsPrint), InvalidCmd, "PrintReq" }
157c160
< Packet::checkFunctional(Addr addr, int size, uint8_t *data)
---
> Packet::checkFunctional(Printable *obj, Addr addr, int size, uint8_t *data)
168a172,182
> // check print first since it doesn't require data
> if (isPrint()) {
> dynamic_cast<PrintReqState*>(senderState)->printObj(obj);
> return false;
> }
>
> // if there's no data, there's no need to look further
> if (!data) {
> return false;
> }
>
197,199c211
< // we always want to keep going with a write
< return false;
< } else
---
> } else {
200a213,216
> }
>
> // keep going with request by default
> return false;
204,205c220,222
< std::ostream &
< operator<<(std::ostream &o, const Packet &p)
---
> void
> Packet::print(std::ostream &o, const int verbosity,
> const std::string &prefix) const
206a224,226
> ccprintf(o, "%s[%x:%x] %s\n", prefix,
> getAddr(), getAddr() + getSize() - 1, cmdString());
> }
208,215d227
< o << "[0x";
< o.setf(std::ios_base::hex, std::ios_base::showbase);
< o << p.getAddr();
< o.unsetf(std::ios_base::hex| std::ios_base::showbase);
< o << ":";
< o.setf(std::ios_base::hex, std::ios_base::showbase);
< o << p.getAddr() + p.getSize() - 1 << "] ";
< o.unsetf(std::ios_base::hex| std::ios_base::showbase);
217,228c229,233
< if (p.isRead())
< o << "Read ";
< if (p.isWrite())
< o << "Write ";
< if (p.isInvalidate())
< o << "Invalidate ";
< if (p.isRequest())
< o << "Request ";
< if (p.isResponse())
< o << "Response ";
< if (p.hasData())
< o << "w/Data ";
---
> Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity)
> : curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity)
> {
> labelStack.push_back(LabelStackEntry("", curPrefixPtr));
> }
230,231c235,240
< o << std::endl;
< return o;
---
>
> Packet::PrintReqState::~PrintReqState()
> {
> labelStack.pop_back();
> assert(labelStack.empty());
> delete curPrefixPtr;
233a243,292
>
> Packet::PrintReqState::
> LabelStackEntry::LabelStackEntry(const std::string &_label,
> std::string *_prefix)
> : label(_label), prefix(_prefix), labelPrinted(false)
> {
> }
>
>
> void
> Packet::PrintReqState::pushLabel(const std::string &lbl,
> const std::string &prefix)
> {
> labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr));
> curPrefixPtr = new std::string(*curPrefixPtr);
> *curPrefixPtr += prefix;
> }
>
> void
> Packet::PrintReqState::popLabel()
> {
> delete curPrefixPtr;
> curPrefixPtr = labelStack.back().prefix;
> labelStack.pop_back();
> assert(!labelStack.empty());
> }
>
> void
> Packet::PrintReqState::printLabels()
> {
> if (!labelStack.back().labelPrinted) {
> LabelStack::iterator i = labelStack.begin();
> LabelStack::iterator end = labelStack.end();
> while (i != end) {
> if (!i->labelPrinted) {
> ccprintf(os, "%s%s\n", *(i->prefix), i->label);
> i->labelPrinted = true;
> }
> i++;
> }
> }
> }
>
>
> void
> Packet::PrintReqState::printObj(Printable *obj)
> {
> printLabels();
> obj->print(os, verbosity, curPrefix());
> }