tracing: simplify confusing iponly/memonly configuration

The internal m_iponly / m_memonly bools are a bit hackish; especially it's
unclear what should happen if both are set.  The m_tracetype enum now
encompasses all possible configurations, while the plugin's user interface
remains unchanged.

Change-Id: Ibdd872b5cc5781836428b27bfb2db3825700e671
This commit is contained in:
Horst Schirmeier
2013-10-17 19:03:27 +02:00
parent 64034e29b4
commit f2d0919553
2 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ bool TracingPlugin::run()
// ev_step is added in the first loop iteration
if (m_memonly || !m_iponly) {
if (m_tracetype | TRACE_MEM) {
simulator.addListener(&ev_mem);
}
if(m_protoStreamFile) {
@ -41,7 +41,7 @@ bool TracingPlugin::run()
curtime = simulator.getTimerTicks();
deltatime = curtime - prevtime;
if (ev == &ev_step || (first && (m_iponly || !m_memonly))) {
if (ev == &ev_step || (first && (m_tracetype | TRACE_IP))) {
first = false;
simulator.addListener(&ev_step);
address_t ip = simulator.getCPU(0).getInstructionPointer();

View File

@ -40,8 +40,8 @@ class TracingPlugin : public fail::ExperimentFlow
private:
fail::MemoryMap *m_memMap; //!< address restriction for memory accesses
fail::MemoryMap *m_ipMap; //!< instruction address restriction
bool m_memonly; //!< log instructions only if they are memory accesses
bool m_iponly; //!< log instruction addresses only
//! trace nothing / instructions / mem accesses / both (can be bitwise ORed)
enum { TRACE_NONE = 0, TRACE_IP, TRACE_MEM, TRACE_BOTH } m_tracetype;
bool m_full_trace; //!< do a full trace (more information for the events)
std::ostream *m_protoStreamFile;
@ -50,7 +50,7 @@ private:
public:
TracingPlugin(bool full_trace = false)
: m_memMap(0), m_ipMap(0), m_memonly(false), m_iponly(false),
: m_memMap(0), m_ipMap(0), m_tracetype(TRACE_BOTH),
m_full_trace(full_trace), m_protoStreamFile(0), m_os(0) { }
bool run();
/**
@ -71,11 +71,11 @@ public:
* conducted a memory access. Defaults to false: All instructions are
* logged.
*/
void setLogMemOnly(bool memonly) { m_memonly = memonly; }
void setLogMemOnly(bool memonly = true) { m_tracetype = memonly ? TRACE_MEM : TRACE_BOTH; }
/**
* If invoked with iponly=true, only instruction addresses are logged.
*/
void setLogIPOnly(bool iponly) { m_iponly = iponly; }
void setLogIPOnly(bool iponly = true) { m_tracetype = iponly ? TRACE_IP : TRACE_BOTH; }
/**
* If invoked with fulltrace=true, a extended (full) trace is done.
*/