Remove help text that is no longer correct.
Fix Python script interpreter to not fail when the Debugger does
not have input/output file handles.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113880 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index ffb2c9b..39ae32a 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -298,8 +298,13 @@
case eInputReaderActivate:
{
// Save terminal settings if we can
+ int input_fd;
FILE *input_fh = reader.GetDebugger().GetInputFileHandle();
- int input_fd = ::fileno (input_fh);
+ if (input_fh != NULL)
+ input_fd = ::fileno (input_fh);
+ else
+ input_fd = STDIN_FILENO;
+
script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0;
struct termios tmp_termios;
if (::tcgetattr (input_fd, &tmp_termios) == 0)
@@ -335,9 +340,14 @@
// Restore terminal settings if they were validly saved
if (script_interpreter->m_termios_valid)
{
- ::tcsetattr (::fileno (reader.GetDebugger().GetInputFileHandle()),
- TCSANOW,
- &script_interpreter->m_termios);
+ int input_fd;
+ FILE *input_fh = reader.GetDebugger().GetInputFileHandle();
+ if (input_fh != NULL)
+ input_fd = ::fileno (input_fh);
+ else
+ input_fd = STDIN_FILENO;
+
+ ::tcsetattr (input_fd, TCSANOW, &script_interpreter->m_termios);
}
break;
}
@@ -352,6 +362,15 @@
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
Debugger &debugger = interpreter.GetDebugger();
+
+ // At the moment, the only time the debugger does not have an input file handle is when this is called
+ // directly from Python, in which case it is both dangerous and unnecessary (not to mention confusing) to
+ // try to embed a running interpreter loop inside the already running Python interpreter loop, so we won't
+ // do it.
+
+ if (debugger.GetInputFileHandle() == NULL)
+ return;
+
InputReaderSP reader_sp (new InputReader(debugger));
if (reader_sp)
{
@@ -556,6 +575,9 @@
static StringList commands_in_progress;
FILE *out_fh = reader.GetDebugger().GetOutputFileHandle();
+ if (out_fh == NULL)
+ out_fh = stdout;
+
switch (notification)
{
case eInputReaderActivate: