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)); }
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)); }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits