2010-06-09 00:52:24 +08:00
|
|
|
/*
|
|
|
|
lldb.swig
|
|
|
|
|
|
|
|
This is the input file for SWIG, to create the appropriate C++ wrappers and
|
|
|
|
functions for various scripting languages, to enable them to call the
|
|
|
|
liblldb Script Bridge functions.
|
|
|
|
*/
|
|
|
|
|
2011-07-01 05:29:50 +08:00
|
|
|
/* Define our module docstring. */
|
|
|
|
%define DOCSTRING
|
|
|
|
"The lldb module contains the public APIs for Python binding.
|
|
|
|
|
2013-11-05 19:00:35 +08:00
|
|
|
Some of the important classes are described here:
|
2011-07-01 05:29:50 +08:00
|
|
|
|
2021-01-15 21:43:26 +08:00
|
|
|
* :py:class:`SBTarget`: Represents the target program running under the debugger.
|
|
|
|
* :py:class:`SBProcess`: Represents the process associated with the target program.
|
|
|
|
* :py:class:`SBThread`: Represents a thread of execution. :py:class:`SBProcess` contains SBThreads.
|
|
|
|
* :py:class:`SBFrame`: Represents one of the stack frames associated with a thread. :py:class:`SBThread`
|
|
|
|
contains SBFrame(s).
|
|
|
|
* :py:class:`SBSymbolContext`: A container that stores various debugger related info.
|
|
|
|
* :py:class:`SBValue`: Represents the value of a variable, a register, or an expression.
|
|
|
|
* :py:class:`SBModule`: Represents an executable image and its associated object and symbol
|
|
|
|
files. :py:class:`SBTarget` contains SBModule.
|
|
|
|
* :py:class:`SBBreakpoint`: Represents a logical breakpoint and its associated settings.
|
|
|
|
:py:class:`SBTarget` contains SBBreakpoints.
|
|
|
|
* :py:class:`SBSymbol`: Represents the symbol possibly associated with a stack frame.
|
|
|
|
* :py:class:`SBCompileUnit`: Represents a compilation unit, or compiled source file.
|
|
|
|
* :py:class:`SBFunction`: Represents a generic function, which can be inlined or not.
|
|
|
|
* :py:class:`SBBlock`: Represents a lexical block. :py:class:`SBFunction` contains SBBlocks.
|
|
|
|
* :py:class:`SBLineEntry`: Specifies an association with a contiguous range of instructions
|
2021-01-20 01:53:52 +08:00
|
|
|
and a source file location. :py:class:`SBCompileUnit` contains SBLineEntry.
|
|
|
|
|
|
|
|
The different enums in the `lldb` module are described in :doc:`python_api_enums`.
|
|
|
|
|
|
|
|
"
|
2011-07-01 05:29:50 +08:00
|
|
|
%enddef
|
|
|
|
|
2017-05-23 18:55:17 +08:00
|
|
|
/*
|
|
|
|
Since version 3.0.9, swig's logic for importing the native module has changed in
|
|
|
|
a way that is incompatible with our usage of the python module as __init__.py
|
|
|
|
(See swig bug #769). Fortunately, since version 3.0.11, swig provides a way for
|
|
|
|
us to override the module import logic to suit our needs. This does that.
|
|
|
|
|
|
|
|
Older swig versions will simply ignore this setting.
|
|
|
|
*/
|
|
|
|
%define MODULEIMPORT
|
2017-06-15 19:23:22 +08:00
|
|
|
"try:
|
2018-10-14 15:24:56 +08:00
|
|
|
# Try an absolute import first. If we're being loaded from lldb,
|
|
|
|
# _lldb should be a built-in module.
|
|
|
|
import $module
|
2017-06-15 19:23:22 +08:00
|
|
|
except ImportError:
|
2018-10-14 15:24:56 +08:00
|
|
|
# Relative import should work if we are being loaded by Python.
|
|
|
|
from . import $module"
|
2017-05-23 18:55:17 +08:00
|
|
|
%enddef
|
|
|
|
// These versions will not generate working python modules, so error out early.
|
|
|
|
#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011
|
|
|
|
#error Swig versions 3.0.9 and 3.0.10 are incompatible with lldb.
|
|
|
|
#endif
|
|
|
|
|
2011-07-17 05:27:36 +08:00
|
|
|
// The name of the module to be created.
|
2017-05-23 18:55:17 +08:00
|
|
|
%module(docstring=DOCSTRING, moduleimport=MODULEIMPORT) lldb
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-07-17 05:27:36 +08:00
|
|
|
// Parameter types will be used in the autodoc string.
|
|
|
|
%feature("autodoc", "1");
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-01-09 08:13:03 +08:00
|
|
|
%define ARRAYHELPER(type,name)
|
|
|
|
%inline %{
|
|
|
|
type *new_ ## name (int nitems) {
|
|
|
|
return (type *) malloc(sizeof(type)*nitems);
|
|
|
|
}
|
|
|
|
void delete_ ## name(type *t) {
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
type name ## _get(type *t, int index) {
|
|
|
|
return t[index];
|
|
|
|
}
|
|
|
|
void name ## _set(type *t, int index, type val) {
|
|
|
|
t[index] = val;
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
%enddef
|
|
|
|
|
2012-02-01 16:09:32 +08:00
|
|
|
%pythoncode%{
|
|
|
|
import uuid
|
|
|
|
import re
|
|
|
|
import os
|
2015-11-12 01:59:57 +08:00
|
|
|
|
|
|
|
import six
|
2012-02-01 16:09:32 +08:00
|
|
|
%}
|
2019-02-15 15:41:12 +08:00
|
|
|
|
|
|
|
// Include the version of swig that was used to generate this interface.
|
|
|
|
%define EMBED_VERSION(VERSION)
|
|
|
|
%pythoncode%{
|
|
|
|
# SWIG_VERSION is written as a single hex number, but the components of it are
|
|
|
|
# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not
|
|
|
|
# 3.0.18.
|
|
|
|
def _to_int(hex):
|
|
|
|
return hex // 0x10 % 0x10 * 10 + hex % 0x10
|
|
|
|
swig_version = (_to_int(VERSION // 0x10000), _to_int(VERSION // 0x100), _to_int(VERSION))
|
|
|
|
del _to_int
|
|
|
|
%}
|
|
|
|
%enddef
|
|
|
|
EMBED_VERSION(SWIG_VERSION)
|
|
|
|
|
2019-02-27 22:16:48 +08:00
|
|
|
%pythoncode%{
|
|
|
|
# ===================================
|
|
|
|
# Iterator for lldb container objects
|
|
|
|
# ===================================
|
|
|
|
def lldb_iter(obj, getsize, getelem):
|
|
|
|
"""A generator adaptor to support iteration for lldb container objects."""
|
|
|
|
size = getattr(obj, getsize)
|
|
|
|
elem = getattr(obj, getelem)
|
|
|
|
for i in range(size()):
|
|
|
|
yield elem(i)
|
|
|
|
%}
|
|
|
|
|
2020-01-09 05:34:55 +08:00
|
|
|
%include <std_string.i>
|
2020-08-13 06:47:57 +08:00
|
|
|
%include "python-typemaps.swig"
|
|
|
|
%include "macros.swig"
|
|
|
|
%include "headers.swig"
|
2011-01-14 12:54:56 +08:00
|
|
|
|
2012-08-09 08:53:54 +08:00
|
|
|
%{
|
2020-01-10 01:54:46 +08:00
|
|
|
#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
|
2020-01-09 23:57:59 +08:00
|
|
|
#include "../bindings/python/python-swigsafecast.swig"
|
2019-10-22 10:32:37 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::python;
|
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
%}
|
|
|
|
|
2020-08-13 06:47:57 +08:00
|
|
|
%include "interfaces.swig"
|
|
|
|
%include "python-extensions.swig"
|
|
|
|
%include "python-wrapper.swig"
|
2019-04-05 17:56:55 +08:00
|
|
|
|
|
|
|
%pythoncode%{
|
2020-04-09 06:34:13 +08:00
|
|
|
_initialize = True
|
|
|
|
try:
|
|
|
|
import lldbconfig
|
|
|
|
_initialize = lldbconfig.INITIALIZE
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2019-04-05 17:56:55 +08:00
|
|
|
debugger_unique_id = 0
|
2020-04-09 06:34:13 +08:00
|
|
|
if _initialize:
|
|
|
|
SBDebugger.Initialize()
|
2019-04-05 17:56:55 +08:00
|
|
|
debugger = None
|
2019-09-18 20:58:52 +08:00
|
|
|
target = None
|
|
|
|
process = None
|
|
|
|
thread = None
|
|
|
|
frame = None
|
2019-04-05 17:56:55 +08:00
|
|
|
%}
|