Home | History | Annotate | Download | only in esan
      1 //===-- esan.h --------------------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file is a part of EfficiencySanitizer, a family of performance tuners.
     11 //
     12 // Main internal esan header file.
     13 //
     14 // Ground rules:
     15 //   - C++ run-time should not be used (static CTORs, RTTI, exceptions, static
     16 //     function-scope locals)
     17 //   - All functions/classes/etc reside in namespace __esan, except for those
     18 //     declared in esan_interface_internal.h.
     19 //   - Platform-specific files should be used instead of ifdefs (*).
     20 //   - No system headers included in header files (*).
     21 //   - Platform specific headers included only into platform-specific files (*).
     22 //
     23 //  (*) Except when inlining is critical for performance.
     24 //===----------------------------------------------------------------------===//
     25 
     26 #ifndef ESAN_H
     27 #define ESAN_H
     28 
     29 #include "interception/interception.h"
     30 #include "sanitizer_common/sanitizer_common.h"
     31 #include "esan_interface_internal.h"
     32 
     33 namespace __esan {
     34 
     35 extern bool EsanIsInitialized;
     36 extern bool EsanDuringInit;
     37 
     38 void initializeLibrary(ToolType Tool);
     39 int finalizeLibrary();
     40 void reportResults();
     41 // Esan creates the variable per tool per compilation unit at compile time
     42 // and passes its pointer Ptr to the runtime library.
     43 void processCompilationUnitInit(void *Ptr);
     44 void processCompilationUnitExit(void *Ptr);
     45 void processRangeAccess(uptr PC, uptr Addr, int Size, bool IsWrite);
     46 void initializeInterceptors();
     47 
     48 // Platform-dependent routines.
     49 void verifyAddressSpace();
     50 bool fixMmapAddr(void **Addr, SIZE_T Size, int Flags);
     51 uptr checkMmapResult(uptr Addr, SIZE_T Size);
     52 // The return value indicates whether to call the real version or not.
     53 bool processSignal(int SigNum, void (*Handler)(int), void (**Result)(int));
     54 bool processSigaction(int SigNum, const void *Act, void *OldAct);
     55 bool processSigprocmask(int How, void *Set, void *OldSet);
     56 
     57 } // namespace __esan
     58 
     59 #endif // ESAN_H
     60