blob: e4b5634258a273ea5486b36868c044de139fed0a [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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"
Jason Molendadea5ea72010-06-09 21:28:42 +000020#include "lldb/Utility/PseudoTerminal.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021
22using namespace lldb;
23using namespace lldb_private;
24
25ScriptInterpreter::ScriptInterpreter (ScriptLanguage script_lang) :
26 m_script_lang (script_lang),
27 m_interpreter_pty ()
28{
29 if (m_interpreter_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, NULL, 0))
30 {
31 const char *slave_name = m_interpreter_pty.GetSlaveName(NULL, 0);
32 if (slave_name)
33 m_pty_slave_name.assign(slave_name);
34 }
35}
36
37ScriptInterpreter::~ScriptInterpreter ()
38{
39 m_interpreter_pty.CloseMasterFileDescriptor();
40}
41
42const char *
43ScriptInterpreter::GetScriptInterpreterPtyName ()
44{
45 return m_pty_slave_name.c_str();
46}
47
48int
49ScriptInterpreter::GetMasterFileDescriptor ()
50{
51 return m_interpreter_pty.GetMasterFileDescriptor();
52}
53
54void
55ScriptInterpreter::CollectDataForBreakpointCommandCallback
56(
Greg Claytonbef15832010-07-14 00:18:15 +000057 CommandInterpreter &interpreter,
Chris Lattner24943d22010-06-08 16:52:24 +000058 BreakpointOptions *bp_options,
59 CommandReturnObject &result
60)
61{
62 result.SetStatus (eReturnStatusFailed);
63 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
64}
65
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000066std::string
67ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
68{
69 std::string return_value;
Chris Lattner24943d22010-06-08 16:52:24 +000070
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000071 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}