-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
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
m_output_stream_sp(std::make_shared<StreamFile>(stdout, false)), - 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
m_file_sp = std::make_shared<NativeFile>(fh, transfer_ownership); - That sets the options to
options()
llvm-project/lldb/include/lldb/Host/File.h
Line 384 in ba704d5
m_options(), m_own_stream(transfer_ownership) {} - That is initialized to
'r'
mode by defaulteOpenOptionReadOnly = 0x0, // Open file for reading (only)
However, stdout and stderr should be set to mode='w'
by default.