Add more debug logs that were useful during interop

gfe-relnote: n/a, debug-only logs
PiperOrigin-RevId: 249631003
Change-Id: Ib510bca1f4f1cb010e6449849d326d0a20df834d
diff --git a/quic/core/crypto/crypto_utils.cc b/quic/core/crypto/crypto_utils.cc
index 57edda0..be12ad4 100644
--- a/quic/core/crypto/crypto_utils.cc
+++ b/quic/core/crypto/crypto_utils.cc
@@ -101,6 +101,10 @@
                                            QuicTransportVersion version,
                                            QuicConnectionId connection_id,
                                            CrypterPair* crypters) {
+  QUIC_DLOG(INFO) << "Creating "
+                  << (perspective == Perspective::IS_CLIENT ? "client"
+                                                            : "server")
+                  << " TLS crypters for " << connection_id;
   QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(connection_id, version))
       << "CreateTlsInitialCrypters: attempted to use connection ID "
       << connection_id << " which is invalid with version "
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 4e93fdf..db717b0 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -1809,10 +1809,15 @@
   QUIC_DLOG(INFO) << ENDPOINT << "Sending version negotiation packet: {"
                   << ParsedQuicVersionVectorToString(
                          framer_.supported_versions())
-                  << "}, ietf_quic: " << ietf_quic;
+                  << "}, " << (ietf_quic ? "" : "!") << "ietf_quic";
   std::unique_ptr<QuicEncryptedPacket> version_packet(
       packet_generator_.SerializeVersionNegotiationPacket(
           ietf_quic, framer_.supported_versions()));
+  QUIC_DVLOG(2) << ENDPOINT << "Sending version negotiation packet: {"
+                << ParsedQuicVersionVectorToString(framer_.supported_versions())
+                << "}, " << (ietf_quic ? "" : "!") << "ietf_quic:" << std::endl
+                << QuicTextUtils::HexDump(QuicStringPiece(
+                       version_packet->data(), version_packet->length()));
   WriteResult result = writer_->WritePacket(
       version_packet->data(), version_packet->length(), self_address().host(),
       peer_address(), per_packet_options_);
@@ -3652,6 +3657,12 @@
   DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA);
 
   const QuicTime packet_send_time = clock_->Now();
+  QUIC_DVLOG(2) << ENDPOINT
+                << "Sending path probe packet for server connection ID "
+                << server_connection_id_ << std::endl
+                << QuicTextUtils::HexDump(
+                       QuicStringPiece(probing_packet->encrypted_buffer,
+                                       probing_packet->encrypted_length));
   WriteResult result = probing_writer->WritePacket(
       probing_packet->encrypted_buffer, probing_packet->encrypted_length,
       self_address().host(), peer_address, per_packet_options_);
@@ -4044,7 +4055,9 @@
   }
   if (sent_packet_manager_.handshake_confirmed()) {
     // A forward secure packet has been received.
-    QUIC_BUG_IF(encryption_level_ != ENCRYPTION_FORWARD_SECURE);
+    QUIC_BUG_IF(encryption_level_ != ENCRYPTION_FORWARD_SECURE)
+        << ENDPOINT << "Unexpected connection close encryption level "
+        << QuicUtils::EncryptionLevelToString(encryption_level_);
     return ENCRYPTION_FORWARD_SECURE;
   }
   if (framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_ZERO_RTT)) {
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 049a63f..0833a27 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -22,6 +22,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
 
 namespace quic {
 
@@ -331,6 +332,10 @@
 void QuicDispatcher::ProcessPacket(const QuicSocketAddress& self_address,
                                    const QuicSocketAddress& peer_address,
                                    const QuicReceivedPacket& packet) {
+  QUIC_DVLOG(2) << "Dispatcher received encrypted " << packet.length()
+                << " bytes:" << std::endl
+                << QuicTextUtils::HexDump(
+                       QuicStringPiece(packet.data(), packet.length()));
   current_self_address_ = self_address;
   current_peer_address_ = peer_address;
   // GetClientAddress must be called after current_peer_address_ is set.
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index eff8f49..6ebdc78 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -4432,8 +4432,7 @@
   }
 
   if (!success) {
-    QUIC_DVLOG(1) << ENDPOINT << "DecryptPacket failed for packet_number:"
-                  << header.packet_number;
+    QUIC_DVLOG(1) << ENDPOINT << "DecryptPacket failed for: " << header;
     return false;
   }
 
diff --git a/quic/core/quic_time_wait_list_manager.cc b/quic/core/quic_time_wait_list_manager.cc
index fa62fc5..56cd70a 100644
--- a/quic/core/quic_time_wait_list_manager.cc
+++ b/quic/core/quic_time_wait_list_manager.cc
@@ -22,6 +22,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h"
 
 namespace quic {
 
@@ -206,10 +207,16 @@
     const QuicSocketAddress& self_address,
     const QuicSocketAddress& peer_address,
     std::unique_ptr<QuicPerPacketContext> packet_context) {
-  SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(
-                        self_address, peer_address,
-                        QuicFramer::BuildVersionNegotiationPacket(
-                            connection_id, ietf_quic, supported_versions)),
+  std::unique_ptr<QuicEncryptedPacket> version_packet =
+      QuicFramer::BuildVersionNegotiationPacket(connection_id, ietf_quic,
+                                                supported_versions);
+  QUIC_DVLOG(2) << "Dispatcher sending version negotiation packet: {"
+                << ParsedQuicVersionVectorToString(supported_versions) << "}, "
+                << (ietf_quic ? "" : "!") << "ietf_quic:" << std::endl
+                << QuicTextUtils::HexDump(QuicStringPiece(
+                       version_packet->data(), version_packet->length()));
+  SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(self_address, peer_address,
+                                                 std::move(version_packet)),
                     packet_context.get());
 }
 
@@ -226,10 +233,17 @@
     bool ietf_quic,
     std::unique_ptr<QuicPerPacketContext> packet_context) {
   if (ietf_quic) {
-    SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(
-                          self_address, peer_address,
-                          BuildIetfStatelessResetPacket(connection_id)),
-                      packet_context.get());
+    std::unique_ptr<QuicEncryptedPacket> ietf_reset_packet =
+        BuildIetfStatelessResetPacket(connection_id);
+    QUIC_DVLOG(2) << "Dispatcher sending IETF reset packet for "
+                  << connection_id << std::endl
+                  << QuicTextUtils::HexDump(
+                         QuicStringPiece(ietf_reset_packet->data(),
+                                         ietf_reset_packet->length()));
+    SendOrQueuePacket(
+        QuicMakeUnique<QueuedPacket>(self_address, peer_address,
+                                     std::move(ietf_reset_packet)),
+        packet_context.get());
     return;
   }
   QuicPublicResetPacket packet;
@@ -240,8 +254,13 @@
   packet.client_address = peer_address;
   GetEndpointId(&packet.endpoint_id);
   // Takes ownership of the packet.
+  std::unique_ptr<QuicEncryptedPacket> reset_packet = BuildPublicReset(packet);
+  QUIC_DVLOG(2) << "Dispatcher sending reset packet for " << connection_id
+                << std::endl
+                << QuicTextUtils::HexDump(QuicStringPiece(
+                       reset_packet->data(), reset_packet->length()));
   SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(self_address, peer_address,
-                                                 BuildPublicReset(packet)),
+                                                 std::move(reset_packet)),
                     packet_context.get());
 }