weathermonitor-experiment adapted to ProtoStream

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1299 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
hellwig
2012-06-05 12:48:53 +00:00
parent 362ed5bb18
commit 03c1ce8a0f
2 changed files with 13 additions and 20 deletions

View File

@ -7,6 +7,7 @@
#include "controller/CampaignManager.hpp" #include "controller/CampaignManager.hpp"
#include "util/Logger.hpp" #include "util/Logger.hpp"
#include "util/MemoryMap.hpp" #include "util/MemoryMap.hpp"
#include "util/ProtoStream.hpp"
#include "vptr_map.hpp" #include "vptr_map.hpp"
@ -43,16 +44,12 @@ bool WeathermonitorCampaign::run()
log << "startup" << endl; log << "startup" << endl;
// load trace // load trace
log << "loading trace ..." << endl;
ifstream tracef(trace_filename); ifstream tracef(trace_filename);
if (tracef.fail()) { if (tracef.fail()) {
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();
log << "... done." << endl;
// a map of FI data addresses // a map of FI data addresses
MemoryMap mm; MemoryMap mm;
@ -81,24 +78,23 @@ bool WeathermonitorCampaign::run()
current_ec.instr1 = 0; current_ec.instr1 = 0;
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;
ps.reset();
// for every section in the trace between subsequent memory // for every section in the trace between subsequent memory
// accesses to that address ... // accesses to that address ...
for (int eventnr = 0; eventnr < trace.event_size(); ++eventnr) { while(ps.getNext(&ev)) {
ev = &trace.event(eventnr);
// instruction events just get counted // instruction events just get counted
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
// FIXME again, do it the other way around, and use mm.isMatching()! // FIXME again, do it the other way around, and use mm.isMatching()!
} else if (ev->memaddr() + ev->width() <= data_address } else if (ev.memaddr() + ev.width() <= data_address
|| ev->memaddr() > data_address) { || ev.memaddr() > data_address) {
continue; continue;
// skip zero-sized intervals: these can // skip zero-sized intervals: these can
@ -118,7 +114,7 @@ bool WeathermonitorCampaign::run()
current_ec.instr2_absolute = instr_absolute; current_ec.instr2_absolute = instr_absolute;
current_ec.data_address = data_address; current_ec.data_address = data_address;
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
@ -137,7 +133,7 @@ bool WeathermonitorCampaign::run()
fi::campaignmanager.addParam(d); fi::campaignmanager.addParam(d);
++count; ++count;
} 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.

View File

@ -68,8 +68,8 @@ bool WeathermonitorExperiment::run()
//tp.setLogIPOnly(true); //tp.setLogIPOnly(true);
// 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);
@ -94,14 +94,11 @@ bool WeathermonitorExperiment::run()
sal::simulator.removeFlow(&tp); sal::simulator.removeFlow(&tp);
// serialize trace to file // serialize trace to file
char const *tracefile = "trace.pb";
std::ofstream of(tracefile);
if (of.fail()) { if (of.fail()) {
log << "failed to write " << tracefile << endl; log << "failed to write " << tracefile << endl;
sal::simulator.clearEvents(this); // cleanup sal::simulator.clearEvents(this); // cleanup
return false; return false;
} }
trace.SerializeToOstream(&of);
of.close(); of.close();
log << "trace written to " << tracefile << endl; log << "trace written to " << tracefile << endl;