summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerUtil.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-05-06 23:38:07 +0000
committerKostya Serebryany <kcc@google.com>2016-05-06 23:38:07 +0000
commit8b8f7a3cda6f33b19fb7880c35652e0be9d26104 (patch)
tree576c736549c4602f010fb50e518535be04f910dc /llvm/lib/Fuzzer/FuzzerUtil.cpp
parentb2e2e21b20ae00a47e931bdb66d2980453e2d717 (diff)
downloadbcm5719-llvm-8b8f7a3cda6f33b19fb7880c35652e0be9d26104.tar.gz
bcm5719-llvm-8b8f7a3cda6f33b19fb7880c35652e0be9d26104.zip
[libFuzzer] enhance -rss_limit_mb and enable by default. Now it will print the OOM reproducer.
llvm-svn: 268821
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerUtil.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerUtil.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerUtil.cpp b/llvm/lib/Fuzzer/FuzzerUtil.cpp
index d5335616a83..88b18d704c2 100644
--- a/llvm/lib/Fuzzer/FuzzerUtil.cpp
+++ b/llvm/lib/Fuzzer/FuzzerUtil.cpp
@@ -14,12 +14,16 @@
#include <iomanip>
#include <sys/resource.h>
#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
#include <cassert>
+#include <chrono>
#include <cstring>
#include <signal.h>
#include <sstream>
#include <unistd.h>
#include <errno.h>
+#include <thread>
namespace fuzzer {
@@ -214,8 +218,18 @@ bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units) {
return true;
}
-int GetPid() { return getpid(); }
+void SleepSeconds(int Seconds) {
+ std::this_thread::sleep_for(std::chrono::seconds(Seconds));
+}
+int GetPid() { return getpid(); }
+int SignalToMainThread() {
+#ifdef __linux__
+ return syscall(SYS_tgkill, GetPid(), GetPid(), SIGALRM);
+#else
+ return 0;
+#endif
+}
std::string Base64(const Unit &U) {
static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
OpenPOWER on IntegriCloud