tracing: fix loss of first dynamic instruction

When starting the tracing plugin (simulator.addFlow()), at the moment
the *current* dynamic instruction (e.g., the one the start symbol
points to) is skipped, and tracing commences with the second
instruction.  This change records an additional instruction event at
the trace begin.

Note that this change affects all tracing-plugin users.  The first
event gets recorded when starting the plugin (simulator.addFlow()).
This avoids compatibility/off-by-one issues when recording traces with
the generic-tracing experiment vs. with custom experiments.

Change-Id: Ic24e17a68b8a44edad3be994e9edd6d6712bfda1
This commit is contained in:
Horst Schirmeier
2013-10-15 16:15:56 +02:00
parent 090125a283
commit 3dc752cd09

View File

@ -16,11 +16,10 @@ bool TracingPlugin::run()
MemAccessListener ev_mem(ANY_ADDR); MemAccessListener ev_mem(ANY_ADDR);
BPSingleListener ev_step(ANY_ADDR); BPSingleListener ev_step(ANY_ADDR);
BaseListener *ev; BaseListener *ev = 0;
// ev_step is added in the first loop iteration
if (m_iponly || !m_memonly) {
simulator.addListener(&ev_step);
}
if (m_memonly || !m_iponly) { if (m_memonly || !m_iponly) {
simulator.addListener(&ev_mem); simulator.addListener(&ev_mem);
} }
@ -36,16 +35,17 @@ bool TracingPlugin::run()
simtime_t prevtime = 0, curtime; simtime_t prevtime = 0, curtime;
simtime_diff_t deltatime; simtime_diff_t deltatime;
while (true) { bool first = true;
ev = simulator.resume();
while (true) {
curtime = simulator.getTimerTicks(); curtime = simulator.getTimerTicks();
deltatime = curtime - prevtime; deltatime = curtime - prevtime;
if (ev == &ev_step) { if (ev == &ev_step || (first && (m_iponly || !m_memonly))) {
first = false;
simulator.addListener(&ev_step); simulator.addListener(&ev_step);
address_t ip = simulator.getCPU(0).getInstructionPointer();
address_t ip = ev_step.getTriggerInstructionPointer();
if (m_ipMap && !m_ipMap->isMatching(ip)) { if (m_ipMap && !m_ipMap->isMatching(ip)) {
continue; continue;
} }
@ -115,7 +115,7 @@ bool TracingPlugin::run()
ps->writeMessage(&e); ps->writeMessage(&e);
} }
} else { } else if (!first) {
if (m_os) if (m_os)
*m_os << "[Tracing] SOMETHING IS SERIOUSLY WRONG\n"; *m_os << "[Tracing] SOMETHING IS SERIOUSLY WRONG\n";
} }
@ -123,6 +123,8 @@ bool TracingPlugin::run()
// do this only if the last delta was written // do this only if the last delta was written
// (no, e.g., memory map mismatch) // (no, e.g., memory map mismatch)
prevtime = curtime; prevtime = curtime;
ev = simulator.resume();
} }
return true; return true;