about summary refs log tree commit diff homepage
path: root/lib/Core/Executor.h
diff options
context:
space:
mode:
authorAndrea Mattavelli <andreamattavelli@gmail.com>2016-05-12 11:17:48 +0100
committerAndrea Mattavelli <andreamattavelli@gmail.com>2016-05-18 10:22:51 +0100
commiteba0093c4887473be2562a7ab4e16b3d09793f4e (patch)
treee03582fee517db083a42b3057b1f4bad187de059 /lib/Core/Executor.h
parente481f415042b9bcb5af6d057648852a9d8ef7d4e (diff)
downloadklee-eba0093c4887473be2562a7ab4e16b3d09793f4e.tar.gz
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.
Diffstat (limited to 'lib/Core/Executor.h')
-rw-r--r--lib/Core/Executor.h14
1 files changed, 13 insertions, 1 deletions
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);