mem: Add Program Counter to MemTraceProbe
authorVictor Garcia <victor.garcia@arm.com>
Thu, 7 Apr 2016 16:32:38 +0000 (11:32 -0500)
committerVictor Garcia <victor.garcia@arm.com>
Thu, 7 Apr 2016 16:32:38 +0000 (11:32 -0500)
src/mem/probes/MemTraceProbe.py
src/mem/probes/mem_trace.cc
src/mem/probes/mem_trace.hh
src/sim/probe/mem.hh
util/decode_packet_trace.py

index 971765eb48fcf1d2b526de1cd0e61ef7ed1ccef9..c51ec92824cf7f71a08bb6259cd4630dacb1818a 100644 (file)
@@ -46,6 +46,9 @@ class MemTraceProbe(BaseMemProbe):
     # Boolean to compress the trace or not.
     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
     trace_file = Param.String("", "Packet trace output file")
 
index 121c6de48e01e8dc07135cb7078128dc53b19418..97b97daae9ba0a611fab5d28ba64965225136a19 100644 (file)
@@ -47,7 +47,8 @@
 
 MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
     : BaseMemProbe(p),
-      traceStream(nullptr)
+      traceStream(nullptr),
+      withPC(p->with_pc)
 {
     std::string filename;
     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_addr(pkt_info.addr);
     pkt_msg.set_size(pkt_info.size);
+    if (withPC && pkt_info.pc != 0)
+        pkt_msg.set_pc(pkt_info.pc);
 
     traceStream->write(pkt_msg);
 }
index d34235eef52f5f0ee8f0a56ac99506854da629f5..158c5aacb63466844f9bc2c2869d1be5f6e365fb 100644 (file)
@@ -64,6 +64,11 @@ class MemTraceProbe : public BaseMemProbe
 
     /** Trace output stream */
     ProtoOutputStream *traceStream;
+
+  private:
+
+    /** Include the Program Counter in the memory trace */
+    const bool withPC;
 };
 
 #endif //__MEM_PROBES_MEM_TRACE_HH__
index 2d4b9aeec5ba64cd29e14a4dced59018136021d8..f17815babda1ea70b06492cf5b906ccfb81ce4c9 100644 (file)
@@ -56,12 +56,14 @@ struct PacketInfo {
     Addr addr;
     uint32_t size;
     Request::FlagsType flags;
+    Addr pc;
 
     explicit PacketInfo(const PacketPtr& pkt) :
         cmd(pkt->cmd),
         addr(pkt->getAddr()),
         size(pkt->getSize()),
-        flags(pkt->req->getFlags()) { }
+        flags(pkt->req->getFlags()),
+        pc(pkt->req->hasPC() ? pkt->req->getPC() : 0)  { }
 };
 
 /**
index e9105753d756e07345919e12ecf61f572d285115..97d3441630902684f75ba9c7990df4eb249fa858 100755 (executable)
@@ -118,11 +118,15 @@ def main():
         if packet.HasField('pkt_id'):
             ascii_out.write('%s,' % (packet.pkt_id))
         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))
         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))
+        if packet.HasField('pc'):
+            ascii_out.write(',%s\n' % (packet.pc))
+        else:
+            ascii_out.write('\n')
 
     print "Parsed packets:", num_packets