From 8a531bf8f276274b146dbb245293b06d31dfaef4 Mon Sep 17 00:00:00 2001 From: Frank Busse Date: Tue, 30 Jul 2019 14:17:17 +0100 Subject: ExecutorTimers: move dumpStates/dumpPTree into Executor * creates two new methods: dumpStates, dumpPTree --- lib/Core/ExecutorTimers.cpp | 66 +++------------------------------------------ 1 file changed, 3 insertions(+), 63 deletions(-) (limited to 'lib/Core/ExecutorTimers.cpp') diff --git a/lib/Core/ExecutorTimers.cpp b/lib/Core/ExecutorTimers.cpp index e1d6684d..81ab7651 100644 --- a/lib/Core/ExecutorTimers.cpp +++ b/lib/Core/ExecutorTimers.cpp @@ -62,10 +62,6 @@ public: static const time::Span kMilliSecondsPerTick(time::milliseconds(100)); static volatile unsigned timerTicks = 0; -// XXX hack -extern "C" unsigned dumpStates, dumpPTree; -unsigned dumpStates = 0, dumpPTree = 0; - static void onAlarm(int) { ++timerTicks; } @@ -114,63 +110,7 @@ void Executor::processTimers(ExecutionState *current, ticks = 1; } - if (ticks || dumpPTree || dumpStates) { - if (dumpPTree) { - char name[32]; - snprintf(name, sizeof(name), "ptree%08d.dot", (int) stats::instructions); - auto os = interpreterHandler->openOutputFile(name); - if (os) { - processTree->dump(*os); - } - - dumpPTree = 0; - } - - if (dumpStates) { - auto os = interpreterHandler->openOutputFile("states.txt"); - - if (os) { - for (ExecutionState *es : states) { - *os << "(" << es << ","; - *os << "["; - auto next = es->stack.begin(); - ++next; - for (auto sfIt = es->stack.begin(), sf_ie = es->stack.end(); - sfIt != sf_ie; ++sfIt) { - *os << "('" << sfIt->kf->function->getName().str() << "',"; - if (next == es->stack.end()) { - *os << es->prevPC->info->line << "), "; - } else { - *os << next->caller->info->line << "), "; - ++next; - } - } - *os << "], "; - - StackFrame &sf = es->stack.back(); - uint64_t md2u = computeMinDistToUncovered(es->pc, - sf.minDistToUncoveredOnReturn); - uint64_t icnt = theStatisticManager->getIndexedValue(stats::instructions, - es->pc->info->id); - uint64_t cpicnt = sf.callPathNode->statistics.getValue(stats::instructions); - - *os << "{"; - *os << "'depth' : " << es->depth << ", "; - *os << "'weight' : " << es->weight << ", "; - *os << "'queryCost' : " << es->queryCost << ", "; - *os << "'coveredNew' : " << es->coveredNew << ", "; - *os << "'instsSinceCovNew' : " << es->instsSinceCovNew << ", "; - *os << "'md2u' : " << md2u << ", "; - *os << "'icnt' : " << icnt << ", "; - *os << "'CPicnt' : " << cpicnt << ", "; - *os << "}"; - *os << ")\n"; - } - } - - dumpStates = 0; - } - + if (ticks) { if (maxInstTime && current && std::find(removedStates.begin(), removedStates.end(), current) == removedStates.end()) { @@ -183,10 +123,10 @@ void Executor::processTimers(ExecutionState *current, if (!timers.empty()) { auto time = time::getWallTime(); - for (std::vector::iterator it = timers.begin(), + for (std::vector::iterator it = timers.begin(), ie = timers.end(); it != ie; ++it) { TimerInfo *ti = *it; - + if (time >= ti->nextFireTime) { ti->timer->run(); ti->nextFireTime = time + ti->rate; -- cgit 1.4.1