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

via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 20 08:47:28 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

This patch fixes running lldb interpreter commands from an input file.

With the following file:
```
# input.txt
script --language python --
value = 250 + 5
print(value)
```
Running `command source ./input.txt` in lldb would fail.

This patch fixes the issue by assuming we build on a recent version of MSVC (>2015), allowing to reenable `lldb\test\Shell\ScriptInterpreter\Python\io.test`.

rdar://168064451

---
Full diff: https://github.com/llvm/llvm-project/pull/193006.diff


3 Files Affected:

- (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+4-1) 
- (modified) lldb/test/Shell/ScriptInterpreter/Python/io.test (-2) 
- (modified) lldb/tools/driver/Driver.cpp (+1-5) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/193006


More information about the lldb-commits mailing list