[Lldb-commits] [PATCH] D52672: Set stdout/stdin to binary mode on Windows
Nathan Lanza via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 5 14:27:27 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346174: Set stdout/stdin to binary mode on Windows (authored by lanza, committed by ).
Herald added a subscriber: lldb-commits.
Changed prior to commit:
https://reviews.llvm.org/D52672?vs=168705&id=172656#toc
Repository:
rLLDB LLDB
https://reviews.llvm.org/D52672
Files:
tools/lldb-vscode/VSCode.cpp
Index: tools/lldb-vscode/VSCode.cpp
===================================================================
--- tools/lldb-vscode/VSCode.cpp
+++ tools/lldb-vscode/VSCode.cpp
@@ -14,6 +14,11 @@
#include "VSCode.h"
#include "LLDBUtils.h"
+#if defined(_WIN32)
+#include <io.h>
+#include <fcntl.h>
+#endif
+
using namespace lldb_vscode;
namespace {
@@ -39,6 +44,13 @@
focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
stop_at_entry(false) {
const char *log_file_path = getenv("LLDBVSCODE_LOG");
+#if defined(_WIN32)
+// Windows opens stdout and stdin in text mode which converts \n to 13,10
+// while the value is just 10 on Darwin/Linux. Setting the file mode to binary
+// fixes this.
+ assert(_setmode(fileno(stdout), _O_BINARY));
+ assert(_setmode(fileno(stdin), _O_BINARY));
+#endif
if (log_file_path)
log.reset(new std::ofstream(log_file_path));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52672.172656.patch
Type: text/x-patch
Size: 897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181105/15602787/attachment.bin>
More information about the lldb-commits
mailing list