Skip to content

Commit c62a9f1

Browse files
committed
[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.
1 parent 9611958 commit c62a9f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
143143
entry.packet.data);
144144
LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'",
145145
packet.GetStringRef());
146-
assert(false && "Encountered unexpected packet during replay");
146+
#ifndef NDEBUG
147+
// This behaves like a regular assert, but prints the expected and
148+
// received packet before aborting.
149+
printf("Reproducer expected packet: '%s'\n", entry.packet.data.c_str());
150+
printf("Reproducer received packet: '%s'\n",
151+
packet.GetStringRef().data());
152+
llvm::report_fatal_error("Encountered unexpected packet during replay");
153+
#endif
147154
return PacketResult::ErrorSendFailed;
148155
}
149156

0 commit comments

Comments
 (0)