1be691f3bSpatrick/* 2be691f3bSpatrick lldb.swig 3be691f3bSpatrick 4be691f3bSpatrick This is the input file for SWIG, to create the appropriate C++ wrappers and 5be691f3bSpatrick functions for various scripting languages, to enable them to call the 6be691f3bSpatrick liblldb Script Bridge functions. 7be691f3bSpatrick*/ 8be691f3bSpatrick 9be691f3bSpatrick/* Define our module docstring. */ 10be691f3bSpatrick%define DOCSTRING 11be691f3bSpatrick"The lldb module contains the public APIs for Python binding. 12be691f3bSpatrick 13be691f3bSpatrickSome of the important classes are described here: 14be691f3bSpatrick 15be691f3bSpatrick* :py:class:`SBTarget`: Represents the target program running under the debugger. 16be691f3bSpatrick* :py:class:`SBProcess`: Represents the process associated with the target program. 17be691f3bSpatrick* :py:class:`SBThread`: Represents a thread of execution. :py:class:`SBProcess` contains SBThreads. 18be691f3bSpatrick* :py:class:`SBFrame`: Represents one of the stack frames associated with a thread. :py:class:`SBThread` 19be691f3bSpatrick contains SBFrame(s). 20be691f3bSpatrick* :py:class:`SBSymbolContext`: A container that stores various debugger related info. 21be691f3bSpatrick* :py:class:`SBValue`: Represents the value of a variable, a register, or an expression. 22be691f3bSpatrick* :py:class:`SBModule`: Represents an executable image and its associated object and symbol 23be691f3bSpatrick files. :py:class:`SBTarget` contains SBModule. 24be691f3bSpatrick* :py:class:`SBBreakpoint`: Represents a logical breakpoint and its associated settings. 25be691f3bSpatrick :py:class:`SBTarget` contains SBBreakpoints. 26be691f3bSpatrick* :py:class:`SBSymbol`: Represents the symbol possibly associated with a stack frame. 27be691f3bSpatrick* :py:class:`SBCompileUnit`: Represents a compilation unit, or compiled source file. 28be691f3bSpatrick* :py:class:`SBFunction`: Represents a generic function, which can be inlined or not. 29be691f3bSpatrick* :py:class:`SBBlock`: Represents a lexical block. :py:class:`SBFunction` contains SBBlocks. 30be691f3bSpatrick* :py:class:`SBLineEntry`: Specifies an association with a contiguous range of instructions 31be691f3bSpatrick and a source file location. :py:class:`SBCompileUnit` contains SBLineEntry. 32be691f3bSpatrick 33be691f3bSpatrickThe different enums in the `lldb` module are described in :doc:`python_api_enums`. 34be691f3bSpatrick 35be691f3bSpatrick" 36be691f3bSpatrick%enddef 37be691f3bSpatrick 38be691f3bSpatrick/* 39be691f3bSpatrickSince version 3.0.9, swig's logic for importing the native module has changed in 40be691f3bSpatricka way that is incompatible with our usage of the python module as __init__.py 41be691f3bSpatrick(See swig bug #769). Fortunately, since version 3.0.11, swig provides a way for 42be691f3bSpatrickus to override the module import logic to suit our needs. This does that. 43be691f3bSpatrick 44be691f3bSpatrickOlder swig versions will simply ignore this setting. 45be691f3bSpatrick*/ 46be691f3bSpatrick%define MODULEIMPORT 47be691f3bSpatrick"try: 48be691f3bSpatrick # Try an absolute import first. If we're being loaded from lldb, 49be691f3bSpatrick # _lldb should be a built-in module. 50be691f3bSpatrick import $module 51be691f3bSpatrickexcept ImportError: 52be691f3bSpatrick # Relative import should work if we are being loaded by Python. 53be691f3bSpatrick from . import $module" 54be691f3bSpatrick%enddef 55be691f3bSpatrick// These versions will not generate working python modules, so error out early. 56be691f3bSpatrick#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011 57be691f3bSpatrick#error Swig versions 3.0.9 and 3.0.10 are incompatible with lldb. 58be691f3bSpatrick#endif 59be691f3bSpatrick 60be691f3bSpatrick// The name of the module to be created. 61be691f3bSpatrick%module(docstring=DOCSTRING, moduleimport=MODULEIMPORT) lldb 62be691f3bSpatrick 63be691f3bSpatrick// Parameter types will be used in the autodoc string. 64be691f3bSpatrick%feature("autodoc", "1"); 65be691f3bSpatrick 66be691f3bSpatrick%define ARRAYHELPER(type,name) 67be691f3bSpatrick%inline %{ 68be691f3bSpatricktype *new_ ## name (int nitems) { 69be691f3bSpatrick return (type *) malloc(sizeof(type)*nitems); 70be691f3bSpatrick} 71be691f3bSpatrickvoid delete_ ## name(type *t) { 72be691f3bSpatrick free(t); 73be691f3bSpatrick} 74be691f3bSpatricktype name ## _get(type *t, int index) { 75be691f3bSpatrick return t[index]; 76be691f3bSpatrick} 77be691f3bSpatrickvoid name ## _set(type *t, int index, type val) { 78be691f3bSpatrick t[index] = val; 79be691f3bSpatrick} 80be691f3bSpatrick%} 81be691f3bSpatrick%enddef 82be691f3bSpatrick 83be691f3bSpatrick%pythoncode%{ 84be691f3bSpatrickimport uuid 85be691f3bSpatrickimport re 86be691f3bSpatrickimport os 87be691f3bSpatrick%} 88be691f3bSpatrick 89be691f3bSpatrick// Include the version of swig that was used to generate this interface. 90be691f3bSpatrick%define EMBED_VERSION(VERSION) 91be691f3bSpatrick%pythoncode%{ 92be691f3bSpatrick# SWIG_VERSION is written as a single hex number, but the components of it are 93be691f3bSpatrick# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not 94be691f3bSpatrick# 3.0.18. 95be691f3bSpatrickdef _to_int(hex): 96be691f3bSpatrick return hex // 0x10 % 0x10 * 10 + hex % 0x10 97be691f3bSpatrickswig_version = (_to_int(VERSION // 0x10000), _to_int(VERSION // 0x100), _to_int(VERSION)) 98be691f3bSpatrickdel _to_int 99be691f3bSpatrick%} 100be691f3bSpatrick%enddef 101be691f3bSpatrickEMBED_VERSION(SWIG_VERSION) 102be691f3bSpatrick 103be691f3bSpatrick%pythoncode%{ 104be691f3bSpatrick# =================================== 105be691f3bSpatrick# Iterator for lldb container objects 106be691f3bSpatrick# =================================== 107be691f3bSpatrickdef lldb_iter(obj, getsize, getelem): 108be691f3bSpatrick """A generator adaptor to support iteration for lldb container objects.""" 109be691f3bSpatrick size = getattr(obj, getsize) 110be691f3bSpatrick elem = getattr(obj, getelem) 111be691f3bSpatrick for i in range(size()): 112be691f3bSpatrick yield elem(i) 113be691f3bSpatrick%} 114be691f3bSpatrick 115be691f3bSpatrick%include <std_string.i> 116be691f3bSpatrick%include "python-typemaps.swig" 117be691f3bSpatrick%include "macros.swig" 118be691f3bSpatrick%include "headers.swig" 119be691f3bSpatrick 120be691f3bSpatrick%{ 121be691f3bSpatrick#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h" 122*f6aab3d8Srobert#include "../source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h" 123be691f3bSpatrick#include "../bindings/python/python-swigsafecast.swig" 124be691f3bSpatrickusing namespace lldb_private; 125be691f3bSpatrickusing namespace lldb_private::python; 126be691f3bSpatrickusing namespace lldb; 127be691f3bSpatrick%} 128be691f3bSpatrick 129be691f3bSpatrick%include "interfaces.swig" 130be691f3bSpatrick%include "python-extensions.swig" 131be691f3bSpatrick%include "python-wrapper.swig" 132be691f3bSpatrick 133be691f3bSpatrick%pythoncode%{ 134be691f3bSpatrickdebugger_unique_id = 0 135be691f3bSpatrickSBDebugger.Initialize() 136be691f3bSpatrickdebugger = None 137be691f3bSpatricktarget = None 138be691f3bSpatrickprocess = None 139be691f3bSpatrickthread = None 140be691f3bSpatrickframe = None 141be691f3bSpatrick%} 142