llvm-capstone/lldb/source/Interpreter/ScriptInterpreter.cpp
Enrico Granata 7bc0ec3aad This commit:
a) adds a Python summary provider for NSDate
 b) changes the initialization for ScriptInterpreter so that we are not passing a bulk of Python-specific function pointers around
 c) provides a new ScriptInterpreterObject class that allows for ref-count safe wrapping of scripting objects on the C++ side
 d) contains much needed performance improvements:
    1) the pointer to the Python function generating a scripted summary is now cached instead of looked up every time
    2) redundant memory reads in the Python ObjC runtime wrapper are eliminated
    3) summaries now use the m_summary_str in ValueObject to store their data instead of passing around ( == copying) an std::string object
 e) contains other minor fixes, such as adding descriptive error messages for some cases of summary generation failure

llvm-svn: 151703
2012-02-29 03:28:49 +00:00

87 lines
2.1 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/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Utility/PseudoTerminal.h"
using namespace lldb;
using namespace lldb_private;
ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang) :
m_interpreter (interpreter),
m_script_lang (script_lang)
{
}
ScriptInterpreter::~ScriptInterpreter ()
{
}
CommandInterpreter &
ScriptInterpreter::GetCommandInterpreter ()
{
return m_interpreter;
}
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;
}
void
ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback)
{
#ifndef LLDB_DISABLE_PYTHON
ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback);
#endif // #ifndef LLDB_DISABLE_PYTHON
}
void
ScriptInterpreter::TerminateInterpreter ()
{
#ifndef LLDB_DISABLE_PYTHON
ScriptInterpreterPython::TerminateInterpreter ();
#endif // #ifndef LLDB_DISABLE_PYTHON
}