2016-04-22 05:32:25 +08:00
|
|
|
//===-- esan.h --------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of EfficiencySanitizer, a family of performance tuners.
|
|
|
|
//
|
|
|
|
// Main internal esan header file.
|
|
|
|
//
|
|
|
|
// Ground rules:
|
|
|
|
// - C++ run-time should not be used (static CTORs, RTTI, exceptions, static
|
|
|
|
// function-scope locals)
|
|
|
|
// - All functions/classes/etc reside in namespace __esan, except for those
|
|
|
|
// declared in esan_interface_internal.h.
|
|
|
|
// - Platform-specific files should be used instead of ifdefs (*).
|
|
|
|
// - No system headers included in header files (*).
|
|
|
|
// - Platform specific headers included only into platform-specific files (*).
|
|
|
|
//
|
|
|
|
// (*) Except when inlining is critical for performance.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ESAN_H
|
|
|
|
#define ESAN_H
|
|
|
|
|
2016-05-28 08:25:16 +08:00
|
|
|
#include "interception/interception.h"
|
2016-04-22 05:32:25 +08:00
|
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
|
|
#include "esan_interface_internal.h"
|
|
|
|
|
|
|
|
namespace __esan {
|
|
|
|
|
|
|
|
extern bool EsanIsInitialized;
|
2016-06-04 06:30:10 +08:00
|
|
|
extern bool EsanDuringInit;
|
2016-10-06 17:58:11 +08:00
|
|
|
extern uptr VmaSize;
|
2016-04-22 05:32:25 +08:00
|
|
|
|
|
|
|
void initializeLibrary(ToolType Tool);
|
|
|
|
int finalizeLibrary();
|
2016-07-09 12:13:25 +08:00
|
|
|
void reportResults();
|
2016-07-19 13:06:48 +08:00
|
|
|
unsigned int getSampleCount();
|
2016-05-25 06:22:20 +08:00
|
|
|
// Esan creates the variable per tool per compilation unit at compile time
|
|
|
|
// and passes its pointer Ptr to the runtime library.
|
|
|
|
void processCompilationUnitInit(void *Ptr);
|
|
|
|
void processCompilationUnitExit(void *Ptr);
|
2016-04-22 05:32:25 +08:00
|
|
|
void processRangeAccess(uptr PC, uptr Addr, int Size, bool IsWrite);
|
2016-04-24 00:41:24 +08:00
|
|
|
void initializeInterceptors();
|
2016-04-22 05:32:25 +08:00
|
|
|
|
2016-05-28 08:25:16 +08:00
|
|
|
// Platform-dependent routines.
|
|
|
|
void verifyAddressSpace();
|
|
|
|
bool fixMmapAddr(void **Addr, SIZE_T Size, int Flags);
|
|
|
|
uptr checkMmapResult(uptr Addr, SIZE_T Size);
|
2016-05-31 21:21:03 +08:00
|
|
|
// The return value indicates whether to call the real version or not.
|
|
|
|
bool processSignal(int SigNum, void (*Handler)(int), void (**Result)(int));
|
|
|
|
bool processSigaction(int SigNum, const void *Act, void *OldAct);
|
2016-07-07 05:04:48 +08:00
|
|
|
bool processSigprocmask(int How, void *Set, void *OldSet);
|
2016-05-28 08:25:16 +08:00
|
|
|
|
2016-04-22 05:32:25 +08:00
|
|
|
} // namespace __esan
|
|
|
|
|
|
|
|
#endif // ESAN_H
|