llvm-project/lldb/source/Interpreter/ScriptInterpreter.cpp
Greg Clayton a701509229 Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't
very usable and made for a lot of unnecessary code just to access variables
that were already owned by the objects.

While I fixed those things, I saw that CommandObject objects should really
have a reference to their command interpreter so they can access the terminal
with if they want to output usaage. Fixed up all CommandObjects to take
an interpreter and cleaned up the API to not need the interpreter to be
passed in.

Fixed the disassemble command to output the usage if no options are passed
down and arguments are passed (all disassebmle variants take options, there
are no "args only").

llvm-svn: 114252
2010-09-18 01:14:36 +00:00

84 lines
2.0 KiB
C++

//===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/ScriptInterpreter.h"
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include "lldb/Core/Error.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Utility/PseudoTerminal.h"
using namespace lldb;
using namespace lldb_private;
ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, ScriptLanguage script_lang) :
m_interpreter (interpreter),
m_script_lang (script_lang),
m_interpreter_pty ()
{
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();
}
const char *
ScriptInterpreter::GetScriptInterpreterPtyName ()
{
return m_pty_slave_name.c_str();
}
int
ScriptInterpreter::GetMasterFileDescriptor ()
{
return m_interpreter_pty.GetMasterFileDescriptor();
}
void
ScriptInterpreter::CollectDataForBreakpointCommandCallback
(
BreakpointOptions *bp_options,
CommandReturnObject &result
)
{
result.SetStatus (eReturnStatusFailed);
result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
}
std::string
ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
{
std::string return_value;
switch (language)
{
case eScriptLanguageNone:
return_value = "None";
break;
case eScriptLanguagePython:
return_value = "Python";
break;
}
return return_value;
}