[Lldb-commits] [lldb] c62a9f1 - [lldb] Improve assert in GDBRemoteCommunicationReplayServer

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 7 12:44:05 PST 2019


Author: Jonas Devlieghere
Date: 2019-11-07T12:43:59-08:00
New Revision: c62a9f180c26e2fed012531caa581f0d736bfed9

URL: https://github.com/llvm/llvm-project/commit/c62a9f180c26e2fed012531caa581f0d736bfed9
DIFF: https://github.com/llvm/llvm-project/commit/c62a9f180c26e2fed012531caa581f0d736bfed9.diff

LOG: [lldb] Improve assert in GDBRemoteCommunicationReplayServer

While investigating an issue where a different packet was sent during
replay I noticed how annoying it is that the existing assert doesn't
specify what packet is actually different. It's printed to the log, but
enabling logging has the potential to change LLDB's behavior. The same
is true when debugging LLDB while it's replaying the reproducer.

I replaced the assert with a printf of the unexpected packet followed by
a fatal_error wrapped in ifndef NDEBUG. The behavior is the same as the
previous assert, just with more/better context.

Added: 
    

Modified: 
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
index 2d26c550dc76..3a01df0fc82a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
@@ -143,7 +143,14 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
                  entry.packet.data);
         LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'",
                  packet.GetStringRef());
-        assert(false && "Encountered unexpected packet during replay");
+#ifndef NDEBUG
+        // This behaves like a regular assert, but prints the expected and
+        // received packet before aborting.
+        printf("Reproducer expected packet: '%s'\n", entry.packet.data.c_str());
+        printf("Reproducer received packet: '%s'\n",
+               packet.GetStringRef().data());
+        llvm::report_fatal_error("Encountered unexpected packet during replay");
+#endif
         return PacketResult::ErrorSendFailed;
       }
 


        


More information about the lldb-commits mailing list