mem: Add Program Counter to MemTraceProbe
This commit is contained in:
parent
a3bf4aa6ec
commit
df5a811833
5 changed files with 21 additions and 4 deletions
|
@ -46,6 +46,9 @@ class MemTraceProbe(BaseMemProbe):
|
||||||
# Boolean to compress the trace or not.
|
# Boolean to compress the trace or not.
|
||||||
trace_compress = Param.Bool(True, "Enable trace compression")
|
trace_compress = Param.Bool(True, "Enable trace compression")
|
||||||
|
|
||||||
|
# For requests with a valid PC, include the PC in the trace
|
||||||
|
with_pc = Param.Bool(False, "Include PC info in the trace")
|
||||||
|
|
||||||
# packet trace output file, disabled by default
|
# packet trace output file, disabled by default
|
||||||
trace_file = Param.String("", "Packet trace output file")
|
trace_file = Param.String("", "Packet trace output file")
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,8 @@
|
||||||
|
|
||||||
MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
|
MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
|
||||||
: BaseMemProbe(p),
|
: BaseMemProbe(p),
|
||||||
traceStream(nullptr)
|
traceStream(nullptr),
|
||||||
|
withPC(p->with_pc)
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string filename;
|
||||||
if (p->trace_file != "") {
|
if (p->trace_file != "") {
|
||||||
|
@ -102,6 +103,8 @@ MemTraceProbe::handleRequest(const ProbePoints::PacketInfo &pkt_info)
|
||||||
pkt_msg.set_flags(pkt_info.flags);
|
pkt_msg.set_flags(pkt_info.flags);
|
||||||
pkt_msg.set_addr(pkt_info.addr);
|
pkt_msg.set_addr(pkt_info.addr);
|
||||||
pkt_msg.set_size(pkt_info.size);
|
pkt_msg.set_size(pkt_info.size);
|
||||||
|
if (withPC && pkt_info.pc != 0)
|
||||||
|
pkt_msg.set_pc(pkt_info.pc);
|
||||||
|
|
||||||
traceStream->write(pkt_msg);
|
traceStream->write(pkt_msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,11 @@ class MemTraceProbe : public BaseMemProbe
|
||||||
|
|
||||||
/** Trace output stream */
|
/** Trace output stream */
|
||||||
ProtoOutputStream *traceStream;
|
ProtoOutputStream *traceStream;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/** Include the Program Counter in the memory trace */
|
||||||
|
const bool withPC;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__MEM_PROBES_MEM_TRACE_HH__
|
#endif //__MEM_PROBES_MEM_TRACE_HH__
|
||||||
|
|
|
@ -56,12 +56,14 @@ struct PacketInfo {
|
||||||
Addr addr;
|
Addr addr;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
Request::FlagsType flags;
|
Request::FlagsType flags;
|
||||||
|
Addr pc;
|
||||||
|
|
||||||
explicit PacketInfo(const PacketPtr& pkt) :
|
explicit PacketInfo(const PacketPtr& pkt) :
|
||||||
cmd(pkt->cmd),
|
cmd(pkt->cmd),
|
||||||
addr(pkt->getAddr()),
|
addr(pkt->getAddr()),
|
||||||
size(pkt->getSize()),
|
size(pkt->getSize()),
|
||||||
flags(pkt->req->getFlags()) { }
|
flags(pkt->req->getFlags()),
|
||||||
|
pc(pkt->req->hasPC() ? pkt->req->getPC() : 0) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -118,11 +118,15 @@ def main():
|
||||||
if packet.HasField('pkt_id'):
|
if packet.HasField('pkt_id'):
|
||||||
ascii_out.write('%s,' % (packet.pkt_id))
|
ascii_out.write('%s,' % (packet.pkt_id))
|
||||||
if packet.HasField('flags'):
|
if packet.HasField('flags'):
|
||||||
ascii_out.write('%s,%s,%s,%s,%s\n' % (cmd, packet.addr, packet.size,
|
ascii_out.write('%s,%s,%s,%s,%s' % (cmd, packet.addr, packet.size,
|
||||||
packet.flags, packet.tick))
|
packet.flags, packet.tick))
|
||||||
else:
|
else:
|
||||||
ascii_out.write('%s,%s,%s,%s\n' % (cmd, packet.addr, packet.size,
|
ascii_out.write('%s,%s,%s,%s' % (cmd, packet.addr, packet.size,
|
||||||
packet.tick))
|
packet.tick))
|
||||||
|
if packet.HasField('pc'):
|
||||||
|
ascii_out.write(',%s\n' % (packet.pc))
|
||||||
|
else:
|
||||||
|
ascii_out.write('\n')
|
||||||
|
|
||||||
print "Parsed packets:", num_packets
|
print "Parsed packets:", num_packets
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue