Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,17 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
return 0;
}

std::unique_ptr<FILE, int(*)(FILE*)> log_file(0, &fclose);
if (Flags.log_file) {
FILE * f = fopen(Flags.log_file, "w");
if (!f) {
Printf("ERROR: unable to open log_file [%s]: %s\n", Flags.log_file, strerror(errno));
return 1;
}
log_file.reset(f);
SetOutputFile(f);
}

if (Flags.close_fd_mask & 2)
DupAndCloseStderr();
if (Flags.close_fd_mask & 1)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/fuzzer/FuzzerFlags.def
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ FUZZER_FLAG_STRING(collect_data_flow,
FUZZER_FLAG_INT(create_missing_dirs, 0, "Automatically attempt to create "
"directories for arguments that would normally expect them to already "
"exist (i.e. artifact_prefix, exact_artifact_path, features_dir, corpus)")
FUZZER_FLAG_STRING(log_file, "Output file for fuzzer, default is stderr")