Skip to content

Commit

Permalink
Convert the ScriptInterpreter system to a plugin-based one.
Browse files Browse the repository at this point in the history
Previously embedded interpreters were handled as ad-hoc source
files compiled into source/Interpreter.  This made it hard to
disable a specific interpreter, or to add support for other
interpreters and allow the developer to choose which interpreter(s)
were enabled for a particular build.

This patch converts script interpreters over to a plugin-based system.
Script interpreters now live in source/Plugins/ScriptInterpreter, and
the canonical LLDB interpreter, ScriptInterpreterPython, is moved there
as well.

Any new code interfacing with the Python C API must live in this location
from here on out.  Additionally, generic code should never need to
reference or make assumptions about the presence of a specific interpreter
going forward.

Differential Revision: http://reviews.llvm.org/D11431
Reviewed By: Greg Clayton

llvm-svn: 243681
  • Loading branch information
Zachary Turner committed Jul 30, 2015
1 parent 13ac40e commit 2c1f46d
Show file tree
Hide file tree
Showing 33 changed files with 545 additions and 316 deletions.
1 change: 0 additions & 1 deletion lldb/include/lldb/API/SystemInitializerFull.h
Expand Up @@ -33,7 +33,6 @@ class SystemInitializerFull : public SystemInitializerCommon

private:
void InitializeSWIG();
void TerminateSWIG();
};
}

Expand Down
17 changes: 17 additions & 0 deletions lldb/include/lldb/Core/PluginManager.h
Expand Up @@ -295,6 +295,23 @@ class PluginManager
static const char *
GetProcessPluginDescriptionAtIndex (uint32_t idx);

//------------------------------------------------------------------
// ScriptInterpreter
//------------------------------------------------------------------
static bool
RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang,
ScriptInterpreterCreateInstance create_callback);

static bool
UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);

static ScriptInterpreterCreateInstance
GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);

static lldb::ScriptInterpreterSP
GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
CommandInterpreter &interpreter);

//------------------------------------------------------------------
// SymbolFile
//------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions lldb/include/lldb/Interpreter/CommandInterpreter.h
Expand Up @@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
Expand Down Expand Up @@ -520,7 +521,10 @@ class CommandInterpreter :
GetOptionArgumentPosition (const char *in_string);

ScriptInterpreter *
GetScriptInterpreter (bool can_create = true);
GetScriptInterpreter(bool can_create = true);

void
SetScriptInterpreter();

void
SkipLLDBInitFiles (bool skip_lldbinit_files)
Expand Down Expand Up @@ -709,7 +713,7 @@ class CommandInterpreter :
OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias.
CommandHistory m_command_history;
std::string m_repeat_command; // Stores the command that will be executed for an empty command string.
std::unique_ptr<ScriptInterpreter> m_script_interpreter_ap;
lldb::ScriptInterpreterSP m_script_interpreter_sp;
lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char;
bool m_batch_command_mode;
Expand Down
4 changes: 2 additions & 2 deletions lldb/include/lldb/Interpreter/ScriptInterpreter.h
Expand Up @@ -14,6 +14,7 @@

#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"

#include "lldb/Utility/PseudoTerminal.h"
Expand All @@ -36,8 +37,7 @@ class ScriptInterpreterLocker
DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterLocker);
};


class ScriptInterpreter
class ScriptInterpreter : public PluginInterface
{
public:

Expand Down
35 changes: 0 additions & 35 deletions lldb/include/lldb/Interpreter/ScriptInterpreterNone.h

This file was deleted.

73 changes: 0 additions & 73 deletions lldb/include/lldb/Utility/PythonPointer.h

This file was deleted.

2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-forward.h
Expand Up @@ -376,6 +376,8 @@ namespace lldb {
#ifndef LLDB_DISABLE_PYTHON
typedef std::shared_ptr<lldb_private::ScriptSummaryFormat> ScriptSummaryFormatSP;
#endif // #ifndef LLDB_DISABLE_PYTHON
typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP;
typedef std::unique_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterUP;
typedef std::shared_ptr<lldb_private::Section> SectionSP;
typedef std::unique_ptr<lldb_private::SectionList> SectionListUP;
typedef std::weak_ptr<lldb_private::Section> SectionWP;
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/lldb-private-interfaces.h
Expand Up @@ -33,6 +33,7 @@ namespace lldb_private
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(CommandInterpreter &interpreter);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
Expand Down
31 changes: 0 additions & 31 deletions lldb/include/lldb/lldb-python.h

This file was deleted.

0 comments on commit 2c1f46d

Please sign in to comment.