Use Host::File in lldb_private::StreamFile and other places to cleanup host
layer a bit more. llvm-svn: 125149
This commit is contained in:
@@ -198,7 +198,7 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
|
||||
ScriptInterpreter (interpreter, eScriptLanguagePython),
|
||||
m_embedded_python_pty (),
|
||||
m_embedded_thread_input_reader_sp (),
|
||||
m_dbg_stdout (interpreter.GetDebugger().GetOutputFileHandle()),
|
||||
m_dbg_stdout (interpreter.GetDebugger().GetOutputFile().GetStream()),
|
||||
m_new_sysout (NULL),
|
||||
m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()),
|
||||
m_terminal_state (),
|
||||
@@ -570,24 +570,17 @@ ScriptInterpreterPython::InputReaderCallback
|
||||
if (script_interpreter->m_script_lang != eScriptLanguagePython)
|
||||
return 0;
|
||||
|
||||
FILE *out_fh = reader.GetDebugger().GetOutputFileHandle ();
|
||||
if (out_fh == NULL)
|
||||
out_fh = stdout;
|
||||
File &out_file = reader.GetDebugger().GetOutputFile();
|
||||
|
||||
switch (notification)
|
||||
{
|
||||
case eInputReaderActivate:
|
||||
{
|
||||
if (out_fh)
|
||||
{
|
||||
::fprintf (out_fh, "Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n");
|
||||
}
|
||||
out_file.Printf ("Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n");
|
||||
|
||||
// Save terminal settings if we can
|
||||
int input_fd;
|
||||
FILE *input_fh = reader.GetDebugger().GetInputFileHandle();
|
||||
if (input_fh != NULL)
|
||||
input_fd = ::fileno (input_fh);
|
||||
else
|
||||
int input_fd = reader.GetDebugger().GetInputFile().GetDescriptor();
|
||||
if (input_fd == File::kInvalidDescriptor)
|
||||
input_fd = STDIN_FILENO;
|
||||
|
||||
script_interpreter->SaveTerminalState(input_fd);
|
||||
@@ -596,7 +589,7 @@ ScriptInterpreterPython::InputReaderCallback
|
||||
{
|
||||
while (!GetPythonLock(1))
|
||||
{
|
||||
::fprintf (out_fh, "Python interpreter locked on another thread; waiting to acquire lock...\n");
|
||||
out_file.Printf ("Python interpreter locked on another thread; waiting to acquire lock...\n");
|
||||
}
|
||||
script_interpreter->EnterSession ();
|
||||
ReleasePythonLock();
|
||||
@@ -718,7 +711,7 @@ ScriptInterpreterPython::ExecuteInterpreterLoop ()
|
||||
// try to embed a running interpreter loop inside the already running Python interpreter loop, so we won't
|
||||
// do it.
|
||||
|
||||
if (debugger.GetInputFileHandle() == NULL)
|
||||
if (!debugger.GetInputFile().IsValid())
|
||||
return;
|
||||
|
||||
InputReaderSP reader_sp (new InputReader(debugger));
|
||||
@@ -1035,21 +1028,19 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback
|
||||
{
|
||||
static StringList commands_in_progress;
|
||||
|
||||
FILE *out_fh = reader.GetDebugger().GetOutputFileHandle();
|
||||
if (out_fh == NULL)
|
||||
out_fh = stdout;
|
||||
File &out_file = reader.GetDebugger().GetOutputFile();
|
||||
|
||||
switch (notification)
|
||||
{
|
||||
case eInputReaderActivate:
|
||||
{
|
||||
commands_in_progress.Clear();
|
||||
if (out_fh)
|
||||
if (out_file.IsValid())
|
||||
{
|
||||
::fprintf (out_fh, "%s\n", g_reader_instructions);
|
||||
out_file.Printf ("%s\n", g_reader_instructions);
|
||||
if (reader.GetPrompt())
|
||||
::fprintf (out_fh, "%s", reader.GetPrompt());
|
||||
::fflush (out_fh);
|
||||
out_file.Printf ("%s", reader.GetPrompt());
|
||||
out_file.Flush ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1058,10 +1049,10 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback
|
||||
break;
|
||||
|
||||
case eInputReaderReactivate:
|
||||
if (reader.GetPrompt() && out_fh)
|
||||
if (reader.GetPrompt() && out_file.IsValid())
|
||||
{
|
||||
::fprintf (out_fh, "%s", reader.GetPrompt());
|
||||
::fflush (out_fh);
|
||||
out_file.Printf ("%s", reader.GetPrompt());
|
||||
out_file.Flush ();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1069,10 +1060,10 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback
|
||||
{
|
||||
std::string temp_string (bytes, bytes_len);
|
||||
commands_in_progress.AppendString (temp_string.c_str());
|
||||
if (out_fh && !reader.IsDone() && reader.GetPrompt())
|
||||
if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt())
|
||||
{
|
||||
::fprintf (out_fh, "%s", reader.GetPrompt());
|
||||
::fflush (out_fh);
|
||||
out_file.Printf ("%s", reader.GetPrompt());
|
||||
out_file.Flush ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1108,7 +1099,7 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback
|
||||
}
|
||||
}
|
||||
else
|
||||
::fprintf (out_fh, "Warning: No command attached to breakpoint.\n");
|
||||
out_file.Printf ("Warning: No command attached to breakpoint.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user