[Lldb-commits] [lldb] r113880 - in /lldb/trunk/source: Commands/CommandObjectProcess.cpp Interpreter/ScriptInterpreterPython.cpp

Caroline Tice ctice at apple.com
Tue Sep 14 15:49:06 PDT 2010


Author: ctice
Date: Tue Sep 14 17:49:06 2010
New Revision: 113880

URL: http://llvm.org/viewvc/llvm-project?rev=113880&view=rev
Log:
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.


Modified:
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113880&r1=113879&r2=113880&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Sep 14 17:49:06 2010
@@ -464,8 +464,6 @@
                        "Attach to a process.",
                        "process attach <cmd-options>")
     {
-        SetHelpLong("Currently, you must set the executable file before you can attach "
-                    "to a process.\n");
     }
 
     ~CommandObjectProcessAttach ()

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113880&r1=113879&r2=113880&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 14 17:49:06 2010
@@ -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:





More information about the lldb-commits mailing list