[Lldb-commits] [lldb] r149098 - in /lldb/trunk: include/lldb/API/SBCommandInterpreter.h include/lldb/Interpreter/ScriptInterpreter.h scripts/Python/interface/SBCommandInterpreter.i source/API/SBCommandInterpreter.cpp source/Interpreter/ScriptInterpreter.cpp source/Interpreter/ScriptInterpreterPython.cpp

Greg Clayton gclayton at apple.com
Thu Jan 26 16:13:27 PST 2012


Author: gclayton
Date: Thu Jan 26 18:13:27 2012
New Revision: 149098

URL: http://llvm.org/viewvc/llvm-project?rev=149098&view=rev
Log:
<rdar://problem/10750012>

Remove a pseudo terminal master open and slave file descriptor that was being
used for pythong stdin. It was not hooked up correctly and was causing file
descriptor leaks.


Modified:
    lldb/trunk/include/lldb/API/SBCommandInterpreter.h
    lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
    lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
    lldb/trunk/source/API/SBCommandInterpreter.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Thu Jan 26 18:13:27 2012
@@ -65,12 +65,6 @@
     lldb::SBProcess
     GetProcess ();
 
-    ssize_t
-    WriteToScriptInterpreter (const char *src);
-
-    ssize_t
-    WriteToScriptInterpreter (const char *src, size_t src_len);
-
     void
     SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
 

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Thu Jan 26 18:13:27 2012
@@ -240,18 +240,6 @@
 protected:
     CommandInterpreter &m_interpreter;
     lldb::ScriptLanguage m_script_lang;
-
-    // Scripting languages may need to use stdin for their interactive loops;
-    // however we don't want them to grab the real system stdin because that
-    // resource needs to be shared among the debugger UI, the inferior process and these
-    // embedded scripting loops.  Therefore we need to set up a pseudoterminal and use that
-    // as stdin for the script interpreter interactive loops/prompts.
-
-    lldb_utility::PseudoTerminal m_interpreter_pty; // m_session_pty
-    std::string m_pty_slave_name;                   //m_session_pty_slave_name
-
-private:
-
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i Thu Jan 26 18:13:27 2012
@@ -99,14 +99,6 @@
     lldb::SBProcess
     GetProcess ();
 
-#if 0
-    ssize_t
-    WriteToScriptInterpreter (const char *src);
-#endif
-
-    ssize_t
-    WriteToScriptInterpreter (const char *src, size_t src_len);
-
     void
     SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
 

Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Thu Jan 26 18:13:27 2012
@@ -208,32 +208,6 @@
     return process;
 }
 
-ssize_t
-SBCommandInterpreter::WriteToScriptInterpreter (const char *src)
-{
-    return WriteToScriptInterpreter (src, strlen(src));
-}
-
-ssize_t
-SBCommandInterpreter::WriteToScriptInterpreter (const char *src, size_t src_len)
-{
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    ssize_t bytes_written = 0;
-    if (m_opaque_ptr && src && src[0])
-    {
-        ScriptInterpreter *script_interpreter = m_opaque_ptr->GetScriptInterpreter();
-        if (script_interpreter)
-            bytes_written = ::write (script_interpreter->GetMasterFileDescriptor(), src, src_len);
-    }
-    if (log)
-        log->Printf ("SBCommandInterpreter(%p)::WriteToScriptInterpreter (src=\"%s\", src_len=%zu) => %zi", 
-                     m_opaque_ptr, src, src_len, bytes_written);
-
-    return bytes_written;
-}
-
-
 CommandInterpreter *
 SBCommandInterpreter::get ()
 {

Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Thu Jan 26 18:13:27 2012
@@ -25,21 +25,12 @@
 
 ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang) :
     m_interpreter (interpreter),
-    m_script_lang (script_lang),
-    m_interpreter_pty (),
-    m_pty_slave_name ()
+    m_script_lang (script_lang)
 {
-    if (m_interpreter_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, NULL, 0))
-    {
-        const char *slave_name = m_interpreter_pty.GetSlaveName(NULL, 0);
-        if (slave_name)
-            m_pty_slave_name.assign(slave_name);
-    }
 }
 
 ScriptInterpreter::~ScriptInterpreter ()
 {
-    m_interpreter_pty.CloseMasterFileDescriptor();
 }
 
 CommandInterpreter &
