about summary refs log tree commit diff homepage
path: root/lib/Solver/QueryLoggingSolver.h
diff options
context:
space:
mode:
authorCristian Cadar <cristic@cs.stanford.edu>2013-01-02 16:15:37 +0000
committerCristian Cadar <cristic@cs.stanford.edu>2013-01-02 16:15:37 +0000
commit8181cb0c5bd1f9e95fe47cf5c6631024d7d5982b (patch)
tree1cb5a159fa31c038175cd34cb02cee02eefcc4bc /lib/Solver/QueryLoggingSolver.h
parent79237753a1e9cbe653e5763ffd61f3cb5b8759c1 (diff)
downloadklee-8181cb0c5bd1f9e95fe47cf5c6631024d7d5982b.tar.gz
Forgot to add QueryLoggingSolver in patch 171387 from Tomasz Kuchta.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@171392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Solver/QueryLoggingSolver.h')
-rw-r--r--lib/Solver/QueryLoggingSolver.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/Solver/QueryLoggingSolver.h b/lib/Solver/QueryLoggingSolver.h
new file mode 100644
index 00000000..527d075b
--- /dev/null
+++ b/lib/Solver/QueryLoggingSolver.h
@@ -0,0 +1,77 @@
+//===-- QueryLoggingSolver.h ---------------------------------------------------===//
+//
+//                     The KLEE Symbolic Virtual Machine
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef KLEE_QUERYLOGGINGSOLVER_H
+#define	KLEE_QUERYLOGGINGSOLVER_H
+
+#include "klee/Solver.h"
+#include "klee/SolverImpl.h"
+#include <fstream>
+#include <sstream>
+
+using namespace klee;
+
+/// This abstract class represents a solver that is capable of logging 
+/// queries to a file.
+/// Derived classes might specialize this one by providing different formats
+/// for the query output.
+class QueryLoggingSolver : public SolverImpl {
+
+protected:
+    Solver *solver;
+    std::ofstream os;
+    std::ostringstream logBuffer; // buffer to store logs before flushing to 
+                                  // file
+    unsigned queryCount;
+    int minQueryTimeToLog; // we log to file only those queries
+                           // which take longer than the specified time (ms);
+                           // if this param is negative, log only those queries
+                           // on which the solver has timed out
+
+    double startTime;
+    double lastQueryTime;
+    const std::string queryCommentSign; // sign representing commented lines
+                                        // in given a query format
+
+    virtual void startQuery(const Query& query, const char* typeName,
+                            const Query* falseQuery = 0,
+                            const std::vector<const Array*>* objects = 0);
+           
+    virtual void finishQuery(bool success);        
+  
+    /// flushBuffer - flushes the temporary logs buffer. Depending on threshold
+    /// settings, contents of the buffer are either discarded or written to a file.  
+    void flushBuffer(void);
+    
+    virtual void printQuery(const Query& query,
+                            const Query* falseQuery = 0,
+                            const std::vector<const Array*>* objects = 0) = 0;
+  
+public:
+    QueryLoggingSolver(Solver *_solver,
+                       std::string path,
+                       const std::string& commentSign,
+                       int queryTimeToLog);
+  
+    virtual ~QueryLoggingSolver();
+
+    /// implementation of the SolverImpl interface
+    bool computeTruth(const Query& query, bool &isValid);
+    bool computeValidity(const Query& query, Solver::Validity &result);
+    bool computeValue(const Query& query, ref<Expr> &result);
+    bool computeInitialValues(const Query& query,
+                              const std::vector<const Array*> &objects,
+                              std::vector< std::vector<unsigned char> > &values,
+                              bool &hasSolution);
+    SolverRunStatus getOperationStatusCode();
+
+};
+
+#endif	/* KLEE_QUERYLOGGINGSOLVER_H */
+