From af4a0a2007a735733ca4de06eb29b46ac37130fc Mon Sep 17 00:00:00 2001 From: Alex Groce Date: Sun, 6 Jan 2019 14:56:20 -0700 Subject: [PATCH] Add a loud mode for debugging libFuzzer on mac OS --- src/lib/DeepState.c | 9 +++++++++ src/lib/Log.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index 751ef11..8bc23fe 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -56,6 +56,9 @@ int DeepState_UsingSymExec = 0; /* Set to 1 when we're using libFuzzer. */ int DeepState_UsingLibFuzzer = 0; +/* To make libFuzzer louder on mac OS. */ +int DeepState_LibFuzzerLoud = 1; + /* Array of DeepState generated strings. Impossible for there to * be more than there are input bytes. Index stores where we are. */ char* DeepState_GeneratedStrings[DeepState_InputSize]; @@ -841,6 +844,12 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { } DeepState_UsingLibFuzzer = 1; + + const char* loud = getenv("LIBFUZZER_LOUD"); + if (loud != NULL) { + FLAGS_log_level = 0; + DeepState_LibFuzzerLoud = 1; + } struct DeepState_TestInfo *test = NULL; diff --git a/src/lib/Log.c b/src/lib/Log.c index 78fe32f..b6d7016 100644 --- a/src/lib/Log.c +++ b/src/lib/Log.c @@ -69,13 +69,14 @@ enum { }; extern int DeepState_UsingLibFuzzer; +extern int DeepState_LibFuzzerLoud; char DeepState_LogBuf[DeepState_LogBufSize + 1] = {}; /* Log a C string. */ DEEPSTATE_NOINLINE void DeepState_Log(enum DeepState_LogLevel level, const char *str) { - if ((DeepState_UsingLibFuzzer && (level < DeepState_LogExternal)) || + if ((DeepState_UsingLibFuzzer && !DeepState_LibFuzzerLoud && (level < DeepState_LogExternal)) || (level < FLAGS_log_level)) { return; }