tracing: fix endless loop when only tracing mem accesses

With m_tracetype=TRACE_MEM, bool first was never reset to false in the
tracing plugin's main loop.  This bug was most probably never
triggered, though, as nobody only traces memory accesses.

This change also slightly simplifies the internal logic in the tracing
plugin.

Change-Id: I65d7df6a3781ec552cfb892bbf3394b421e227f1
This commit is contained in:
Horst Schirmeier
2014-02-11 10:32:55 +01:00
parent 01c1321b48
commit 85152238da

View File

@ -35,18 +35,18 @@ bool TracingPlugin::run()
simtime_t prevtime = 0, curtime; simtime_t prevtime = 0, curtime;
simtime_diff_t deltatime; simtime_diff_t deltatime;
bool first = true; bool record_first_ipevent = m_tracetype | TRACE_IP;
while (true) { while (true) {
if (!first) { if (!record_first_ipevent) {
ev = simulator.resume(); ev = simulator.resume();
} }
curtime = simulator.getTimerTicks(); curtime = simulator.getTimerTicks();
deltatime = curtime - prevtime; deltatime = curtime - prevtime;
if (ev == &ev_step || (first && (m_tracetype | TRACE_IP))) { if (ev == &ev_step || record_first_ipevent) {
first = false; record_first_ipevent = false;
simulator.addListener(&ev_step); simulator.addListener(&ev_step);
address_t ip = simulator.getCPU(0).getInstructionPointer(); address_t ip = simulator.getCPU(0).getInstructionPointer();
@ -127,7 +127,7 @@ bool TracingPlugin::run()
ps->writeMessage(&e); ps->writeMessage(&e);
} }
} else if (!first) { } else {
if (m_os) if (m_os)
*m_os << "[Tracing] SOMETHING IS SERIOUSLY WRONG\n"; *m_os << "[Tracing] SOMETHING IS SERIOUSLY WRONG\n";
} }