SpecialFunctionHandler.h

Go to the documentation of this file.
00001 //===-- SpecialFunctionHandler.h --------------------------------*- C++ -*-===//
00002 //
00003 //                     The KLEE Symbolic Virtual Machine
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef KLEE_SPECIALFUNCTIONHANDLER_H
00011 #define KLEE_SPECIALFUNCTIONHANDLER_H
00012 
00013 #include <map>
00014 #include <vector>
00015 #include <string>
00016 
00017 namespace llvm {
00018   class Function;
00019 }
00020 
00021 namespace klee {
00022   class Executor;
00023   class Expr;
00024   class ExecutionState;
00025   class KInstruction;
00026   template<typename T> class ref;
00027   
00028   class SpecialFunctionHandler {
00029   public:
00030     typedef void (SpecialFunctionHandler::*Handler)(ExecutionState &state,
00031                                                     KInstruction *target, 
00032                                                     std::vector<ref<Expr> > 
00033                                                       &arguments);
00034     typedef std::map<const llvm::Function*, 
00035                      std::pair<Handler,bool> > handlers_ty;
00036 
00037     handlers_ty handlers;
00038     class Executor &executor;
00039 
00040   public:
00041     SpecialFunctionHandler(Executor &_executor);
00042 
00047     void prepare();
00048 
00051     void bind();
00052 
00053     bool handle(ExecutionState &state, 
00054                 llvm::Function *f,
00055                 KInstruction *target,
00056                 std::vector< ref<Expr> > &arguments);
00057 
00058     /* Convenience routines */
00059 
00060     std::string readStringAtAddress(ExecutionState &state, ref<Expr> address);
00061     
00062     /* Handlers */
00063 
00064 #define HANDLER(name) void name(ExecutionState &state, \
00065                                 KInstruction *target, \
00066                                 std::vector< ref<Expr> > &arguments)
00067     HANDLER(handleAbort);
00068     HANDLER(handleAssert);
00069     HANDLER(handleAssertFail);
00070     HANDLER(handleAssume);
00071     HANDLER(handleCalloc);
00072     HANDLER(handleCheckMemoryAccess);
00073     HANDLER(handleDefineFixedObject);
00074     HANDLER(handleDelete);    
00075     HANDLER(handleDeleteArray);
00076     HANDLER(handleExit);
00077     HANDLER(handleAliasFunction);
00078     HANDLER(handleFree);
00079     HANDLER(handleGetErrno);
00080     HANDLER(handleGetObjSize);
00081     HANDLER(handleGetValue);
00082     HANDLER(handleIsSymbolic);
00083     HANDLER(handleMakeSymbolic);
00084     HANDLER(handleMalloc);
00085     HANDLER(handleMarkGlobal);
00086     HANDLER(handleMerge);
00087     HANDLER(handleNew);
00088     HANDLER(handleNewArray);
00089     HANDLER(handlePreferCex);
00090     HANDLER(handlePrintExpr);
00091     HANDLER(handlePrintRange);
00092     HANDLER(handleRange);
00093     HANDLER(handleRealloc);
00094     HANDLER(handleReportError);
00095     HANDLER(handleRevirtObjects);
00096     HANDLER(handleSetForking);
00097     HANDLER(handleSilentExit);
00098     HANDLER(handleUnderConstrained);
00099     HANDLER(handleWarning);
00100     HANDLER(handleWarningOnce);
00101 #undef HANDLER
00102   };
00103 } // End klee namespace
00104 
00105 #endif

Generated on Fri Jun 5 03:31:32 2009 for klee by  doxygen 1.5.8