summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-02-09 01:08:52 +0000
committerGreg Clayton <gclayton@apple.com>2011-02-09 01:08:52 +0000
commit51b1e2d271a4749654c2168aad7b24321bbb2897 (patch)
treeba30fa1dae5d98f59f4b43af59459e9279bb22da /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent7eaacc517bc312d43d511856f359e7bd68c344f1 (diff)
downloadbcm5719-llvm-51b1e2d271a4749654c2168aad7b24321bbb2897.tar.gz
bcm5719-llvm-51b1e2d271a4749654c2168aad7b24321bbb2897.zip
Use Host::File in lldb_private::StreamFile and other places to cleanup host
layer a bit more. llvm-svn: 125149
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp49
1 files changed, 20 insertions, 29 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 88f42233789..54d46068905 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -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
{
OpenPOWER on IntegriCloud