From 86f0d4a2b1e2632edd5fc45fcc72a4c89e4f4066 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 16 Jan 2024 16:18:18 -0800 Subject: [PATCH] Replace DebugString with absl::StrCat DebugString is going to be deprecated. --- examples/libfuzzer/libfuzzer_bin_example.cc | 2 +- examples/libfuzzer/libfuzzer_example.cc | 2 +- src/field_instance.h | 6 +++--- src/mutator.cc | 2 +- src/mutator_test.cc | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/libfuzzer/libfuzzer_bin_example.cc b/examples/libfuzzer/libfuzzer_bin_example.cc index cd31aad..0734caa 100644 --- a/examples/libfuzzer/libfuzzer_bin_example.cc +++ b/examples/libfuzzer/libfuzzer_bin_example.cc @@ -55,7 +55,7 @@ DEFINE_BINARY_PROTO_FUZZER(const libfuzzer_example::Msg& message) { !std::isnan(message.optional_float()) && std::fabs(message.optional_float()) > 1000 && message.any().UnpackTo(&file) && !file.name().empty()) { - std::cerr << message.DebugString() << "\n"; + std::cerr << absl::StrCat(message) << "\n"; abort(); } } diff --git a/examples/libfuzzer/libfuzzer_example.cc b/examples/libfuzzer/libfuzzer_example.cc index 2e6e887..37c4e6b 100644 --- a/examples/libfuzzer/libfuzzer_example.cc +++ b/examples/libfuzzer/libfuzzer_example.cc @@ -55,7 +55,7 @@ DEFINE_PROTO_FUZZER(const libfuzzer_example::Msg& message) { !std::isnan(message.optional_float()) && std::fabs(message.optional_float()) > 1000 && message.any().UnpackTo(&file) && !file.name().empty()) { - std::cerr << message.DebugString() << "\n"; + std::cerr << absl::StrCat(message) << "\n"; abort(); } } diff --git a/src/field_instance.h b/src/field_instance.h index 487996b..d5ecd84 100644 --- a/src/field_instance.h +++ b/src/field_instance.h @@ -195,9 +195,9 @@ class ConstFieldInstance { const protobuf::FieldDescriptor* descriptor() const { return descriptor_; } std::string DebugString() const { - std::string s = descriptor_->DebugString(); - if (is_repeated()) s += "[" + std::to_string(index_) + "]"; - return s + " of\n" + message_->DebugString(); + std::string s = absl::StrCat(*descriptor_); + if (is_repeated()) s += absl::StrCat("[", index_, "]"); + return s + " of\n" + absl::StrCat(*message_); } protected: diff --git a/src/mutator.cc b/src/mutator.cc index eaa7571..6977ea7 100644 --- a/src/mutator.cc +++ b/src/mutator.cc @@ -801,7 +801,7 @@ std::string Mutator::MutateUtf8String(const std::string& value, bool Mutator::IsInitialized(const Message& message) const { if (!keep_initialized_ || message.IsInitialized()) return true; - std::cerr << "Uninitialized: " << message.DebugString() << "\n"; + std::cerr << "Uninitialized: " << absl::StrCat(message) << "\n"; return false; } diff --git a/src/mutator_test.cc b/src/mutator_test.cc index 17c5542..32f4e7d 100644 --- a/src/mutator_test.cc +++ b/src/mutator_test.cc @@ -410,8 +410,8 @@ bool Mutate(const protobuf::Message& from, const protobuf::Message& to, } ADD_FAILURE() << "Failed to get from:\n" - << from.DebugString() << "\nto:\n" - << to.DebugString(); + << absl::StrCat(from) << "\nto:\n" + << absl::StrCat(to); return false; }