1 //===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Interpreter/ScriptInterpreter.h" 11 12 #include <string> 13 #include <stdlib.h> 14 #include <stdio.h> 15 16 #include "lldb/Core/Error.h" 17 #include "lldb/Core/Stream.h" 18 #include "lldb/Core/StringList.h" 19 #include "lldb/Interpreter/CommandReturnObject.h" 20 #include "lldb/Utility/PseudoTerminal.h" 21 22 using namespace lldb; 23 using namespace lldb_private; 24 25 ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, ScriptLanguage script_lang) : 26 m_interpreter (interpreter), 27 m_script_lang (script_lang), 28 m_interpreter_pty () 29 { 30 if (m_interpreter_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, NULL, 0)) 31 { 32 const char *slave_name = m_interpreter_pty.GetSlaveName(NULL, 0); 33 if (slave_name) 34 m_pty_slave_name.assign(slave_name); 35 } 36 } 37 38 ScriptInterpreter::~ScriptInterpreter () 39 { 40 m_interpreter_pty.CloseMasterFileDescriptor(); 41 } 42 43 const char * 44 ScriptInterpreter::GetScriptInterpreterPtyName () 45 { 46 return m_pty_slave_name.c_str(); 47 } 48 49 int 50 ScriptInterpreter::GetMasterFileDescriptor () 51 { 52 return m_interpreter_pty.GetMasterFileDescriptor(); 53 } 54 55 void 56 ScriptInterpreter::CollectDataForBreakpointCommandCallback 57 ( 58 BreakpointOptions *bp_options, 59 CommandReturnObject &result 60 ) 61 { 62 result.SetStatus (eReturnStatusFailed); 63 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented."); 64 } 65 66 std::string 67 ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language) 68 { 69 std::string return_value; 70 71 switch (language) 72 { 73 case eScriptLanguageNone: 74 return_value = "None"; 75 break; 76 case eScriptLanguagePython: 77 return_value = "Python"; 78 break; 79 80 } 81 82 return return_value; 83 } 84