summaryrefslogtreecommitdiff
path: root/src/cpu/inst_pb_trace.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-01-25 00:21:58 -0800
committerGabe Black <gabeblack@google.com>2018-03-26 22:34:03 +0000
commit740619f5d394da3816ff3fe6389cd7eb6ac55b8f (patch)
treee230281721d458b07af54fd906cba5c24f116a0c /src/cpu/inst_pb_trace.cc
parent81050be736f0d7ac71e7f862a4f34b1ed6787716 (diff)
downloadgem5-740619f5d394da3816ff3fe6389cd7eb6ac55b8f.tar.xz
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 Reviewed-on: https://gem5-review.googlesource.com/7563 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/cpu/inst_pb_trace.cc')
-rw-r--r--src/cpu/inst_pb_trace.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cpu/inst_pb_trace.cc b/src/cpu/inst_pb_trace.cc
index 400360078..138ef5386 100644
--- a/src/cpu/inst_pb_trace.cc
+++ b/src/cpu/inst_pb_trace.cc
@@ -69,7 +69,7 @@ InstPBTraceRecord::dump()
}
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,22 @@ InstPBTrace::traceInst(ThreadContext *tc, StaticInstPtr si, TheISA::PCState pc)
curMsg = NULL;
}
+ size_t instSize = si->asBytes(buf.get(), bufSize);
+ if (instSize > bufSize) {
+ bufSize = instSize;
+ buf.reset(new uint8_t[bufSize]);
+ instSize = si->asBytes(buf.get(), bufSize);
+ }
+
// 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()));