Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/7563

Change subject: cpu: Use the new asBytes function in the protobuf inst tracer.
......................................................................

cpu: Use the new asBytes function in the protobuf inst tracer.

Use this function to get the binary representation of the instruction
rather than referencing the ExtMachInst typed machInst member of the
StaticInst directly. ExtMachInst is an ISA specific type and can't
always be straightforwardly squished into a 32 bit integer.

Change-Id: Ic1f74d6d86eb779016677ae45c022939ce3e2b9f
---
M src/cpu/inst_pb_trace.cc
M src/cpu/inst_pb_trace.hh
2 files changed, 18 insertions(+), 2 deletions(-)



diff --git a/src/cpu/inst_pb_trace.cc b/src/cpu/inst_pb_trace.cc
index 4003600..8bce38d 100644
--- a/src/cpu/inst_pb_trace.cc
+++ b/src/cpu/inst_pb_trace.cc
@@ -69,7 +69,7 @@
 }

 InstPBTrace::InstPBTrace(const InstPBTraceParams *p)
-    : InstTracer(p), curMsg(nullptr)
+    : InstTracer(p), buf(nullptr), bufSize(0), curMsg(nullptr)
 {
     // Create our output file
     createTraceFile(p->file_name);
@@ -141,10 +141,23 @@
         curMsg = NULL;
     }

+    size_t instSize = bufSize;
+    si->asBytes(buf.get(), instSize);
+    if (instSize > bufSize) {
+        bufSize = instSize;
+        buf.reset(new uint8_t[bufSize]);
+        si->asBytes(buf.get(), instSize);
+    }
+
     // Create a new instruction message and fill out the fields
     curMsg = new ProtoMessage::Inst;
     curMsg->set_pc(pc.pc());
-    curMsg->set_inst(static_cast<uint32_t>(bits(si->machInst, 31, 0)));
+    if (instSize == sizeof(uint32_t)) {
+        curMsg->set_inst(letoh(*reinterpret_cast<uint32_t *>(buf.get())));
+    } else if (instSize) {
+        curMsg->set_inst_bytes(
+ std::string(reinterpret_cast<const char *>(buf.get()), bufSize));
+    }
     curMsg->set_cpuid(tc->cpuId());
     curMsg->set_tick(curTick());
curMsg->set_type(static_cast<ProtoMessage::Inst_InstType>(si->opClass()));
diff --git a/src/cpu/inst_pb_trace.hh b/src/cpu/inst_pb_trace.hh
index 57b3c2c..e9e0147 100644
--- a/src/cpu/inst_pb_trace.hh
+++ b/src/cpu/inst_pb_trace.hh
@@ -93,6 +93,9 @@
                                     StaticInstPtr mi = NULL) override;

   protected:
+    std::unique_ptr<uint8_t []> buf;
+    size_t bufSize;
+
     /** One output stream for the entire simulation.
      * We encode the CPU & system ID so all we need is a single file
      */

--
To view, visit https://gem5-review.googlesource.com/7563
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1f74d6d86eb779016677ae45c022939ce3e2b9f
Gerrit-Change-Number: 7563
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to