different approach

This commit is contained in:
Alex Groce
2018-07-28 09:11:34 -07:00
parent fcf53b25a5
commit af6c5d8eac
2 changed files with 16 additions and 11 deletions

View File

@@ -37,8 +37,9 @@ enum DeepState_LogLevel {
DeepState_LogWarning = 2,
DeepState_LogWarn = DeepState_LogWarning,
DeepState_LogError = 3,
DeepState_LogFatal = 4,
DeepState_LogCritical = DeepState_LogFatal
DeepState_LogFuzzer = 4,
DeepState_LogFatal = 5,
DeepState_LogCritical = DeepState_LogFatal,
};
/* Log a C string. */

View File

@@ -53,6 +53,8 @@ static const char *DeepState_LogLevelStr(enum DeepState_LogLevel level) {
return "WARNING";
case DeepState_LogError:
return "ERROR";
case DeepState_LogFuzzer:
return "FUZZER";
case DeepState_LogFatal:
return "FATAL";
default:
@@ -71,6 +73,9 @@ 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_LogFatal)) {
return;
}
memset(DeepState_LogBuf, 0, DeepState_LogBufSize);
snprintf(DeepState_LogBuf, DeepState_LogBufSize, "%s: %s\n",
DeepState_LogLevelStr(level), str);
@@ -165,15 +170,14 @@ int vfprintf(FILE *file, const char *format, va_list args) {
} else if (stdout == file) {
DeepState_LogVFormat(DeepState_LogInfo, format, args);
} else {
if (!DeepState_UsingLibFuzzer) {
DeepState_LogStream(DeepState_LogWarning);
DeepState_Log(DeepState_LogWarning,
"vfprintf with non-stdout/stderr stream follows:");
DeepState_LogVFormat(DeepState_LogInfo, format, args);
} else {
DeepState_LogVFormatLLVM(DeepState_LogInfo, format, args);
}
#ifndef LIBFUZZER
DeepState_LogStream(DeepState_LogWarning);
DeepState_Log(DeepState_LogWarning,
"vfprintf with non-stdout/stderr stream follows:");
DeepState_LogVFormat(DeepState_LogInfo, format, args);
#else
DeepState_LogVFormat(DeepState_LogFuzzer, format, args);
#endif
}
return 0;
}