diff options
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 33a9b91e906..10bb26791a1 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -245,64 +245,44 @@ Debugger::DisconnectInput() void Debugger::SetInputFileHandle (FILE *fh, bool tranfer_ownership) { - m_input_file.SetFileHandle (fh, tranfer_ownership); - if (m_input_file.GetFileHandle() == NULL) - m_input_file.SetFileHandle (stdin, false); + File &in_file = GetInputFile(); + in_file.SetStream (fh, tranfer_ownership); + if (in_file.IsValid() == false) + in_file.SetStream (stdin, true); // Disconnect from any old connection if we had one m_input_comm.Disconnect (); - m_input_comm.SetConnection (new ConnectionFileDescriptor (::fileno (GetInputFileHandle()), true)); + m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), true)); m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this); Error error; if (m_input_comm.StartReadThread (&error) == false) { - FILE *err_fh = GetErrorFileHandle(); - if (err_fh) - { - ::fprintf (err_fh, "error: failed to main input read thread: %s", error.AsCString() ? error.AsCString() : "unkown error"); - exit(1); - } - } - -} + File &err_file = GetErrorFile(); -FILE * -Debugger::GetInputFileHandle () -{ - return m_input_file.GetFileHandle(); + err_file.Printf ("error: failed to main input read thread: %s", error.AsCString() ? error.AsCString() : "unkown error"); + exit(1); + } } - void Debugger::SetOutputFileHandle (FILE *fh, bool tranfer_ownership) { - m_output_file.SetFileHandle (fh, tranfer_ownership); - if (m_output_file.GetFileHandle() == NULL) - m_output_file.SetFileHandle (stdin, false); + File &out_file = GetOutputFile(); + out_file.SetStream (fh, tranfer_ownership); + if (out_file.IsValid() == false) + out_file.SetStream (stdout, false); GetCommandInterpreter().GetScriptInterpreter()->ResetOutputFileHandle (fh); } -FILE * -Debugger::GetOutputFileHandle () -{ - return m_output_file.GetFileHandle(); -} - void Debugger::SetErrorFileHandle (FILE *fh, bool tranfer_ownership) { - m_error_file.SetFileHandle (fh, tranfer_ownership); - if (m_error_file.GetFileHandle() == NULL) - m_error_file.SetFileHandle (stdin, false); -} - - -FILE * -Debugger::GetErrorFileHandle () -{ - return m_error_file.GetFileHandle(); + File &err_file = GetErrorFile(); + err_file.SetStream (fh, tranfer_ownership); + if (err_file.IsValid() == false) + err_file.SetStream (stderr, false); } CommandInterpreter & @@ -547,12 +527,11 @@ Debugger::CheckIfTopInputReaderIsDone () void Debugger::ActivateInputReader (const InputReaderSP &reader_sp) { - FILE *in_fh = GetInputFileHandle(); + int input_fd = m_input_file.GetFile().GetDescriptor(); - if (in_fh) + if (input_fd >= 0) { - int in_fd = fileno (in_fh); - Terminal tty(in_fd); + Terminal tty(input_fd); tty.SetEcho(reader_sp->GetEcho()); |