Skip to content
Snippets Groups Projects
Commit 2ab9284f authored by Richard Hellwig's avatar Richard Hellwig
Browse files

coolchecksum adapted to ProtoStream

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1282 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
parent 2566658b
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "experimentInfo.hpp" #include "experimentInfo.hpp"
#include "controller/CampaignManager.hpp" #include "controller/CampaignManager.hpp"
#include "util/Logger.hpp" #include "util/Logger.hpp"
#include "util/ProtoStream.hpp"
#include "SAL/SALConfig.hpp" #include "SAL/SALConfig.hpp"
#if COOL_FAULTSPACE_PRUNING #if COOL_FAULTSPACE_PRUNING
...@@ -82,9 +83,7 @@ bool CoolChecksumCampaign::run() ...@@ -82,9 +83,7 @@ bool CoolChecksumCampaign::run()
log << "couldn't open " << trace_filename << endl; log << "couldn't open " << trace_filename << endl;
return false; return false;
} }
Trace trace; ProtoIStream ps(&tracef);
trace.ParseFromIstream(&tracef);
tracef.close();
// set of equivalence classes that need one (rather: eight, one for // set of equivalence classes that need one (rather: eight, one for
// each bit in that byte) experiment to determine them all // each bit in that byte) experiment to determine them all
...@@ -105,19 +104,19 @@ bool CoolChecksumCampaign::run() ...@@ -105,19 +104,19 @@ bool CoolChecksumCampaign::run()
// XXX reorganizing the trace for efficient seeks could speed this up // XXX reorganizing the trace for efficient seeks could speed this up
int instr = 0; int instr = 0;
sal::address_t instr_absolute = 0; // FIXME this one probably should also be recorded ... sal::address_t instr_absolute = 0; // FIXME this one probably should also be recorded ...
Trace_Event const *ev; Trace_Event ev;
for (int eventnr = 0; eventnr < trace.event_size(); ++eventnr) { ps.reset();
ev = &trace.event(eventnr);
while(ps.getNext(&ev)) {
// only count instruction events // only count instruction events
if (!ev->has_memaddr()) { if (!ev.has_memaddr()) {
// new instruction // new instruction
instr++; instr++;
instr_absolute = ev->ip(); instr_absolute = ev.ip();
continue; continue;
// skip accesses to other data // skip accesses to other data
} else if (ev->memaddr() != byte_offset + COOL_ECC_OBJUNDERTEST) { } else if (ev.memaddr() != byte_offset + COOL_ECC_OBJUNDERTEST) {
continue; continue;
// skip zero-sized intervals: these can // skip zero-sized intervals: these can
...@@ -137,12 +136,12 @@ bool CoolChecksumCampaign::run() ...@@ -137,12 +136,12 @@ bool CoolChecksumCampaign::run()
current_ec.instr2_absolute = instr_absolute; current_ec.instr2_absolute = instr_absolute;
current_ec.byte_offset = byte_offset; current_ec.byte_offset = byte_offset;
if (ev->accesstype() == ev->READ) { if (ev.accesstype() == ev.READ) {
// a sequence ending with READ: we need // a sequence ending with READ: we need
// to do one experiment to cover it // to do one experiment to cover it
// completely // completely
ecs_need_experiment.push_back(current_ec); ecs_need_experiment.push_back(current_ec);
} else if (ev->accesstype() == ev->WRITE) { } else if (ev.accesstype() == ev.WRITE) {
// a sequence ending with WRITE: an // a sequence ending with WRITE: an
// injection anywhere here would have // injection anywhere here would have
// no effect. // no effect.
......
...@@ -62,8 +62,8 @@ bool CoolChecksumExperiment::run() ...@@ -62,8 +62,8 @@ bool CoolChecksumExperiment::run()
tp.restrictMemoryAddresses(&mm); tp.restrictMemoryAddresses(&mm);
// record trace // record trace
Trace trace; std::ofstream of("trace.pb");
tp.setTraceMessage(&trace); tp.setTraceFile(&of);
// this must be done *after* configuring the plugin: // this must be done *after* configuring the plugin:
sal::simulator.addFlow(&tp); sal::simulator.addFlow(&tp);
...@@ -86,13 +86,11 @@ bool CoolChecksumExperiment::run() ...@@ -86,13 +86,11 @@ bool CoolChecksumExperiment::run()
sal::simulator.removeFlow(&tp); sal::simulator.removeFlow(&tp);
// serialize trace to file // serialize trace to file
std::ofstream of("trace.pb");
if (of.fail()) { if (of.fail()) {
log << "failed to write trace.pb" << endl; log << "failed to write trace.pb" << endl;
sal::simulator.clearEvents(this); sal::simulator.clearEvents(this);
return false; return false;
} }
trace.SerializeToOstream(&of);
of.close(); of.close();
#endif #endif
......
...@@ -22,7 +22,10 @@ bool TracingPlugin::run() ...@@ -22,7 +22,10 @@ bool TracingPlugin::run()
if (m_memonly || !m_iponly) { if (m_memonly || !m_iponly) {
simulator.addEvent(&ev_mem); simulator.addEvent(&ev_mem);
} }
if(m_protoStreamFile) {
ps = new ProtoOStream(m_protoStreamFile);
}
while (true) { while (true) {
ev = simulator.waitAny(); ev = simulator.waitAny();
...@@ -36,9 +39,10 @@ bool TracingPlugin::run() ...@@ -36,9 +39,10 @@ bool TracingPlugin::run()
if (m_os) if (m_os)
*m_os << "[Tracing] IP " << hex << ip << "\n"; *m_os << "[Tracing] IP " << hex << ip << "\n";
if (m_trace) { if (m_protoStreamFile) {
Trace_Event *e = m_trace->add_event(); Trace_Event e;
e->set_ip(ip); e.set_ip(ip);
ps->writeMessage(&e);
} }
} else if (ev == &ev_mem) { } else if (ev == &ev_mem) {
simulator.addEvent(&ev_mem); simulator.addEvent(&ev_mem);
...@@ -56,14 +60,15 @@ bool TracingPlugin::run() ...@@ -56,14 +60,15 @@ bool TracingPlugin::run()
<< ((ev_mem.getTriggerAccessType() & << ((ev_mem.getTriggerAccessType() &
MemAccessEvent::MEM_READ) ? "R " : "W ") MemAccessEvent::MEM_READ) ? "R " : "W ")
<< addr << " width " << width << " IP " << ip << "\n"; << addr << " width " << width << " IP " << ip << "\n";
if (m_trace) { if (m_protoStreamFile) {
Trace_Event *e = m_trace->add_event(); Trace_Event e;
e->set_ip(ip); e.set_ip(ip);
e->set_memaddr(addr); e.set_memaddr(addr);
e->set_width(width); e.set_width(width);
e->set_accesstype( e.set_accesstype(
(ev_mem.getTriggerAccessType() & MemAccessEvent::MEM_READ) ? (ev_mem.getTriggerAccessType() & MemAccessEvent::MEM_READ) ?
e->READ : e->WRITE); e.READ : e.WRITE);
ps->writeMessage(&e);
} }
} else { } else {
if (m_os) if (m_os)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <ostream> #include <ostream>
#include "controller/ExperimentFlow.hpp" #include "controller/ExperimentFlow.hpp"
#include "util/MemoryMap.hpp" #include "util/MemoryMap.hpp"
#include "util/ProtoStream.hpp"
#include "config/FailConfig.hpp" #include "config/FailConfig.hpp"
#include "plugins/tracing/trace.pb.h" #include "plugins/tracing/trace.pb.h"
...@@ -41,13 +42,14 @@ private: ...@@ -41,13 +42,14 @@ private:
bool m_memonly; //!< log instructions only if they are memory accesses bool m_memonly; //!< log instructions only if they are memory accesses
bool m_iponly; //!< log instruction addresses only bool m_iponly; //!< log instruction addresses only
Trace *m_trace; //!< protobuf message to store trace in std::ostream *m_protoStreamFile;
std::ostream *m_os; //!< ostream to write human-readable trace into std::ostream *m_os; //!< ostream to write human-readable trace into
ProtoOStream *ps;
public: public:
TracingPlugin() TracingPlugin()
: m_memMap(0), m_ipMap(0), m_memonly(false), m_iponly(false), : m_memMap(0), m_ipMap(0), m_memonly(false), m_iponly(false),
m_trace(0), m_os(0) { } m_protoStreamFile(0), m_os(0) { }
bool run(); bool run();
/** /**
* Restricts tracing to memory addresses listed in this MemoryMap. An * Restricts tracing to memory addresses listed in this MemoryMap. An
...@@ -77,9 +79,9 @@ public: ...@@ -77,9 +79,9 @@ public:
*/ */
void setOstream(std::ostream *os) { m_os = os; } void setOstream(std::ostream *os) { m_os = os; }
/** /**
* Protobuf message to trace into (trace.proto instance) * ProtoStream file to trace into (trace.proto instance)
*/ */
void setTraceMessage(Trace *trace) { m_trace = trace; } void setTraceFile(std::ostream *os) { m_protoStreamFile = os; }
}; };
#endif /* __TRACING_PLUGIN_HPP__ */ #endif /* __TRACING_PLUGIN_HPP__ */
message Trace { message Trace_Event {
repeated group Event = 1{ required uint64 ip = 1;
required uint64 ip = 1;
optional uint64 memaddr = 2; optional uint64 memaddr = 2;
optional uint32 width = 3; optional uint32 width = 3;
enum AccessType { enum AccessType {
...@@ -8,5 +7,4 @@ message Trace { ...@@ -8,5 +7,4 @@ message Trace {
WRITE = 2; WRITE = 2;
} }
optional AccessType accesstype = 4; optional AccessType accesstype = 4;
}
} }
...@@ -2,6 +2,7 @@ set(SRCS ...@@ -2,6 +2,7 @@ set(SRCS
SynchronizedCounter.cc SynchronizedCounter.cc
Logger.hpp Logger.hpp
Logger.cc Logger.cc
ProtoStream.cc
) )
add_library(util ${SRCS}) add_library(util ${SRCS})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment