klee.h

Go to the documentation of this file.
00001 //===-- klee.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_H__
00011 #define __KLEE_H__
00012 
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016   
00017   /* Add an accesible memory object at a user specified location. It
00018      is the users responsibility to make sure that these memory
00019      objects do not overlap. These memory objects will also
00020      (obviously) not correctly interact with external function
00021      calls. */
00022   void klee_define_fixed_object(void *addr, unsigned nbytes);
00023 
00032   void klee_make_symbolic(void *addr, unsigned nbytes, const char *name);
00033 
00039   int klee_range(int begin, int end, const char *name);
00040 
00045   int klee_int(const char *name);
00046 
00049   __attribute__((noreturn))
00050   void klee_silent_exit(int status);
00051 
00053   __attribute__((noreturn))
00054   void klee_abort(void);  
00055 
00063   __attribute__((noreturn))
00064   void klee_report_error(const char *file, 
00065                          int line, 
00066                          const char *message, 
00067                          const char *suffix);
00068   
00069   /* called by checking code to get size of memory. */
00070   unsigned klee_get_obj_size(void *ptr);
00071   
00072   /* print the tree associated w/ a given expression. */
00073   void klee_print_expr(const char *msg, ...);
00074   
00075   /* NB: this *does not* fork n times and return [0,n) in children.
00076    * It makes n be symbolic and returns: caller must compare N times.
00077    */
00078   unsigned klee_choose(unsigned n);
00079   
00080   /* special klee assert macro. this assert should be used when path consistency
00081    * across platforms is desired (e.g., in tests).
00082    * NB: __assert_fail is a klee "special" function
00083    */
00084 # define klee_assert(expr)                                              \
00085   ((expr)                                                               \
00086    ? (void) (0)                                                         \
00087    : __assert_fail (#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))    \
00088 
00089   /* Return true if the given value is symbolic (represented by an
00090    * expression) in the current state. This is primarily for debugging
00091    * and writing tests but can also be used to enable prints in replay
00092    * mode.
00093    */
00094   unsigned klee_is_symbolic(unsigned n);
00095 
00096 
00097   /* The following intrinsics are primarily intended for internal use
00098      and may have peculiar semantics. */
00099 
00100   void klee_assume(unsigned condition);
00101   void klee_warning(const char *message);
00102   void klee_warning_once(const char *message);
00103   void klee_prefer_cex(void *object, unsigned condition);
00104   void klee_mark_global(void *object);
00105 
00106   /* Return a possible constant value for the input expression. This
00107      allows programs to forcibly concretize values on their own. */
00108   unsigned klee_get_value(unsigned expr);
00109 
00110   /* Ensure that memory in the range [address, address+size) is
00111      accessible to the program. If some byte in the range is not
00112      accessible an error will be generated and the state
00113      terminated. 
00114   
00115      The current implementation requires both address and size to be
00116      constants and that the range lie within a single object. */
00117   void klee_check_memory_access(const void *address, unsigned size);
00118 
00119   /* Enable/disable forking. */
00120   void klee_set_forking(unsigned enable);
00121 
00122   /* klee_alias_function("foo", "bar") will replace, at runtime (on
00123      the current path and all paths spawned on the current path), all
00124      calls to foo() by calls to bar().  foo() and bar() have to exist
00125      and have identical types.  Use klee_alias_function("foo", "foo")
00126      to undo.  Be aware that some special functions, such as exit(),
00127      may not always work. */
00128   void klee_alias_function(const char* fn_name, const char* new_fn_name);
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 
00134 #endif /* __KLEE_H__ */

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