@@ -48,18 +39,6 @@
     return m_interpreter;
 }
 
-const char *
-ScriptInterpreter::GetScriptInterpreterPtyName ()
-{
-    return m_pty_slave_name.c_str();
-}
-
-int
-ScriptInterpreter::GetMasterFileDescriptor ()
-{
-    return m_interpreter_pty.GetMasterFileDescriptor();
-}
-
 void 
 ScriptInterpreter::CollectDataForBreakpointCommandCallback 
 (

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=149098&r1=149097&r2=149098&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Jan 26 18:13:27 2012
@@ -187,7 +187,6 @@
     m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()),
     m_terminal_state (),
     m_session_is_active (false),
-    m_pty_slave_is_open (false),
     m_valid_session (true)
 {
 
@@ -262,7 +261,6 @@
     {
         m_embedded_thread_input_reader_sp->SetIsDone (true);
         m_embedded_python_pty.CloseSlaveFileDescriptor();
-        m_pty_slave_is_open = false;
         const InputReaderSP reader_sp = m_embedded_thread_input_reader_sp;
         m_embedded_thread_input_reader_sp.reset();
         debugger.PopInputReader (reader_sp);
@@ -348,14 +346,14 @@
         run_string.Printf ("run_one_line (%s, 'lldb.target = lldb.debugger.GetSelectedTarget()')", 
                            m_dictionary_name.c_str());
     else
-        run_string.Printf ("run_one_line (%s, 'lldb.target = None')", m_dictionary_name.c_str());
+        run_string.Printf ("run_one_line (%s, 'lldb.target = lldb.SBTarget()')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
     run_string.Clear();
 
     if (exe_ctx.GetProcessPtr())
         run_string.Printf ("run_one_line (%s, 'lldb.process = lldb.target.GetProcess()')", m_dictionary_name.c_str());
     else
-        run_string.Printf ("run_one_line (%s, 'lldb.process = None')", m_dictionary_name.c_str());
+        run_string.Printf ("run_one_line (%s, 'lldb.process = lldb.SBProcess()')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
     run_string.Clear();
 
@@ -363,7 +361,7 @@
         run_string.Printf ("run_one_line (%s, 'lldb.thread = lldb.process.GetSelectedThread ()')", 
                            m_dictionary_name.c_str());
     else
-        run_string.Printf ("run_one_line (%s, 'lldb.thread = None')", m_dictionary_name.c_str());
+        run_string.Printf ("run_one_line (%s, 'lldb.thread = lldb.SBThread()')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
     run_string.Clear();
     
@@ -371,7 +369,7 @@
         run_string.Printf ("run_one_line (%s, 'lldb.frame = lldb.thread.GetSelectedFrame ()')", 
                            m_dictionary_name.c_str());
     else
-        run_string.Printf ("run_one_line (%s, 'lldb.frame = None')", m_dictionary_name.c_str());
+        run_string.Printf ("run_one_line (%s, 'lldb.frame = lldb.SBFrame()')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
     run_string.Clear();
     
@@ -385,19 +383,6 @@
             
     if (PyErr_Occurred())
         PyErr_Clear ();
-        
-    if (!m_pty_slave_is_open)
-    {
-        run_string.Clear();
-        run_string.Printf ("run_one_line (%s, \"new_stdin = open('%s', 'r')\")", m_dictionary_name.c_str(),
-                           m_pty_slave_name.c_str());
-        PyRun_SimpleString (run_string.GetData());
-        m_pty_slave_is_open = true;
-        
-        run_string.Clear();
-        run_string.Printf ("run_one_line (%s, 'sys.stdin = new_stdin')", m_dictionary_name.c_str());
-        PyRun_SimpleString (run_string.GetData());
-    }
 }   
 
 
@@ -1651,8 +1636,6 @@
     
     script_interpreter->m_embedded_python_pty.CloseSlaveFileDescriptor();
 
-    script_interpreter->m_pty_slave_is_open = false;
-    
     log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT);
     if (log)
         log->Printf ("%p ScriptInterpreterPython::RunEmbeddedPythonInterpreter () thread exiting...", baton);





More information about the lldb-commits mailing list