# packet trace output file, disabled by default
trace_file = Param.String("", "Packet trace output file")
+ # System object to look up the name associated with a master ID
+ system = Param.System(Parent.any, "System the probe belongs to")
#include "base/output.hh"
#include "params/MemTraceProbe.hh"
#include "proto/packet.pb.h"
+#include "sim/system.hh"
MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
: BaseMemProbe(p),
traceStream(nullptr),
+ system(p->system),
withPC(p->with_pc)
{
std::string filename;
traceStream = new ProtoOutputStream(filename);
+ // Register a callback to compensate for the destructor not
+ // being called. The callback forces the stream to flush and
+ // closes the output file.
+ registerExitCallback(
+ new MakeCallback<MemTraceProbe, &MemTraceProbe::closeStreams>(this));
+}
+
+void
+MemTraceProbe::startup()
+{
// Create a protobuf message for the header and write it to
// the stream
ProtoMessage::PacketHeader header_msg;
header_msg.set_obj_id(name());
header_msg.set_tick_freq(SimClock::Frequency);
- traceStream->write(header_msg);
- // Register a callback to compensate for the destructor not
- // being called. The callback forces the stream to flush and
- // closes the output file.
- registerExitCallback(
- new MakeCallback<MemTraceProbe, &MemTraceProbe::closeStreams>(this));
+ for (int i = 0; i < system->maxMasters(); i++) {
+ auto id_string = header_msg.add_id_strings();
+ id_string->set_key(i);
+ id_string->set_value(system->getMasterName(i));
+ }
+
+ traceStream->write(header_msg);
}
void
#include "proto/protoio.hh"
struct MemTraceProbeParams;
+class System;
class MemTraceProbe : public BaseMemProbe
{
*/
void closeStreams();
+ void startup() override;
+
protected:
/** Trace output stream */
ProtoOutputStream *traceStream;
+ System *system;
+
private:
/** Include the Program Counter in the memory trace */