From f2d0919553e8af6b1d24c1530acae3bdc3f2aa0f Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Thu, 17 Oct 2013 19:03:27 +0200 Subject: [PATCH] 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 --- src/plugins/tracing/TracingPlugin.cc | 4 ++-- src/plugins/tracing/TracingPlugin.hpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/tracing/TracingPlugin.cc b/src/plugins/tracing/TracingPlugin.cc index 7dbb4f0e..cfc69d33 100644 --- a/src/plugins/tracing/TracingPlugin.cc +++ b/src/plugins/tracing/TracingPlugin.cc @@ -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(); diff --git a/src/plugins/tracing/TracingPlugin.hpp b/src/plugins/tracing/TracingPlugin.hpp index e8cec478..1004e949 100644 --- a/src/plugins/tracing/TracingPlugin.hpp +++ b/src/plugins/tracing/TracingPlugin.hpp @@ -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. */