Open
Description
It looks like when lldb initializes the default OutputFileHandle and ErrorFileHandle on a new debugger instance it is not setting the handles as writable (mode='w').
Here is a simple python script using the lldb module to illustrate this:
import lldb
dbg = lldb.SBDebugger.Create()
print("output", dbg.GetOutputFileHandle()) #> output <_io.TextIOWrapper name=1 mode='r' encoding='UTF-8'>
print("error", dbg.GetErrorFileHandle()) #> error <_io.TextIOWrapper name=2 mode='r' encoding='UTF-8'>
I think this is happening because:
- Debugger initializes with a
FILE*
llvm-project/lldb/source/Core/Debugger.cpp
Line 878 in ba704d5
- Calling into this
StreamFile
constructor https://github.com/llvm/llvm-project/blob/ba704d59569151f1b8b6552ed22a7b840f5e6256/lldb/include/lldb/Host/StreamFile.h#L31C3-L31C13 - That calls into
NativeFile
- That sets the options to
options()
llvm-project/lldb/include/lldb/Host/File.h
Line 384 in ba704d5
- That is initialized to
'r'
mode by default
However, stdout and stderr should be set to mode='w'
by default.