[Lldb-commits] [lldb] [lldb][windows] fix script interpreter file parsing (PR #193006)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 20 08:54:42 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/193006

>From fb4a1f6db52c6824e5f5585854b71fb1cae3a038 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 20 Apr 2026 16:43:00 +0100
Subject: [PATCH 1/2] [lldb][windows] fix script interpreter file parsing

---
 .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp    | 5 ++++-
 lldb/test/Shell/ScriptInterpreter/Python/io.test            | 2 --
 lldb/tools/driver/Driver.cpp                                | 6 +-----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index f962fb884d146..b75e49d81bd2d 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -590,7 +590,10 @@ bool ScriptInterpreterPythonImpl::SetStdHandle(FileSP file_sp,
 
   auto new_file = PythonFile::FromFile(file, mode);
   if (!new_file) {
-    llvm::consumeError(new_file.takeError());
+    LLDB_LOG(GetLog(LLDBLog::Script),
+             "ScriptInterpreterPythonImpl::SetStdHandle failed to wrap "
+             "sys.{0}: {1}",
+             py_name, llvm::toString(new_file.takeError()));
     return false;
   }
 
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/io.test b/lldb/test/Shell/ScriptInterpreter/Python/io.test
index f4303d4bcdf49..e2cc73f582bb0 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/io.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/io.test
@@ -1,5 +1,3 @@
-# UNSUPPORTED: system-windows
-
 # RUN: rm -rf %t.stdout %t.stderr
 # RUN: cat %s | %lldb --script-language python > %t.stdout 2> %t.stderr
 # RUN: cat %t.stdout | FileCheck %s --check-prefix STDOUT
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 27ba52e94e43d..8344a96aac8ac 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -449,12 +449,8 @@ int Driver::MainLoop() {
     atexit(reset_stdin_termios);
   }
 
-#ifndef _MSC_VER
-  // Disabling stdin buffering with MSVC's 2015 CRT exposes a bug in fgets
-  // which causes it to miss newlines depending on whether there have been an
-  // odd or even number of characters.  Bug has been reported to MS via Connect.
+
   ::setbuf(stdin, nullptr);
-#endif
   ::setbuf(stdout, nullptr);
 
   m_debugger.SetErrorFileHandle(stderr, false);

>From ba084b4f6233d79ba5f06b2ee8a37f50eba1d715 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 20 Apr 2026 17:54:27 +0200
Subject: [PATCH 2/2] fixup! [lldb][windows] fix script interpreter file
 parsing

---
 lldb/tools/driver/Driver.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 8344a96aac8ac..d47d3daf1c3fc 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -449,7 +449,6 @@ int Driver::MainLoop() {
     atexit(reset_stdin_termios);
   }
 
-
   ::setbuf(stdin, nullptr);
   ::setbuf(stdout, nullptr);
 



More information about the lldb-commits mailing list