brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 3d2caa6 Raw
131 lines · plain
1/*2   lldb.swig3 4   This is the input file for SWIG, to create the appropriate C++ wrappers and5   functions for various scripting languages, to enable them to call the6   liblldb Script Bridge functions.7*/8 9/* Define our module docstring. */10%define DOCSTRING11"The lldb module contains the public APIs for Python binding.12 13Some of the important classes are described here:14 15* :py:class:`SBTarget`: Represents the target program running under the debugger.16* :py:class:`SBProcess`: Represents the process associated with the target program.17* :py:class:`SBThread`: Represents a thread of execution. :py:class:`SBProcess` contains SBThreads.18* :py:class:`SBFrame`: Represents one of the stack frames associated with a thread. :py:class:`SBThread`19  contains SBFrame(s).20* :py:class:`SBSymbolContext`: A container that stores various debugger related info.21* :py:class:`SBValue`: Represents the value of a variable, a register, or an expression.22* :py:class:`SBModule`: Represents an executable image and its associated object and symbol23  files.  :py:class:`SBTarget` contains SBModule.24* :py:class:`SBBreakpoint`: Represents a logical breakpoint and its associated settings.25  :py:class:`SBTarget` contains SBBreakpoints.26* :py:class:`SBSymbol`: Represents the symbol possibly associated with a stack frame.27* :py:class:`SBCompileUnit`: Represents a compilation unit, or compiled source file.28* :py:class:`SBFunction`: Represents a generic function, which can be inlined or not.29* :py:class:`SBBlock`: Represents a lexical block. :py:class:`SBFunction` contains SBBlocks.30* :py:class:`SBLineEntry`: Specifies an association with a contiguous range of instructions31  and a source file location. :py:class:`SBCompileUnit` contains SBLineEntry.32 33The different enums in the `lldb` module are described in :doc:`python_api_enums`.34 35"36%enddef37 38/*39Since version 3.0.9, swig's logic for importing the native module has changed in40a way that is incompatible with our usage of the python module as __init__.py41(See swig bug #769).  Fortunately, since version 3.0.11, swig provides a way for42us to override the module import logic to suit our needs. This does that.43 44Older swig versions will simply ignore this setting.45*/46%define MODULEIMPORT47"try:48    # Try an absolute import first.  If we're being loaded from lldb,49    # _lldb should be a built-in module.50    import $module51except ImportError:52    # Relative import should work if we are being loaded by Python.53    # The cpython module built by swig is pushed one level down into54    # the native submodule, because at this point the interpreter55    # is still constructing the lldb module itself.56    # Simply importing anything using `from . import` constitutes57    # a cyclic importing.58    from .native import $module"59%enddef60 61// The name of the module to be created.62%module(docstring=DOCSTRING, moduleimport=MODULEIMPORT) lldb63 64// Parameter types will be used in the autodoc string.65%feature("autodoc", "1");66 67// Include lldb-python first as it sets Py_LIMITED_API.68%begin %{69#include "../source/Plugins/ScriptInterpreter/Python/lldb-python.h"70%}71 72%pythoncode%{73import uuid74import re75import os76%}77 78// Include the version of swig that was used to generate this interface.79%define EMBED_VERSION(VERSION)80%pythoncode%{81# SWIG_VERSION is written as a single hex number, but the components of it are82# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not83# 3.0.18.84def _to_int(hex):85    return hex // 0x10 % 0x10 * 10 + hex % 0x1086swig_version = (_to_int(VERSION // 0x10000), _to_int(VERSION // 0x100), _to_int(VERSION))87del _to_int88%}89%enddef90EMBED_VERSION(SWIG_VERSION)91 92%pythoncode%{93# ===================================94# Iterator for lldb container objects95# ===================================96def lldb_iter(obj, getsize, getelem):97    """A generator adaptor to support iteration for lldb container objects."""98    size = getattr(obj, getsize)99    elem = getattr(obj, getelem)100    for i in range(size()):101        yield elem(i)102%}103 104%include <std_string.i>105%include "python-typemaps.swig"106%include "macros.swig"107%include "headers.swig"108 109%{110#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"111#include "../source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"112#include "../bindings/python/python-swigsafecast.swig"113using namespace lldb_private;114using namespace lldb_private::python;115using namespace lldb;116%}117 118%include "interfaces.swig"119%include "python-extensions.swig"120%include "python-wrapper.swig"121 122%pythoncode%{123debugger_unique_id = 0124SBDebugger.Initialize()125debugger = None126target = None127process = None128thread = None129frame = None130%}131