From c1cf2a18d07ad2b5be52dece92b35a24a00287bd Mon Sep 17 00:00:00 2001 From: Sergey Shevchenko Date: Tue, 4 Apr 2023 13:47:54 -0700 Subject: [PATCH] Replace a few noisy/secondary/rarely useful LOGs with VLOGs Abseil hasn't open-sourced VLOGs: we may roll out our own polyfill. PiperOrigin-RevId: 521855604 --- centipede.cc | 22 ++++++++++++---------- control_flow.cc | 6 +++--- testing/centipede_test.cc | 8 ++++---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/centipede.cc b/centipede.cc index 6dc29b0..d232141 100644 --- a/centipede.cc +++ b/centipede.cc @@ -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; @@ -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. @@ -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); diff --git a/control_flow.cc b/control_flow.cc index eaba78d..f80543b 100644 --- a/control_flow.cc +++ b/control_flow.cc @@ -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; @@ -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 { diff --git a/testing/centipede_test.cc b/testing/centipede_test.cc index b15f215..3e6cc27 100644 --- a/testing/centipede_test.cc +++ b/testing/centipede_test.cc @@ -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; @@ -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; @@ -473,7 +477,6 @@ static std::vector RunWithFunctionFilter( FunctionFilterMock mock(env); MockFactory factory(mock); CentipedeMain(env, factory); - LOG(INFO) << mock.observed_inputs_.size(); std::vector res(mock.observed_inputs_.begin(), mock.observed_inputs_.end()); std::sort(res.begin(), res.end()); @@ -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();