Skip to content

Commit c4144ca

Browse files
committed
[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.
1 parent 4751e4f commit c4144ca

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lldb/source/Utility/ReproducerInstrumentation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "lldb/Utility/ReproducerInstrumentation.h"
1010
#include "lldb/Utility/Reproducer.h"
11+
#include <stdio.h>
1112

1213
using namespace lldb_private;
1314
using namespace lldb_private::repro;
@@ -47,6 +48,10 @@ bool Registry::Replay(llvm::StringRef buffer) {
4748
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
4849
#endif
4950

51+
// Disable buffering stdout so that we approximate the way things get flushed
52+
// during an interactive session.
53+
setvbuf(stdout, nullptr, _IONBF, 0);
54+
5055
Deserializer deserializer(buffer);
5156
while (deserializer.HasData(1)) {
5257
unsigned id = deserializer.Deserialize<unsigned>();

0 commit comments

Comments
 (0)