From eba0093c4887473be2562a7ab4e16b3d09793f4e Mon Sep 17 00:00:00 2001 From: Andrea Mattavelli Date: Thu, 12 May 2016 11:17:48 +0100 Subject: Modified -debug-print-instructions to allow to write directly on log file. The option now contains 4 different options: 1) all:stderr, which logs all instructions to file in format [src, inst_id, llvm_inst]; 2) src:stderr, which logs all instructions to file in format [src, inst_id]; 3) compact:stderr, which logs all instructions to file in format [inst_id]; 4) all:file, which logs all instructions to file in format [src, inst_id, llvm_inst]; 5) src:file, which logs all instructions to file in format [src, inst_id]; 6) compact:file, which logs all instructions to file in format [inst_id]; Writing to file gives a speedup of ~50x. --- lib/Core/Executor.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/Core/Executor.h') diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h index 1997bad2..600c7b90 100644 --- a/lib/Core/Executor.h +++ b/lib/Core/Executor.h @@ -21,6 +21,7 @@ #include "klee/Internal/Module/KInstruction.h" #include "klee/Internal/Module/KModule.h" #include "klee/util/ArrayCache.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Twine.h" @@ -183,12 +184,22 @@ private: /// Assumes ownership of the created array objects ArrayCache arrayCache; + /// File to print executed instructions to + llvm::raw_ostream *debugInstFile; + + // @brief Buffer used by logBuffer + std::string debugBufferString; + + // @brief buffer to store logs before flushing to file + llvm::raw_string_ostream debugLogBuffer; + llvm::Function* getTargetFunction(llvm::Value *calledVal, ExecutionState &state); void executeInstruction(ExecutionState &state, KInstruction *ki); - void printFileLine(ExecutionState &state, KInstruction *ki); + void printFileLine(ExecutionState &state, KInstruction *ki, + llvm::raw_ostream &file); void run(ExecutionState &initialState); @@ -400,6 +411,7 @@ private: void processTimers(ExecutionState *current, double maxInstTime); void checkMemoryUsage(); + void printDebugInstructions(ExecutionState &state); public: Executor(const InterpreterOptions &opts, InterpreterHandler *ie); -- cgit 1.4.1