[Lldb-commits] [lldb] c4144ca - [lldb/Reproducer] Disable buffering	of stdout during replay
    Jonas Devlieghere via lldb-commits 
    lldb-commits at lists.llvm.org
       
    Wed Jan 22 16:17:24 PST 2020
    
    
  
Author: Jonas Devlieghere
Date: 2020-01-22T16:17:08-08:00
New Revision: c4144caf9b865a2064e49afcdfff474426fc5d47
URL: https://github.com/llvm/llvm-project/commit/c4144caf9b865a2064e49afcdfff474426fc5d47
DIFF: https://github.com/llvm/llvm-project/commit/c4144caf9b865a2064e49afcdfff474426fc5d47.diff
LOG: [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.
Added: 
    
Modified: 
    lldb/source/Utility/ReproducerInstrumentation.cpp
Removed: 
    
################################################################################
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 <stdio.h>
 
 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<unsigned>();
        
    
    
More information about the lldb-commits
mailing list