From c4144caf9b865a2064e49afcdfff474426fc5d47 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 22 Jan 2020 16:15:06 -0800 Subject: [PATCH] [lldb/Reproducer] Disable buffering of stdout during replay Different buffering behavior during capture and replay caused some of the shell tests to fail when run from a reproducer. By disabling stdout buffering we get a better approximation of how things get flushed during an regular debug session. There is a performance impact but since this only affects replay this is acceptable. --- lldb/source/Utility/ReproducerInstrumentation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp index 473786ef4d3e..0b74acaacb7e 100644 --- a/lldb/source/Utility/ReproducerInstrumentation.cpp +++ b/lldb/source/Utility/ReproducerInstrumentation.cpp @@ -8,6 +8,7 @@ #include "lldb/Utility/ReproducerInstrumentation.h" #include "lldb/Utility/Reproducer.h" +#include using namespace lldb_private; using namespace lldb_private::repro; @@ -47,6 +48,10 @@ bool Registry::Replay(llvm::StringRef buffer) { Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); #endif + // Disable buffering stdout so that we approximate the way things get flushed + // during an interactive session. + setvbuf(stdout, nullptr, _IONBF, 0); + Deserializer deserializer(buffer); while (deserializer.HasData(1)) { unsigned id = deserializer.Deserialize();