Skip to content

Commit

Permalink
add -log_file option to fuzzers
Browse files Browse the repository at this point in the history
  • Loading branch information
yakov-olkhovskiy committed Sep 25, 2024
1 parent 2aedf75 commit c096b67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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")

0 comments on commit c096b67

Please sign in to comment.