From 2b34877c5dbf24eabf331a124b1e68d901a72cba Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Wed, 3 Oct 2018 14:42:37 +0200 Subject: refactor klee_open_output_file to return std::unique_ptr and introduce klee_open_compressed_output_file with similar behavior along some other minor improvements --- lib/Core/StatsTracker.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'lib/Core/StatsTracker.cpp') diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 6ad5b89f..dee14e61 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -176,8 +176,6 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename, bool _updateMinDistToUncovered) : executor(_executor), objectFilename(_objectFilename), - statsFile(0), - istatsFile(0), startWallTime(util::getWallTime()), numBranches(0), fullBranches(0), @@ -243,12 +241,15 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename, if (OutputStats) { statsFile = executor.interpreterHandler->openOutputFile("run.stats"); - assert(statsFile && "unable to open statistics trace file"); - writeStatsHeader(); - writeStatsLine(); + if (statsFile) { + writeStatsHeader(); + writeStatsLine(); - if (StatsWriteInterval > 0) - executor.addTimer(new WriteStatsTimer(this), StatsWriteInterval); + if (StatsWriteInterval > 0) + executor.addTimer(new WriteStatsTimer(this), StatsWriteInterval); + } else { + klee_error("Unable to open statistics trace file (run.stats)."); + } } // Add timer to calculate uncovered instructions if needed by the solver @@ -259,18 +260,15 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename, if (OutputIStats) { istatsFile = executor.interpreterHandler->openOutputFile("run.istats"); - assert(istatsFile && "unable to open istats file"); - - if (IStatsWriteInterval > 0) - executor.addTimer(new WriteIStatsTimer(this), IStatsWriteInterval); + if (istatsFile) { + if (IStatsWriteInterval > 0) + executor.addTimer(new WriteIStatsTimer(this), IStatsWriteInterval); + } else { + klee_error("Unable to open instruction level stats file (run.istats)."); + } } } -StatsTracker::~StatsTracker() { - delete statsFile; - delete istatsFile; -} - void StatsTracker::done() { if (statsFile) writeStatsLine(); @@ -278,7 +276,8 @@ void StatsTracker::done() { if (OutputIStats) { if (updateMinDistToUncovered) computeReachableUncovered(); - writeIStats(); + if (istatsFile) + writeIStats(); } } -- cgit 1.4.1