2016-04-22 05:32:25 +08:00
|
|
|
//===-- esan.cpp ----------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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 file (entry points) for the Esan run-time.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "esan.h"
|
2016-05-21 03:26:52 +08:00
|
|
|
#include "esan_flags.h"
|
2016-04-22 05:32:25 +08:00
|
|
|
#include "esan_interface_internal.h"
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
#include "esan_shadow.h"
|
2016-05-26 01:49:00 +08:00
|
|
|
#include "cache_frag.h"
|
2016-04-22 05:32:25 +08:00
|
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
|
|
#include "sanitizer_common/sanitizer_flag_parser.h"
|
|
|
|
#include "sanitizer_common/sanitizer_flags.h"
|
2016-05-25 10:04:04 +08:00
|
|
|
#include "working_set.h"
|
2016-04-22 05:32:25 +08:00
|
|
|
|
|
|
|
// See comment below.
|
|
|
|
extern "C" {
|
|
|
|
extern void __cxa_atexit(void (*function)(void));
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace __esan {
|
|
|
|
|
|
|
|
bool EsanIsInitialized;
|
2016-06-04 06:30:10 +08:00
|
|
|
bool EsanDuringInit;
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
ShadowMapping Mapping;
|
2016-04-22 05:32:25 +08:00
|
|
|
|
2016-05-25 10:04:04 +08:00
|
|
|
// Different tools use different scales within the same shadow mapping scheme.
|
|
|
|
// The scale used here must match that used by the compiler instrumentation.
|
|
|
|
// This array is indexed by the ToolType enum.
|
|
|
|
static const uptr ShadowScale[] = {
|
|
|
|
0, // ESAN_None.
|
|
|
|
2, // ESAN_CacheFrag: 4B:1B, so 4 to 1 == >>2.
|
|
|
|
6, // ESAN_WorkingSet: 64B:1B, so 64 to 1 == >>6.
|
|
|
|
};
|
|
|
|
|
2016-04-22 05:32:25 +08:00
|
|
|
// We are combining multiple performance tuning tools under the umbrella of
|
|
|
|
// one EfficiencySanitizer super-tool. Most of our tools have very similar
|
|
|
|
// memory access instrumentation, shadow memory mapping, libc interception,
|
|
|
|
// etc., and there is typically more shared code than distinct code.
|
|
|
|
//
|
|
|
|
// We are not willing to dispatch on tool dynamically in our fastpath
|
|
|
|
// instrumentation: thus, which tool to use is a static option selected
|
|
|
|
// at compile time and passed to __esan_init().
|
|
|
|
//
|
|
|
|
// We are willing to pay the overhead of tool dispatch in the slowpath to more
|
|
|
|
// easily share code. We expect to only come here rarely.
|
|
|
|
// If this becomes a performance hit, we can add separate interface
|
|
|
|
// routines for each subtool (e.g., __esan_cache_frag_aligned_load_4).
|
|
|
|
// But for libc interceptors, we'll have to do one of the following:
|
|
|
|
// A) Add multiple-include support to sanitizer_common_interceptors.inc,
|
|
|
|
// instantiate it separately for each tool, and call the selected
|
|
|
|
// tool's intercept setup code.
|
|
|
|
// B) Build separate static runtime libraries, one for each tool.
|
|
|
|
// C) Completely split the tools into separate sanitizers.
|
|
|
|
|
|
|
|
void processRangeAccess(uptr PC, uptr Addr, int Size, bool IsWrite) {
|
|
|
|
VPrintf(3, "in esan::%s %p: %c %p %d\n", __FUNCTION__, PC,
|
|
|
|
IsWrite ? 'w' : 'r', Addr, Size);
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
2016-04-22 05:32:25 +08:00
|
|
|
// TODO(bruening): add shadow mapping and update shadow bits here.
|
|
|
|
// We'll move this to cache_frag.cpp once we have something.
|
2016-06-04 03:40:08 +08:00
|
|
|
} else if (__esan_which_tool == ESAN_WorkingSet) {
|
2016-05-25 10:04:04 +08:00
|
|
|
processRangeAccessWorkingSet(PC, Addr, Size, IsWrite);
|
2016-04-22 05:32:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-31 21:21:03 +08:00
|
|
|
bool processSignal(int SigNum, void (*Handler)(int), void (**Result)(int)) {
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_WorkingSet)
|
2016-05-31 21:21:03 +08:00
|
|
|
return processWorkingSetSignal(SigNum, Handler, Result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool processSigaction(int SigNum, const void *Act, void *OldAct) {
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_WorkingSet)
|
2016-05-31 21:21:03 +08:00
|
|
|
return processWorkingSetSigaction(SigNum, Act, OldAct);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-07 05:04:48 +08:00
|
|
|
bool processSigprocmask(int How, void *Set, void *OldSet) {
|
|
|
|
if (__esan_which_tool == ESAN_WorkingSet)
|
|
|
|
return processWorkingSetSigprocmask(How, Set, OldSet);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
#if SANITIZER_DEBUG
|
|
|
|
static bool verifyShadowScheme() {
|
|
|
|
// Sanity checks for our shadow mapping scheme.
|
2016-05-21 03:19:06 +08:00
|
|
|
uptr AppStart, AppEnd;
|
|
|
|
if (Verbosity() >= 3) {
|
|
|
|
for (int i = 0; getAppRegion(i, &AppStart, &AppEnd); ++i) {
|
|
|
|
VPrintf(3, "App #%d: [%zx-%zx) (%zuGB)\n", i, AppStart, AppEnd,
|
|
|
|
(AppEnd - AppStart) >> 30);
|
|
|
|
}
|
|
|
|
}
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
for (int Scale = 0; Scale < 8; ++Scale) {
|
|
|
|
Mapping.initialize(Scale);
|
2016-05-21 03:19:06 +08:00
|
|
|
if (Verbosity() >= 3) {
|
|
|
|
VPrintf(3, "\nChecking scale %d\n", Scale);
|
|
|
|
uptr ShadowStart, ShadowEnd;
|
|
|
|
for (int i = 0; getShadowRegion(i, &ShadowStart, &ShadowEnd); ++i) {
|
|
|
|
VPrintf(3, "Shadow #%d: [%zx-%zx) (%zuGB)\n", i, ShadowStart,
|
|
|
|
ShadowEnd, (ShadowEnd - ShadowStart) >> 30);
|
|
|
|
}
|
|
|
|
for (int i = 0; getShadowRegion(i, &ShadowStart, &ShadowEnd); ++i) {
|
|
|
|
VPrintf(3, "Shadow(Shadow) #%d: [%zx-%zx)\n", i,
|
|
|
|
appToShadow(ShadowStart), appToShadow(ShadowEnd - 1)+1);
|
|
|
|
}
|
|
|
|
}
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
for (int i = 0; getAppRegion(i, &AppStart, &AppEnd); ++i) {
|
|
|
|
DCHECK(isAppMem(AppStart));
|
|
|
|
DCHECK(!isAppMem(AppStart - 1));
|
|
|
|
DCHECK(isAppMem(AppEnd - 1));
|
|
|
|
DCHECK(!isAppMem(AppEnd));
|
|
|
|
DCHECK(!isShadowMem(AppStart));
|
|
|
|
DCHECK(!isShadowMem(AppEnd - 1));
|
|
|
|
DCHECK(isShadowMem(appToShadow(AppStart)));
|
|
|
|
DCHECK(isShadowMem(appToShadow(AppEnd - 1)));
|
|
|
|
// Double-shadow checks.
|
|
|
|
DCHECK(!isShadowMem(appToShadow(appToShadow(AppStart))));
|
|
|
|
DCHECK(!isShadowMem(appToShadow(appToShadow(AppEnd - 1))));
|
|
|
|
}
|
|
|
|
// Ensure no shadow regions overlap each other.
|
|
|
|
uptr ShadowAStart, ShadowBStart, ShadowAEnd, ShadowBEnd;
|
|
|
|
for (int i = 0; getShadowRegion(i, &ShadowAStart, &ShadowAEnd); ++i) {
|
|
|
|
for (int j = 0; getShadowRegion(j, &ShadowBStart, &ShadowBEnd); ++j) {
|
|
|
|
DCHECK(i == j || ShadowAStart >= ShadowBEnd ||
|
|
|
|
ShadowAEnd <= ShadowBStart);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-10-06 17:58:11 +08:00
|
|
|
uptr VmaSize;
|
|
|
|
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
static void initializeShadow() {
|
2016-05-28 08:25:16 +08:00
|
|
|
verifyAddressSpace();
|
|
|
|
|
2016-10-06 17:58:11 +08:00
|
|
|
// This is based on the assumption that the intial stack is always allocated
|
|
|
|
// in the topmost segment of the user address space and the assumption
|
|
|
|
// holds true on all the platforms currently supported.
|
|
|
|
VmaSize =
|
|
|
|
(MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1);
|
|
|
|
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
DCHECK(verifyShadowScheme());
|
|
|
|
|
2016-06-04 03:40:08 +08:00
|
|
|
Mapping.initialize(ShadowScale[__esan_which_tool]);
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
|
|
|
|
VPrintf(1, "Shadow scale=%d offset=%p\n", Mapping.Scale, Mapping.Offset);
|
|
|
|
|
|
|
|
uptr ShadowStart, ShadowEnd;
|
|
|
|
for (int i = 0; getShadowRegion(i, &ShadowStart, &ShadowEnd); ++i) {
|
|
|
|
VPrintf(1, "Shadow #%d: [%zx-%zx) (%zuGB)\n", i, ShadowStart, ShadowEnd,
|
|
|
|
(ShadowEnd - ShadowStart) >> 30);
|
|
|
|
|
2016-05-31 21:41:07 +08:00
|
|
|
uptr Map;
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_WorkingSet) {
|
2016-05-31 21:41:07 +08:00
|
|
|
// We want to identify all shadow pages that are touched so we start
|
|
|
|
// out inaccessible.
|
|
|
|
Map = (uptr)MmapFixedNoAccess(ShadowStart, ShadowEnd- ShadowStart,
|
|
|
|
"shadow");
|
|
|
|
} else {
|
|
|
|
Map = (uptr)MmapFixedNoReserve(ShadowStart, ShadowEnd - ShadowStart,
|
|
|
|
"shadow");
|
|
|
|
}
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
if (Map != ShadowStart) {
|
|
|
|
Printf("FATAL: EfficiencySanitizer failed to map its shadow memory.\n");
|
|
|
|
Die();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (common_flags()->no_huge_pages_for_shadow)
|
|
|
|
NoHugePagesInRegion(ShadowStart, ShadowEnd - ShadowStart);
|
|
|
|
if (common_flags()->use_madv_dontdump)
|
|
|
|
DontDumpShadowMemory(ShadowStart, ShadowEnd - ShadowStart);
|
|
|
|
|
|
|
|
// TODO: Call MmapNoAccess() on in-between regions.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-22 05:32:25 +08:00
|
|
|
void initializeLibrary(ToolType Tool) {
|
2016-06-04 06:30:10 +08:00
|
|
|
// We assume there is only one thread during init, but we need to
|
|
|
|
// guard against double-init when we're (re-)called from an
|
|
|
|
// early interceptor.
|
|
|
|
if (EsanIsInitialized || EsanDuringInit)
|
2016-04-22 05:32:25 +08:00
|
|
|
return;
|
2016-06-04 06:30:10 +08:00
|
|
|
EsanDuringInit = true;
|
|
|
|
CHECK(Tool == __esan_which_tool);
|
2016-04-22 05:32:25 +08:00
|
|
|
SanitizerToolName = "EfficiencySanitizer";
|
2016-06-03 04:50:30 +08:00
|
|
|
CacheBinaryName();
|
2016-04-22 05:32:25 +08:00
|
|
|
initializeFlags();
|
|
|
|
|
|
|
|
// Intercepting libc _exit or exit via COMMON_INTERCEPTOR_ON_EXIT only
|
|
|
|
// finalizes on an explicit exit call by the app. To handle a normal
|
|
|
|
// exit we register an atexit handler.
|
|
|
|
::__cxa_atexit((void (*)())finalizeLibrary);
|
|
|
|
|
|
|
|
VPrintf(1, "in esan::%s\n", __FUNCTION__);
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool <= ESAN_None || __esan_which_tool >= ESAN_Max) {
|
|
|
|
Printf("ERROR: unknown tool %d requested\n", __esan_which_tool);
|
2016-04-22 05:32:25 +08:00
|
|
|
Die();
|
|
|
|
}
|
|
|
|
|
[esan] EfficiencySanitizer shadow memory
Summary:
Adds shadow memory mapping support common to all tools to the new
Efficiencysanitizer ("esan") family of tools. This includes:
+ Shadow memory layout and mapping support for 64-bit Linux for any
power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that
shadow(shadow(address)) does not overlap shadow or application
memory.
+ Mmap interception to ensure the application does not map on top of
our shadow memory.
+ Init-time sanity checks for shadow regions.
+ A test of the mmap conflict mechanism.
Reviewers: aizatsky, filcab
Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin
Differential Revision: http://reviews.llvm.org/D19921
llvm-svn: 269198
2016-05-11 23:47:54 +08:00
|
|
|
initializeShadow();
|
[sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors. The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.
Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up. This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.
Adds a test that emulates an instrumented allocator.
Reviewers: aizatsky
Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka
Differential Revision: http://reviews.llvm.org/D21083
llvm-svn: 272676
2016-06-14 23:15:38 +08:00
|
|
|
if (__esan_which_tool == ESAN_WorkingSet)
|
|
|
|
initializeShadowWorkingSet();
|
|
|
|
|
2016-04-24 00:41:24 +08:00
|
|
|
initializeInterceptors();
|
|
|
|
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
2016-05-26 01:49:00 +08:00
|
|
|
initializeCacheFrag();
|
2016-06-04 03:40:08 +08:00
|
|
|
} else if (__esan_which_tool == ESAN_WorkingSet) {
|
2016-05-25 10:04:04 +08:00
|
|
|
initializeWorkingSet();
|
|
|
|
}
|
|
|
|
|
2016-04-22 05:32:25 +08:00
|
|
|
EsanIsInitialized = true;
|
2016-06-04 06:30:10 +08:00
|
|
|
EsanDuringInit = false;
|
2016-04-22 05:32:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int finalizeLibrary() {
|
|
|
|
VPrintf(1, "in esan::%s\n", __FUNCTION__);
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
2016-05-26 01:49:00 +08:00
|
|
|
return finalizeCacheFrag();
|
2016-06-04 03:40:08 +08:00
|
|
|
} else if (__esan_which_tool == ESAN_WorkingSet) {
|
2016-05-25 10:04:04 +08:00
|
|
|
return finalizeWorkingSet();
|
2016-04-22 05:32:25 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-09 12:13:25 +08:00
|
|
|
void reportResults() {
|
|
|
|
VPrintf(1, "in esan::%s\n", __FUNCTION__);
|
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
|
|
|
return reportCacheFrag();
|
|
|
|
} else if (__esan_which_tool == ESAN_WorkingSet) {
|
|
|
|
return reportWorkingSet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-25 06:22:20 +08:00
|
|
|
void processCompilationUnitInit(void *Ptr) {
|
|
|
|
VPrintf(2, "in esan::%s\n", __FUNCTION__);
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
2016-06-01 05:27:39 +08:00
|
|
|
DCHECK(Ptr != nullptr);
|
2016-05-26 01:49:00 +08:00
|
|
|
processCacheFragCompilationUnitInit(Ptr);
|
2016-06-01 05:27:39 +08:00
|
|
|
} else {
|
|
|
|
DCHECK(Ptr == nullptr);
|
2016-05-26 01:49:00 +08:00
|
|
|
}
|
2016-05-25 06:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is called when the containing module is unloaded.
|
|
|
|
// For the main executable module, this is called after finalizeLibrary.
|
|
|
|
void processCompilationUnitExit(void *Ptr) {
|
|
|
|
VPrintf(2, "in esan::%s\n", __FUNCTION__);
|
2016-06-04 03:40:08 +08:00
|
|
|
if (__esan_which_tool == ESAN_CacheFrag) {
|
2016-06-01 05:27:39 +08:00
|
|
|
DCHECK(Ptr != nullptr);
|
2016-05-26 01:49:00 +08:00
|
|
|
processCacheFragCompilationUnitExit(Ptr);
|
2016-06-01 05:27:39 +08:00
|
|
|
} else {
|
|
|
|
DCHECK(Ptr == nullptr);
|
2016-05-26 01:49:00 +08:00
|
|
|
}
|
2016-05-25 06:22:20 +08:00
|
|
|
}
|
|
|
|
|
2016-07-19 13:06:48 +08:00
|
|
|
unsigned int getSampleCount() {
|
|
|
|
VPrintf(1, "in esan::%s\n", __FUNCTION__);
|
|
|
|
if (__esan_which_tool == ESAN_WorkingSet) {
|
|
|
|
return getSampleCountWorkingSet();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-22 05:32:25 +08:00
|
|
|
} // namespace __esan
|