summaryrefslogtreecommitdiff
path: root/lib/esan
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-07-19 05:06:48 +0000
committerDerek Bruening <bruening@google.com>2016-07-19 05:06:48 +0000
commit818c1248e0128d9058e997db8a9003270fbf80c7 (patch)
tree8c0d69bc8cd201d6b9802f3def4080dc99004d99 /lib/esan
parent189001e3bc9f050781628eba7da36f90725b04ba (diff)
[esan|wset] Fix flaky sampling tests
Adds a new esan public interface routine __esan_get_sample_count() and uses it to ensure that tests of sampling receive the minimum number of samples. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/esan')
-rw-r--r--lib/esan/esan.cpp8
-rw-r--r--lib/esan/esan.h1
-rw-r--r--lib/esan/esan_interface.cpp4
-rw-r--r--lib/esan/working_set.cpp5
-rw-r--r--lib/esan/working_set.h1
5 files changed, 19 insertions, 0 deletions
diff --git a/lib/esan/esan.cpp b/lib/esan/esan.cpp
index 3c69b4e91..2fb77894d 100644
--- a/lib/esan/esan.cpp
+++ b/lib/esan/esan.cpp
@@ -259,4 +259,12 @@ void processCompilationUnitExit(void *Ptr) {
}
}
+unsigned int getSampleCount() {
+ VPrintf(1, "in esan::%s\n", __FUNCTION__);
+ if (__esan_which_tool == ESAN_WorkingSet) {
+ return getSampleCountWorkingSet();
+ }
+ return 0;
+}
+
} // namespace __esan
diff --git a/lib/esan/esan.h b/lib/esan/esan.h
index 371810d5e..5a0dde627 100644
--- a/lib/esan/esan.h
+++ b/lib/esan/esan.h
@@ -38,6 +38,7 @@ extern bool EsanDuringInit;
void initializeLibrary(ToolType Tool);
int finalizeLibrary();
void reportResults();
+unsigned int getSampleCount();
// 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);
diff --git a/lib/esan/esan_interface.cpp b/lib/esan/esan_interface.cpp
index 8a64d1526..43b3dff86 100644
--- a/lib/esan/esan_interface.cpp
+++ b/lib/esan/esan_interface.cpp
@@ -115,4 +115,8 @@ extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE void __esan_report() {
reportResults();
}
+
+SANITIZER_INTERFACE_ATTRIBUTE unsigned int __esan_get_sample_count() {
+ return getSampleCount();
+}
} // extern "C"
diff --git a/lib/esan/working_set.cpp b/lib/esan/working_set.cpp
index 3fde5a8b5..f39111993 100644
--- a/lib/esan/working_set.cpp
+++ b/lib/esan/working_set.cpp
@@ -190,6 +190,11 @@ static void takeSample(void *Arg) {
}
}
+unsigned int getSampleCountWorkingSet()
+{
+ return SnapshotNum;
+}
+
// Initialization that must be done before any instrumented code is executed.
void initializeShadowWorkingSet() {
CHECK(getFlags()->cache_line_size == CacheLineSize);
diff --git a/lib/esan/working_set.h b/lib/esan/working_set.h
index 38ff0635d..6a976c3f9 100644
--- a/lib/esan/working_set.h
+++ b/lib/esan/working_set.h
@@ -24,6 +24,7 @@ void initializeWorkingSet();
void initializeShadowWorkingSet();
int finalizeWorkingSet();
void reportWorkingSet();
+unsigned int getSampleCountWorkingSet();
void processRangeAccessWorkingSet(uptr PC, uptr Addr, SIZE_T Size,
bool IsWrite);