44#include "debug/ExecEnable.hh"
45#include "params/InstPBTrace.hh"
46#include "proto/inst.pb.h"
73 :
InstTracer(
p), buf(nullptr), bufSize(0), curMsg(nullptr)
89 ProtoMessage::InstHeader header_msg;
90 header_msg.set_obj_id(
"gem5 generated instruction trace");
91 header_msg.set_ver(0);
93 header_msg.set_has_mem(
true);
126 if (!debug::ExecEnable)
152 curMsg =
new ProtoMessage::Inst;
154 if (instSize ==
sizeof(uint32_t)) {
155 curMsg->set_inst(
letoh(*
reinterpret_cast<uint32_t *
>(
buf.get())));
156 }
else if (instSize) {
158 std::string(
reinterpret_cast<const char *
>(
buf.get()),
bufSize));
162 curMsg->set_type(
static_cast<ProtoMessage::Inst_InstType
>(
si->opClass()));
171 curMsg->set_type(
static_cast<ProtoMessage::Inst_InstType
>(
si->opClass()));
173 ProtoMessage::Inst::MemAccess *mem_msg =
curMsg->add_mem_access();
174 mem_msg->set_addr(
a);
175 mem_msg->set_size(
s);
176 mem_msg->set_mem_flags(
f);
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file ...
void write(const google::protobuf::Message &msg)
Write a message to the stream, preprending it with the message size.
std::string resolve(const std::string &name) const
Returns relative file names prepended with name of this directory.
bool isFirstMicroop() const
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual int cpuId() const =0
This in an instruction tracer that records the flow of instructions through multiple cpus and systems...
void dump() override
called by the cpu when the instruction commits.
InstPBTraceRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr si, const PCStateBase &pc, const StaticInstPtr mi=NULL) override
std::unique_ptr< uint8_t[]> buf
void closeStreams()
If there is a pending message still write it out and then close the file.
void createTraceFile(std::string filename)
Create the output file and write the header into it.
friend class InstPBTraceRecord
ProtoMessage::Inst * curMsg
This is the message were working on writing.
void traceMem(StaticInstPtr si, Addr a, Addr s, unsigned f)
Write a memory request to the trace file as part of the cur instruction.
InstPBTrace(const InstPBTraceParams &p)
void traceInst(ThreadContext *tc, StaticInstPtr si, const PCStateBase &pc)
Write an instruction to the trace file.
static ProtoOutputStream * traceStream
One output stream for the entire simulation.
unsigned getFlags() const
StaticInstPtr macroStaticInst
std::unique_ptr< PCStateBase > pc
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
void registerExitCallback(const std::function< void()> &callback)
Register an exit callback.