[PATCH] D27924: [libFuzzer] Diff 29 - Separate implementations of GetPeakRSSMb() for diff platforms.
Marcos Pividori via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 19 09:03:53 PST 2016
mpividori created this revision.
mpividori added reviewers: kcc, zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.
As far as I understand, the goal is to have only one file for afl_driver and make it self contained, even if we are repeating code from libFuzzer.
Taking that into account, I include the following modifications using macros inside afl_driver, to support different platforms.
As this code is the same than for libFuzzer, I would strongly prefer to develop a common static library: "FuzzerSupport", including all the IO and Utils functionalities. Then we could link against that library for libFuzzer and for the afl_driver.
I would like to know your opinion on this.
It would be very simple to add a cmake dependency: "target_link(AFLDriver FuzzerSupport)"
Also, I would like to update the code to remove the flags: LIBFUZZER_POSIX, LIBFUZZER_WINDOWS, etc. and move that logic to the cmake files.
Thanks
Repository:
rL LLVM
https://reviews.llvm.org/D27924
Files:
lib/Fuzzer/afl/afl_driver.cpp
Index: lib/Fuzzer/afl/afl_driver.cpp
===================================================================
--- lib/Fuzzer/afl/afl_driver.cpp
+++ lib/Fuzzer/afl/afl_driver.cpp
@@ -120,6 +120,7 @@
"slowest_unit_time_sec : %u\n";
// Copied from FuzzerUtil.cpp.
+#if LIBFUZZER_POSIX
size_t GetPeakRSSMb() {
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage))
@@ -134,6 +135,14 @@
assert(0 && "GetPeakRSSMb() is not implemented for your platform");
return 0;
}
+#elif LIBFUZZER_WINDOWS
+size_t GetPeakRSSMb() {
+ PROCESS_MEMORY_COUNTERS info;
+ if (!GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)))
+ return 0;
+ return info.PeakWorkingSetSize >> 20;
+}
+#endif
// Based on SetSigaction in FuzzerUtil.cpp
static void SetSigaction(int signum,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27924.81960.patch
Type: text/x-patch
Size: 829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161219/ee29684c/attachment.bin>
More information about the llvm-commits
mailing list