private:
void InitializeSWIG();
- void TerminateSWIG();
};
}
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
//------------------------------------------------------------------
static bool
// 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"
GetOptionArgumentPosition (const char *in_string);
ScriptInterpreter *
- GetScriptInterpreter (bool can_create = true);
+ GetScriptInterpreter(bool can_create = true);
+
+ void
+ SetScriptInterpreter();
void
SkipLLDBInitFiles (bool skip_lldbinit_files)
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;
#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"
DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterLocker);
};
-
-class ScriptInterpreter
+class ScriptInterpreter : public PluginInterface
{
public:
+++ /dev/null
-//===-- ScriptInterpreterNone.h ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ScriptInterpreterNone_h_
-#define liblldb_ScriptInterpreterNone_h_
-
-#include "lldb/Interpreter/ScriptInterpreter.h"
-
-namespace lldb_private {
-
-class ScriptInterpreterNone : public ScriptInterpreter
-{
-public:
-
- ScriptInterpreterNone (CommandInterpreter &interpreter);
-
- ~ScriptInterpreterNone ();
-
- bool
- ExecuteOneLine (const char *command, CommandReturnObject *result, const ExecuteScriptOptions &options = ExecuteScriptOptions());
-
- void
- ExecuteInterpreterLoop ();
-
-};
-
-} // namespace lldb_private
-
-#endif // #ifndef liblldb_ScriptInterpreterNone_h_
+++ /dev/null
-//===---------------------PythonPointer.h ------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_PythonPointer_h_
-#define utility_PythonPointer_h_
-
-#include <algorithm>
-
-#include "lldb/lldb-python.h"
-
-namespace lldb_private {
-
-template<class T>
-class PythonPointer
-{
-public:
- typedef PyObject* element_type;
-private:
- element_type* ptr_;
- bool my_ref;
-public:
-
- PythonPointer(element_type p, bool steal_ref = false) :
- ptr_(p),
- my_ref(!steal_ref)
- {
- if (my_ref)
- Py_INCREF(ptr_);
- }
-
- PythonPointer(const PythonPointer& r, bool steal_ref = false) :
- ptr_(r.ptr_),
- my_ref(!steal_ref)
- {
- if (my_ref)
- Py_INCREF(ptr_);
- }
-
- ~PythonPointer()
- {
- if (my_ref)
- Py_XDECREF(ptr_);
- }
-
- PythonPointer
- StealReference()
- {
- return PythonPointer(ptr_,true);
- }
-
- PythonPointer
- DuplicateReference()
- {
- return PythonPointer(ptr_, false);
- }
-
- element_type get() const {return ptr_;}
-
- bool IsNull() { return ptr_ == NULL; }
- bool IsNone() { return ptr_ == Py_None; }
-
- operator PyObject* () { return ptr_; }
-};
-
-} // namespace lldb
-
-#endif // utility_PythonPointer_h_
#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;
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);
+++ /dev/null
-//===-- lldb-python.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_lldb_python_h_
-#define LLDB_lldb_python_h_
-
-// Python.h needs to be included before any system headers in order to avoid redefinition of macros
-
-#ifdef LLDB_DISABLE_PYTHON
-// Python is disabled in this build
-#else
- #if defined(__linux__)
- // features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
- // may be different from the value that Python defines it to be which results
- // in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
- // holds for _XOPEN_SOURCE.
- #undef _POSIX_C_SOURCE
- #undef _XOPEN_SOURCE
- #endif
-
- // Include python for non windows machines
- #include <Python.h>
-#endif // LLDB_DISABLE_PYTHON
-
-#endif // LLDB_lldb_python_h_
2689008513353E2200698AC0 /* CommandReturnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */; };
2689008613353E2200698AC0 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8610F1B85900F91463 /* Options.cpp */; };
2689008713353E2200698AC0 /* ScriptInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */; };
- 2689008813353E2200698AC0 /* ScriptInterpreterNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */; };
- 2689008913353E2200698AC0 /* ScriptInterpreterPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0C10F1B8DD00F91463 /* ScriptInterpreterPython.cpp */; };
2689008D13353E4200698AC0 /* DynamicLoaderMacOSXDYLD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */; };
2689008E13353E4200698AC0 /* DynamicLoaderStatic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268A683D1321B53B000E3FB8 /* DynamicLoaderStatic.cpp */; };
2689009613353E4200698AC0 /* ObjectContainerBSDArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A3B4AC1181454800381BC2 /* ObjectContainerBSDArchive.cpp */; };
3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692E1ABB7A6D001DA9DF /* SystemInitializer.cpp */; };
3F8169321ABB7A6D001DA9DF /* SystemInitializerCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692F1ABB7A6D001DA9DF /* SystemInitializerCommon.cpp */; };
3F8169331ABB7A6D001DA9DF /* SystemLifetimeManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169301ABB7A6D001DA9DF /* SystemLifetimeManager.cpp */; };
+ 3FBA69DF1B6067020008F44A /* ScriptInterpreterNone.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3FBA69DD1B6067020008F44A /* ScriptInterpreterNone.cpp */; };
+ 3FBA69E01B6067020008F44A /* ScriptInterpreterNone.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3FBA69DE1B6067020008F44A /* ScriptInterpreterNone.h */; };
+ 3FBA69E11B6067120008F44A /* ScriptInterpreterNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FBA69DD1B6067020008F44A /* ScriptInterpreterNone.cpp */; };
+ 3FBA69E71B60672A0008F44A /* lldb-python.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3FBA69E21B60672A0008F44A /* lldb-python.h */; };
+ 3FBA69E91B60672A0008F44A /* PythonDataObjects.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3FBA69E41B60672A0008F44A /* PythonDataObjects.h */; };
+ 3FBA69EB1B60672A0008F44A /* ScriptInterpreterPython.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3FBA69E61B60672A0008F44A /* ScriptInterpreterPython.h */; };
+ 3FBA69EC1B6067430008F44A /* PythonDataObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FBA69E31B60672A0008F44A /* PythonDataObjects.cpp */; };
+ 3FBA69ED1B60674B0008F44A /* ScriptInterpreterPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FBA69E51B60672A0008F44A /* ScriptInterpreterPython.cpp */; };
3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; };
3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; };
3FDFDDC6199D37ED009756A7 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */; };
94D6A0AB16CEB55F00833B6E /* NSDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D6A0A816CEB55F00833B6E /* NSDictionary.cpp */; };
94D6A0AC16CEB55F00833B6E /* NSSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D6A0A916CEB55F00833B6E /* NSSet.cpp */; };
94E829CA152D33C1006F96A3 /* lldb-server in Resources */ = {isa = PBXBuildFile; fileRef = 26DC6A101337FE6900FF7998 /* lldb-server */; };
- 94EA1D5C15E6C9B400D4171A /* PythonDataObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94EA1D5B15E6C9B400D4171A /* PythonDataObjects.cpp */; };
94EA27CE17DE91750070F505 /* LibCxxUnorderedMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94EA27CD17DE91750070F505 /* LibCxxUnorderedMap.cpp */; };
94F48F251A01C687005C0EC6 /* StringPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94F48F241A01C687005C0EC6 /* StringPrinter.cpp */; };
94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94FA3DDF1405D50300833217 /* ValueObjectConstResultChild.cpp */; };
dstPath = "$(DEVELOPER_DIR)/usr/share/man/man1/";
dstSubfolderSpec = 0;
files = (
+ 3FBA69E91B60672A0008F44A /* PythonDataObjects.h in CopyFiles */,
AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */,
+ 3FBA69E71B60672A0008F44A /* lldb-python.h in CopyFiles */,
+ 3FBA69DF1B6067020008F44A /* ScriptInterpreterNone.cpp in CopyFiles */,
+ 3FBA69E01B6067020008F44A /* ScriptInterpreterNone.h in CopyFiles */,
33E5E8461A6736D30024ED68 /* StringConvert.h in CopyFiles */,
+ 3FBA69EB1B60672A0008F44A /* ScriptInterpreterPython.h in CopyFiles */,
AFC234081AF85CE000CDE8B6 /* CommandObjectLanguage.cpp in CopyFiles */,
33E5E8421A672A240024ED68 /* StringConvert.cpp in CopyFiles */,
);
26BC7DE310F1B7F900F91463 /* CommandObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObject.h; path = include/lldb/Interpreter/CommandObject.h; sourceTree = "<group>"; };
26BC7DE410F1B7F900F91463 /* CommandReturnObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandReturnObject.h; path = include/lldb/Interpreter/CommandReturnObject.h; sourceTree = "<group>"; };
26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreter.h; path = include/lldb/Interpreter/ScriptInterpreter.h; sourceTree = "<group>"; };
- 26BC7DE610F1B7F900F91463 /* ScriptInterpreterPython.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreterPython.h; path = include/lldb/Interpreter/ScriptInterpreterPython.h; sourceTree = "<group>"; };
26BC7DF110F1B81A00F91463 /* DynamicLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicLoader.h; path = include/lldb/Target/DynamicLoader.h; sourceTree = "<group>"; };
26BC7DF210F1B81A00F91463 /* ExecutionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContext.h; path = include/lldb/Target/ExecutionContext.h; sourceTree = "<group>"; };
26BC7DF310F1B81A00F91463 /* Process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Process.h; path = include/lldb/Target/Process.h; sourceTree = "<group>"; };
26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandInterpreter.cpp; path = source/Interpreter/CommandInterpreter.cpp; sourceTree = "<group>"; };
26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObject.cpp; path = source/Interpreter/CommandObject.cpp; sourceTree = "<group>"; };
26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandReturnObject.cpp; path = source/Interpreter/CommandReturnObject.cpp; sourceTree = "<group>"; };
- 26BC7F0C10F1B8DD00F91463 /* ScriptInterpreterPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreterPython.cpp; path = source/Interpreter/ScriptInterpreterPython.cpp; sourceTree = "<group>"; };
26BC7F1310F1B8EC00F91463 /* Block.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Block.cpp; path = source/Symbol/Block.cpp; sourceTree = "<group>"; };
26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTContext.cpp; path = source/Symbol/ClangASTContext.cpp; sourceTree = "<group>"; };
26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompileUnit.cpp; path = source/Symbol/CompileUnit.cpp; sourceTree = "<group>"; };
3F8169341ABB7A80001DA9DF /* SystemInitializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializer.h; path = include/lldb/Initialization/SystemInitializer.h; sourceTree = "<group>"; };
3F8169351ABB7A80001DA9DF /* SystemInitializerCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializerCommon.h; path = include/lldb/Initialization/SystemInitializerCommon.h; sourceTree = "<group>"; };
3F8169361ABB7A80001DA9DF /* SystemLifetimeManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemLifetimeManager.h; path = include/lldb/Initialization/SystemLifetimeManager.h; sourceTree = "<group>"; };
+ 3FBA69DD1B6067020008F44A /* ScriptInterpreterNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreterNone.cpp; path = ScriptInterpreter/None/ScriptInterpreterNone.cpp; sourceTree = "<group>"; };
+ 3FBA69DE1B6067020008F44A /* ScriptInterpreterNone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreterNone.h; path = ScriptInterpreter/None/ScriptInterpreterNone.h; sourceTree = "<group>"; };
+ 3FBA69E21B60672A0008F44A /* lldb-python.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-python.h"; path = "ScriptInterpreter/Python/lldb-python.h"; sourceTree = "<group>"; };
+ 3FBA69E31B60672A0008F44A /* PythonDataObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonDataObjects.cpp; path = ScriptInterpreter/Python/PythonDataObjects.cpp; sourceTree = "<group>"; };
+ 3FBA69E41B60672A0008F44A /* PythonDataObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonDataObjects.h; path = ScriptInterpreter/Python/PythonDataObjects.h; sourceTree = "<group>"; };
+ 3FBA69E51B60672A0008F44A /* ScriptInterpreterPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreterPython.cpp; path = ScriptInterpreter/Python/ScriptInterpreterPython.cpp; sourceTree = "<group>"; };
+ 3FBA69E61B60672A0008F44A /* ScriptInterpreterPython.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreterPython.h; path = ScriptInterpreter/Python/ScriptInterpreterPython.h; sourceTree = "<group>"; };
3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = "<group>"; };
3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = "<group>"; };
3FDFDDBE199D345E009756A7 /* FileCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCache.cpp; path = source/Host/common/FileCache.cpp; sourceTree = "<group>"; };
94D6A0A916CEB55F00833B6E /* NSSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSSet.cpp; path = source/DataFormatters/NSSet.cpp; sourceTree = "<group>"; };
94E367CC140C4EC4001C7A5A /* modify-python-lldb.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "modify-python-lldb.py"; sourceTree = "<group>"; };
94E367CE140C4EEA001C7A5A /* python-typemaps.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-typemaps.swig"; sourceTree = "<group>"; };
- 94EA1D5A15E6C99B00D4171A /* PythonDataObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonDataObjects.h; path = include/lldb/Interpreter/PythonDataObjects.h; sourceTree = "<group>"; };
- 94EA1D5B15E6C9B400D4171A /* PythonDataObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonDataObjects.cpp; path = source/Interpreter/PythonDataObjects.cpp; sourceTree = "<group>"; };
94EA27CD17DE91750070F505 /* LibCxxUnorderedMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxxUnorderedMap.cpp; path = source/DataFormatters/LibCxxUnorderedMap.cpp; sourceTree = "<group>"; };
94EBAC8313D9EE26009BA64E /* PythonPointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonPointer.h; path = include/lldb/Utility/PythonPointer.h; sourceTree = "<group>"; };
94ED54A119C8A822007BE2EA /* ThreadSafeDenseMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSafeDenseMap.h; path = include/lldb/Core/ThreadSafeDenseMap.h; sourceTree = "<group>"; };
9A22A15E135E30370024DDC3 /* EmulateInstructionARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmulateInstructionARM.h; sourceTree = "<group>"; };
9A22A15F135E30370024DDC3 /* EmulationStateARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulationStateARM.cpp; sourceTree = "<group>"; };
9A22A160135E30370024DDC3 /* EmulationStateARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmulationStateARM.h; sourceTree = "<group>"; };
- 9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreterNone.h; path = include/lldb/Interpreter/ScriptInterpreterNone.h; sourceTree = "<group>"; };
- 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreterNone.cpp; path = source/Interpreter/ScriptInterpreterNone.cpp; sourceTree = "<group>"; };
9A357582116CFDEE00E8ED2F /* SBValueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValueList.h; path = include/lldb/API/SBValueList.h; sourceTree = "<group>"; };
9A35758D116CFE0F00E8ED2F /* SBValueList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValueList.cpp; path = source/API/SBValueList.cpp; sourceTree = "<group>"; };
9A35765E116E76A700E8ED2F /* StringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringList.h; path = include/lldb/Core/StringList.h; sourceTree = "<group>"; };
266DFE9013FD64D200D0C574 /* OperatingSystem */,
26C5577E132575B6008FD8FE /* Platform */,
260C898A10F57C5600BB2B04 /* Process */,
+ 3FBA69DA1B6066D20008F44A /* ScriptInterpreter */,
AF11CB34182CA85A00D9B618 /* SystemRuntime */,
260C89B110F57C5600BB2B04 /* SymbolFile */,
260C89E010F57C5600BB2B04 /* SymbolVendor */,
B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */,
26ACEC2715E077AE00E94760 /* Property.h */,
2640E19E15DC78FD00F23B50 /* Property.cpp */,
- 94EA1D5A15E6C99B00D4171A /* PythonDataObjects.h */,
- 94EA1D5B15E6C9B400D4171A /* PythonDataObjects.cpp */,
26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */,
9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */,
- 9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */,
- 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */,
- 26BC7DE610F1B7F900F91463 /* ScriptInterpreterPython.h */,
- 26BC7F0C10F1B8DD00F91463 /* ScriptInterpreterPython.cpp */,
);
name = Interpreter;
sourceTree = "<group>";
name = Initialization;
sourceTree = "<group>";
};
+ 3FBA69DA1B6066D20008F44A /* ScriptInterpreter */ = {
+ isa = PBXGroup;
+ children = (
+ 3FBA69DC1B6066E90008F44A /* None */,
+ 3FBA69DB1B6066E40008F44A /* Python */,
+ );
+ name = ScriptInterpreter;
+ sourceTree = "<group>";
+ };
+ 3FBA69DB1B6066E40008F44A /* Python */ = {
+ isa = PBXGroup;
+ children = (
+ 3FBA69E21B60672A0008F44A /* lldb-python.h */,
+ 3FBA69E31B60672A0008F44A /* PythonDataObjects.cpp */,
+ 3FBA69E41B60672A0008F44A /* PythonDataObjects.h */,
+ 3FBA69E51B60672A0008F44A /* ScriptInterpreterPython.cpp */,
+ 3FBA69E61B60672A0008F44A /* ScriptInterpreterPython.h */,
+ );
+ name = Python;
+ sourceTree = "<group>";
+ };
+ 3FBA69DC1B6066E90008F44A /* None */ = {
+ isa = PBXGroup;
+ children = (
+ 3FBA69DD1B6067020008F44A /* ScriptInterpreterNone.cpp */,
+ 3FBA69DE1B6067020008F44A /* ScriptInterpreterNone.h */,
+ );
+ name = None;
+ sourceTree = "<group>";
+ };
3FDFDDC4199D37BE009756A7 /* posix */ = {
isa = PBXGroup;
children = (
26474CBE18D0CB2D0073DEBA /* RegisterContextMach_i386.cpp in Sources */,
2689008613353E2200698AC0 /* Options.cpp in Sources */,
2689008713353E2200698AC0 /* ScriptInterpreter.cpp in Sources */,
- 2689008813353E2200698AC0 /* ScriptInterpreterNone.cpp in Sources */,
- 2689008913353E2200698AC0 /* ScriptInterpreterPython.cpp in Sources */,
260A63191861009E00FECF8E /* IOHandler.cpp in Sources */,
2689008D13353E4200698AC0 /* DynamicLoaderMacOSXDYLD.cpp in Sources */,
2689008E13353E4200698AC0 /* DynamicLoaderStatic.cpp in Sources */,
26A7A035135E6E4200FB369E /* OptionValue.cpp in Sources */,
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */,
AFDFDFD119E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp in Sources */,
+ 3FBA69ED1B60674B0008F44A /* ScriptInterpreterPython.cpp in Sources */,
9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */,
9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */,
AF1D88691B575E8D003CB899 /* ValueObjectConstResultCast.cpp in Sources */,
94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */,
267A47FF1B1411D90021A5BC /* NativeWatchpointList.cpp in Sources */,
26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */,
+ 3FBA69E11B6067120008F44A /* ScriptInterpreterNone.cpp in Sources */,
94EA27CE17DE91750070F505 /* LibCxxUnorderedMap.cpp in Sources */,
266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */,
26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */,
255EFF761AFABA950069F277 /* LockFilePosix.cpp in Sources */,
+ 3FBA69EC1B6067430008F44A /* PythonDataObjects.cpp in Sources */,
26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */,
94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */,
3FDFED2819BA6D96009756A7 /* HostThread.cpp in Sources */,
26491E3E15E1DB9F00CBFFC2 /* OptionValueRegex.cpp in Sources */,
2697A39315E404B1003E682C /* OptionValueArch.cpp in Sources */,
6D55B2921A8A806200A70529 /* GDBRemoteCommunicationServerPlatform.cpp in Sources */,
- 94EA1D5C15E6C9B400D4171A /* PythonDataObjects.cpp in Sources */,
94D6A0AC16CEB55F00833B6E /* NSSet.cpp in Sources */,
94CD704E16F8DDEA00CF1E42 /* Cocoa.cpp in Sources */,
2698699B15E6CBD0002415FF /* OperatingSystemPython.cpp in Sources */,
${LLDB_VERS_GENERATED_FILE}
)
+# This should not be part of LLDBDependencies.cmake, because we don't
+# want every single library taking a dependency on the script interpreters.
+target_link_libraries(liblldb PRIVATE
+ lldbPluginScriptInterpreterNone
+ lldbPluginScriptInterpreterPython
+ )
+
set_target_properties(liblldb
PROPERTIES
VERSION ${LLDB_VERSION}
//===----------------------------------------------------------------------===//
#include "lldb/lldb-types.h"
-#include "lldb/Core/SourceManager.h"
+
#include "lldb/Core/Listener.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
//
//===----------------------------------------------------------------------===//
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
+
#include "lldb/API/SystemInitializerFull.h"
+#include "lldb/API/SBCommandInterpreter.h"
+
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
+#endif
+
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "Plugins/Process/Windows/ProcessWindows.h"
#endif
-#if !defined(LLDB_DISABLE_PYTHON)
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#endif
-
#include "llvm/Support/TargetSelect.h"
#include <string>
void
SystemInitializerFull::Initialize()
{
+ SystemInitializerCommon::Initialize();
+
+#if !defined(LLDB_DISABLE_PYTHON)
InitializeSWIG();
- SystemInitializerCommon::Initialize();
+ // ScriptInterpreterPython::Initialize() depends on things like HostInfo being initialized
+ // so it can compute the python directory etc, so we need to do this after
+ // SystemInitializerCommon::Initialize().
+ ScriptInterpreterNone::Initialize();
+ ScriptInterpreterPython::Initialize();
+#endif
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
-
-void SystemInitializerFull::TerminateSWIG()
-{
-
-}
return NULL;
}
+#pragma mark ScriptInterpreter
+
+struct ScriptInterpreterInstance
+{
+ ScriptInterpreterInstance()
+ : name()
+ , language(lldb::eScriptLanguageNone)
+ , description()
+ , create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ lldb::ScriptLanguage language;
+ std::string description;
+ ScriptInterpreterCreateInstance create_callback;
+};
+
+typedef std::vector<ScriptInterpreterInstance> ScriptInterpreterInstances;
+
+static Mutex &
+GetScriptInterpreterMutex()
+{
+ static Mutex g_instances_mutex(Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static ScriptInterpreterInstances &
+GetScriptInterpreterInstances()
+{
+ static ScriptInterpreterInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_language,
+ ScriptInterpreterCreateInstance create_callback)
+{
+ if (!create_callback)
+ return false;
+ ScriptInterpreterInstance instance;
+ assert((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ instance.language = script_language;
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ GetScriptInterpreterInstances().push_back(instance);
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin(ScriptInterpreterCreateInstance create_callback)
+{
+ if (!create_callback)
+ return false;
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+
+ ScriptInterpreterInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++pos)
+ {
+ if (pos->create_callback != create_callback)
+ continue;
+
+ instances.erase(pos);
+ return true;
+ }
+ return false;
+}
+
+ScriptInterpreterCreateInstance
+PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx)
+{
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return nullptr;
+}
+
+lldb::ScriptInterpreterSP
+PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, CommandInterpreter &interpreter)
+{
+ Mutex::Locker locker(GetScriptInterpreterMutex());
+ ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
+
+ ScriptInterpreterInstances::iterator pos, end = instances.end();
+ ScriptInterpreterCreateInstance none_instance = nullptr;
+ for (pos = instances.begin(); pos != end; ++pos)
+ {
+ if (pos->language == lldb::eScriptLanguageNone)
+ none_instance = pos->create_callback;
+
+ if (script_lang == pos->language)
+ return pos->create_callback(interpreter);
+ }
+
+ // If we didn't find one, return the ScriptInterpreter for the null language.
+ assert(none_instance != nullptr);
+ return none_instance(interpreter);
+}
+
#pragma mark SymbolFile
struct SymbolFileInstance
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/macosx/HostInfoMacOSX.h"
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
+
#include "lldb/Core/Log.h"
#include "lldb/Host/posix/HostInfoPosix.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
ProcessWindowsLog::Initialize();
#endif
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializePrivate();
OperatingSystemPython::Initialize();
#endif
}
OptionGroupWatchpoint.cpp
Options.cpp
Property.cpp
- PythonDataObjects.cpp
ScriptInterpreter.cpp
- ScriptInterpreterNone.cpp
- ScriptInterpreterPython.cpp
)
#include "../Commands/CommandObjectWatchpoint.h"
#include "../Commands/CommandObjectLanguage.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
-#include "lldb/Interpreter/ScriptInterpreterNone.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Target/Process.h"
return class_name;
}
-CommandInterpreter::CommandInterpreter
-(
- Debugger &debugger,
- ScriptLanguage script_language,
- bool synchronous_execution
-) :
- Broadcaster (&debugger, CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
- Properties(OptionValuePropertiesSP(new OptionValueProperties(ConstString("interpreter")))),
- IOHandlerDelegate (IOHandlerDelegate::Completion::LLDBCommand),
- m_debugger (debugger),
- m_synchronous_execution (synchronous_execution),
- m_skip_lldbinit_files (false),
- m_skip_app_init_files (false),
- m_script_interpreter_ap (),
- m_command_io_handler_sp (),
- m_comment_char ('#'),
- m_batch_command_mode (false),
- m_truncation_warning(eNoTruncation),
- m_command_source_depth (0),
- m_num_errors(0),
- m_quit_requested(false),
- m_stopped_for_crash(false)
-
+CommandInterpreter::CommandInterpreter(Debugger &debugger, ScriptLanguage script_language, bool synchronous_execution)
+ : Broadcaster(&debugger, CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
+ Properties(OptionValuePropertiesSP(new OptionValueProperties(ConstString("interpreter")))),
+ IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
+ m_debugger(debugger),
+ m_synchronous_execution(synchronous_execution),
+ m_skip_lldbinit_files(false),
+ m_skip_app_init_files(false),
+ m_script_interpreter_sp(),
+ m_command_io_handler_sp(),
+ m_comment_char('#'),
+ m_batch_command_mode(false),
+ m_truncation_warning(eNoTruncation),
+ m_command_source_depth(0),
+ m_num_errors(0),
+ m_quit_requested(false),
+ m_stopped_for_crash(false)
{
debugger.SetScriptLanguage (script_language);
SetEventName (eBroadcastBitThreadShouldExit, "thread-should-exit");
CommandInterpreter::Clear()
{
m_command_io_handler_sp.reset();
-
- if (m_script_interpreter_ap)
- m_script_interpreter_ap->Clear();
+
+ if (m_script_interpreter_sp)
+ m_script_interpreter_sp->Clear();
}
const char *
}
ScriptInterpreter *
-CommandInterpreter::GetScriptInterpreter (bool can_create)
+CommandInterpreter::GetScriptInterpreter(bool can_create)
{
- if (m_script_interpreter_ap.get() != nullptr)
- return m_script_interpreter_ap.get();
-
+ if (m_script_interpreter_sp)
+ return m_script_interpreter_sp.get();
+
if (!can_create)
return nullptr;
-
- // <rdar://problem/11751427>
- // we need to protect the initialization of the script interpreter
- // otherwise we could end up with two threads both trying to create
- // their instance of it, and for some languages (e.g. Python)
- // this is a bulletproof recipe for disaster!
- // this needs to be a function-level static because multiple Debugger instances living in the same process
- // still need to be isolated and not try to initialize Python concurrently
- static Mutex g_interpreter_mutex(Mutex::eMutexTypeRecursive);
- Mutex::Locker interpreter_lock(g_interpreter_mutex);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("Initializing the ScriptInterpreter now\n");
-
+
lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
- switch (script_lang)
- {
- case eScriptLanguagePython:
-#ifndef LLDB_DISABLE_PYTHON
- m_script_interpreter_ap.reset (new ScriptInterpreterPython (*this));
- break;
-#else
- // Fall through to the None case when python is disabled
-#endif
- case eScriptLanguageNone:
- m_script_interpreter_ap.reset (new ScriptInterpreterNone (*this));
- break;
- };
-
- return m_script_interpreter_ap.get();
+ m_script_interpreter_sp = PluginManager::GetScriptInterpreterForLanguage(script_lang, *this);
+ return m_script_interpreter_sp.get();
}
-
-
bool
CommandInterpreter::GetSynchronous ()
{
+++ /dev/null
-//===-- ScriptInterpreterNone.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/ScriptInterpreterNone.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-ScriptInterpreterNone::ScriptInterpreterNone (CommandInterpreter &interpreter) :
- ScriptInterpreter (interpreter, eScriptLanguageNone)
-{
-}
-
-ScriptInterpreterNone::~ScriptInterpreterNone ()
-{
-}
-
-bool
-ScriptInterpreterNone::ExecuteOneLine (const char *command, CommandReturnObject *, const ExecuteScriptOptions&)
-{
- m_interpreter.GetDebugger().GetErrorFile()->PutCString ("error: there is no embedded script interpreter in this mode.\n");
- return false;
-}
-
-void
-ScriptInterpreterNone::ExecuteInterpreterLoop ()
-{
- m_interpreter.GetDebugger().GetErrorFile()->PutCString ("error: there is no embedded script interpreter in this mode.\n");
-}
-
-
add_subdirectory(OperatingSystem)
add_subdirectory(Platform)
add_subdirectory(Process)
+add_subdirectory(ScriptInterpreter)
add_subdirectory(SymbolFile)
add_subdirectory(SystemRuntime)
add_subdirectory(SymbolVendor)
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
-#ifndef LLDB_DISABLE_PYTHON
-#include "lldb/Interpreter/PythonDataObjects.h"
-#endif
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Utils.h"
--- /dev/null
+add_subdirectory(None)
+add_subdirectory(Python)
--- /dev/null
+add_lldb_library(lldbPluginScriptInterpreterNone
+ ScriptInterpreterNone.cpp
+ )
\ No newline at end of file
--- /dev/null
+//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ScriptInterpreterNone.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StringList.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+
+#include <mutex>
+
+using namespace lldb;
+using namespace lldb_private;
+
+ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
+ : ScriptInterpreter(interpreter, eScriptLanguageNone)
+{
+}
+
+ScriptInterpreterNone::~ScriptInterpreterNone()
+{
+}
+
+bool
+ScriptInterpreterNone::ExecuteOneLine(const char *command, CommandReturnObject *, const ExecuteScriptOptions &)
+{
+ m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ "error: there is no embedded script interpreter in this mode.\n");
+ return false;
+}
+
+void
+ScriptInterpreterNone::ExecuteInterpreterLoop()
+{
+ m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ "error: there is no embedded script interpreter in this mode.\n");
+}
+
+void
+ScriptInterpreterNone::Initialize()
+{
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []()
+ {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(),
+ lldb::eScriptLanguageNone, CreateInstance);
+ });
+}
+
+void
+ScriptInterpreterNone::Terminate()
+{
+}
+
+lldb::ScriptInterpreterSP
+ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter)
+{
+ return std::make_shared<ScriptInterpreterNone>(interpreter);
+}
+
+lldb_private::ConstString
+ScriptInterpreterNone::GetPluginNameStatic()
+{
+ static ConstString g_name("script-none");
+ return g_name;
+}
+
+const char *
+ScriptInterpreterNone::GetPluginDescriptionStatic()
+{
+ return "Null script interpreter";
+}
+
+lldb_private::ConstString
+ScriptInterpreterNone::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ScriptInterpreterNone::GetPluginVersion()
+{
+ return 1;
+}
--- /dev/null
+//===-- ScriptInterpreterNone.h ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ScriptInterpreterNone_h_
+#define liblldb_ScriptInterpreterNone_h_
+
+#include "lldb/Interpreter/ScriptInterpreter.h"
+
+namespace lldb_private
+{
+
+class ScriptInterpreterNone : public ScriptInterpreter
+{
+ public:
+ ScriptInterpreterNone(CommandInterpreter &interpreter);
+
+ ~ScriptInterpreterNone();
+
+ bool
+ ExecuteOneLine(const char *command, CommandReturnObject *result,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions());
+
+ void
+ ExecuteInterpreterLoop();
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb::ScriptInterpreterSP
+ CreateInstance(CommandInterpreter &interpreter);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ virtual lldb_private::ConstString
+ GetPluginName();
+
+ virtual uint32_t
+ GetPluginVersion();
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_ScriptInterpreterNone_h_
--- /dev/null
+add_lldb_library(lldbPluginScriptInterpreterPython
+ PythonDataObjects.cpp
+ ScriptInterpreterPython.cpp
+ )
//
//===----------------------------------------------------------------------===//
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included here.
#ifdef LLDB_DISABLE_PYTHON
// Python is disabled in this build
#else
-#include "lldb/lldb-python.h"
-
-#include <stdio.h>
+#include "lldb-python.h"
+#include "PythonDataObjects.h"
+#include "ScriptInterpreterPython.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/File.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
+
+#include <stdio.h>
using namespace lldb_private;
using namespace lldb;
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PythonDataObjects_h_
-#define liblldb_PythonDataObjects_h_
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
// C Includes
// C++ Includes
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/Flags.h"
#include "lldb/Interpreter/OptionValue.h"
-#include "lldb/lldb-python.h"
namespace lldb_private {
class PythonString;
} // namespace lldb_private
-#endif // liblldb_PythonDataObjects_h_
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
//
//===----------------------------------------------------------------------===//
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included here.
#ifdef LLDB_DISABLE_PYTHON
// Python is disabled in this build
#else
-#include "lldb/lldb-python.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb-python.h"
+#include "ScriptInterpreterPython.h"
+#include "PythonDataObjects.h"
#include <stdlib.h>
#include <stdio.h>
+#include <mutex>
#include <string>
#include "lldb/API/SBValue.h"
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
m_lock_count (0),
m_command_thread_state (nullptr)
{
- assert(g_initialized && "ScriptInterpreterPython created but initialize has not been called!");
+ assert(g_initialized && "ScriptInterpreterPython created but InitializePrivate has not been called!");
m_dictionary_name.append("_dict");
StreamString run_string;
}
void
+ScriptInterpreterPython::Initialize()
+{
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []()
+ {
+ InitializePrivate();
+
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(),
+ lldb::eScriptLanguagePython,
+ CreateInstance);
+ });
+}
+
+void
+ScriptInterpreterPython::Terminate()
+{
+
+}
+
+lldb::ScriptInterpreterSP
+ScriptInterpreterPython::CreateInstance(CommandInterpreter &interpreter)
+{
+ return std::make_shared<ScriptInterpreterPython>(interpreter);
+}
+
+lldb_private::ConstString
+ScriptInterpreterPython::GetPluginNameStatic()
+{
+ static ConstString g_name("script-python");
+ return g_name;
+}
+
+const char *
+ScriptInterpreterPython::GetPluginDescriptionStatic()
+{
+ return "Embedded Python interpreter";
+}
+
+lldb_private::ConstString
+ScriptInterpreterPython::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ScriptInterpreterPython::GetPluginVersion()
+{
+ return 1;
+}
+
+void
ScriptInterpreterPython::IOHandlerActivated (IOHandler &io_handler)
{
const char *instructions = nullptr;
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ScriptInterpreterPython_h_
-#define liblldb_ScriptInterpreterPython_h_
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
#ifdef LLDB_DISABLE_PYTHON
#else
-#include "lldb/lldb-python.h"
#include "lldb/lldb-private.h"
+#include "PythonDataObjects.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/PythonDataObjects.h"
#include "lldb/Host/Terminal.h"
class IOHandlerPythonInterpreter;
void
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb::ScriptInterpreterSP
+ CreateInstance(CommandInterpreter &interpreter);
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ virtual lldb_private::ConstString
+ GetPluginName();
+
+ virtual uint32_t
+ GetPluginVersion();
+
protected:
bool
#endif // #ifdef LLDB_DISABLE_PYTHON
-#endif // #ifndef liblldb_ScriptInterpreterPython_h_
+#endif // #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
--- /dev/null
+//===-- lldb-python.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
+
+// Python.h needs to be included before any system headers in order to avoid redefinition of macros
+
+#ifdef LLDB_DISABLE_PYTHON
+// Python is disabled in this build
+#else
+#if defined(__linux__)
+// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
+// may be different from the value that Python defines it to be which results
+// in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
+// holds for _XOPEN_SOURCE.
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+#endif
+
+// Include python for non windows machines
+#include <Python.h>
+#endif // LLDB_DISABLE_PYTHON
+
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
${ARGN}
)
- if (MSVC)
- target_link_libraries(${test_name} ${PYTHON_LIBRARY})
- endif()
-
lldb_link_common_libs(${test_name} EXE)
target_link_libraries(${test_name} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})