Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Replace a few noisy/secondary/rarely useful LOGs with VLOGs
Browse files Browse the repository at this point in the history
Abseil hasn't open-sourced VLOGs: we may roll out our own polyfill.

PiperOrigin-RevId: 521855604
  • Loading branch information
ussuri authored and copybara-github committed Apr 4, 2023
1 parent 7a20b4e commit c1cf2a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
22 changes: 12 additions & 10 deletions centipede.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ int Centipede::ExportCorpusFromLocalDir(const Environment &env,
CHECK_OK(appender->Append(input));
++inputs_added;
}
LOG(INFO) << VV(shard) << VV(inputs_added) << VV(inputs_ignored)
<< VV(num_shard_bytes) << VV(shard_data.size());

VLOG(1) << "Exported: " << VV(shard) << VV(inputs_added)
<< VV(inputs_ignored) << VV(num_shard_bytes)
<< VV(shard_data.size());
}
CHECK_EQ(total_paths, inputs_added + inputs_ignored);
return 0;
Expand Down Expand Up @@ -550,9 +552,9 @@ void Centipede::MergeFromOtherCorpus(std::string_view merge_from_dir,
}

void Centipede::FuzzingLoop() {
LOG(INFO) << "Shard: " << env_.my_shard_index << "/" << env_.total_shards
<< " " << TemporaryLocalDirPath() << " "
<< "seed: " << env_.seed << "\n\n\n";
LOG(INFO) << "\n\nFuzzing: shard: " << env_.my_shard_index << "/"
<< env_.total_shards << " " << TemporaryLocalDirPath() << " "
<< "seed: " << env_.seed << "\n\n";

{
// Execute a dummy input.
Expand Down Expand Up @@ -776,16 +778,16 @@ void Centipede::ReportCrash(std::string_view binary,
auto suspect_hash = Hash(suspect_input);
auto crash_dir = env_.MakeCrashReproducerDirPath();
RemoteMkdir(crash_dir);
std::string save_dir =
std::filesystem::path(crash_dir).append("crashing_batch-").
concat(suspect_hash);
std::string save_dir = std::filesystem::path(crash_dir)
.append("crashing_batch-")
.concat(suspect_hash);
RemoteMkdir(save_dir);
LOG(INFO) << log_prefix << "Saving used inputs from batch to: " << save_dir;
for (int i = 0; i <= suspect_input_idx; ++i) {
const auto &one_input = input_vec[i];
auto hash = Hash(one_input);
std::string file_path = std::filesystem::path(save_dir)
.append(absl::StrFormat("input-%010d-%s", i, hash));
std::string file_path = std::filesystem::path(save_dir).append(
absl::StrFormat("input-%010d-%s", i, hash));
auto *file = RemoteFileOpen(file_path, "w");
CHECK(file != nullptr) << log_prefix << "Failed to open " << file_path;
RemoteFileAppend(file, one_input);
Expand Down
6 changes: 3 additions & 3 deletions control_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ PCTable GetPcTableFromBinaryWithTracePC(std::string_view binary_path,
"/dev/null");
int system_exit_code = cmd.Execute();
if (system_exit_code) {
LOG(INFO) << __func__ << " objdump failed: " << VV(system_exit_code)
<< VV(cmd.ToString());
VLOG(1) << __func__ << " objdump failed: " << VV(system_exit_code)
<< VV(cmd.ToString());
return PCTable();
}
PCTable pc_table;
Expand Down Expand Up @@ -78,7 +78,7 @@ PCTable GetPcTableFromBinary(std::string_view binary_path,
PCTable res = GetPcTableFromBinaryWithPcTable(binary_path, tmp_path);
if (res.empty()) {
// Fall back to trace-pc.
LOG(INFO) << "Fall back to GetPcTableFromBinaryWithTracePC";
VLOG(1) << "Fall back to GetPcTableFromBinaryWithTracePC";
res = GetPcTableFromBinaryWithTracePC(binary_path, tmp_path);
*uses_legacy_trace_pc_instrumentation = true;
} else {
Expand Down
8 changes: 4 additions & 4 deletions testing/centipede_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ TEST(Centipede, ShardsAndDistillTest) {
env.corpus_dir.push_back(tmp_dir.CreateSubdir("cd1"));
env.corpus_dir.push_back(tmp_dir.CreateSubdir("cd2"));

VLOG(1) << "Fuzzing";

CentipedeMock mock(env);
// First round of runs: do the actual fuzzing, compute the features.
size_t max_shard_size = 0;
Expand All @@ -187,6 +189,8 @@ TEST(Centipede, ShardsAndDistillTest) {
EXPECT_GT(CountFilesInDir(env.corpus_dir[0]), 128);
EXPECT_EQ(CountFilesInDir(env.corpus_dir[1]), 0);

VLOG(1) << "Distilling";

// Second round of runs. Don't fuzz, only distill.
// Don't distill in the last one to test the flag behaviour.
env.distill_shards = env.total_shards - 1;
Expand Down Expand Up @@ -473,7 +477,6 @@ static std::vector<ByteArray> RunWithFunctionFilter(
FunctionFilterMock mock(env);
MockFactory factory(mock);
CentipedeMain(env, factory);
LOG(INFO) << mock.observed_inputs_.size();
std::vector<ByteArray> res(mock.observed_inputs_.begin(),
mock.observed_inputs_.end());
std::sort(res.begin(), res.end());
Expand Down Expand Up @@ -653,9 +656,6 @@ TEST(Centipede, UndetectedCrashingInput) {
constexpr size_t kCrashingInputIdx =
(kNumBatches / 2) * kBatchSize + kCrashingInputIdxInBatch;

LOG(INFO) << VV(kNumBatches) << VV(kBatchSize)
<< VV(kCrashingInputIdxInBatch) VV(kCrashingInputIdx);

TempDir temp_dir{test_info_->name()};
Environment env;
env.workdir = temp_dir.path();
Expand Down

0 comments on commit c1cf2a1

Please sign in to comment.