diff options
Diffstat (limited to 'lldb/scripts/Python')
51 files changed, 0 insertions, 10251 deletions
diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh deleted file mode 100755 index 76c538397240..000000000000 --- a/lldb/scripts/Python/build-swig-Python.sh +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh - -# build-swig-Python.sh - -# SRC_ROOT is the root of the lldb source tree. -# TARGET_DIR is where the lldb framework/shared library gets put. -# CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh shell script -# put the lldb.py file it was generated from running SWIG. -# PREFIX is the root directory used to determine where third-party modules -# for scripting languages should be installed. -# debug_flag (optional) determines whether or not this script outputs -# additional information when running. - -SRC_ROOT=$1 -TARGET_DIR=$2 -CONFIG_BUILD_DIR=$3 -PYTHON_INSTALL_DIR=$4 -debug_flag=$5 -SWIG=$6 - -swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp -swig_input_file=${SRC_ROOT}/scripts/lldb.swig -swig_python_extensions=${SRC_ROOT}/scripts/Python/python-extensions.swig -swig_python_wrapper=${SRC_ROOT}/scripts/Python/python-wrapper.swig -swig_python_typemaps=${SRC_ROOT}/scripts/Python/python-typemaps.swig - -if [ "x$SDKROOT" = "x" ] ; then - -if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] -then - Debug=1 -else - Debug=0 -fi - -# If this project is being built with LLDB_DISABLE_PYTHON defined, -# don't bother generating Python swig bindings -- we don't have -# Python available. - -if echo $GCC_PREPROCESSOR_DEFINITIONS | grep LLDB_DISABLE_PYTHON -then - echo "" > "${swig_output_file}" - exit 0 -fi - -HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\ -" ${SRC_ROOT}/include/lldb/lldb-defines.h"\ -" ${SRC_ROOT}/include/lldb/lldb-enumerations.h"\ -" ${SRC_ROOT}/include/lldb/lldb-forward.h"\ -" ${SRC_ROOT}/include/lldb/lldb-forward-rtti.h"\ -" ${SRC_ROOT}/include/lldb/lldb-types.h"\ -" ${SRC_ROOT}/include/lldb/API/SBAddress.h"\ -" ${SRC_ROOT}/include/lldb/API/SBBlock.h"\ -" ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ -" ${SRC_ROOT}/include/lldb/API/SBBreakpointLocation.h"\ -" ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\ -" ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ -" ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ -" ${SRC_ROOT}/include/lldb/API/SBCommunication.h"\ -" ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\ -" ${SRC_ROOT}/include/lldb/API/SBData.h"\ -" ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\ -" ${SRC_ROOT}/include/lldb/API/SBError.h"\ -" ${SRC_ROOT}/include/lldb/API/SBEvent.h"\ -" ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\ -" ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ -" ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ -" ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\ -" ${SRC_ROOT}/include/lldb/API/SBInputReader.h"\ -" ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\ -" ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\ -" ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ -" ${SRC_ROOT}/include/lldb/API/SBListener.h"\ -" ${SRC_ROOT}/include/lldb/API/SBModule.h"\ -" ${SRC_ROOT}/include/lldb/API/SBProcess.h"\ -" ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\ -" ${SRC_ROOT}/include/lldb/API/SBStream.h"\ -" ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ -" ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ -" ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ -" ${SRC_ROOT}/include/lldb/API/SBSymbolContextList.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ -" ${SRC_ROOT}/include/lldb/API/SBThread.h"\ -" ${SRC_ROOT}/include/lldb/API/SBType.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeCategory.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeFilter.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeFormat.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeNameSpecifier.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeSummary.h"\ -" ${SRC_ROOT}/include/lldb/API/SBTypeSynthetic.h"\ -" ${SRC_ROOT}/include/lldb/API/SBValue.h"\ -" ${SRC_ROOT}/include/lldb/API/SBValueList.h"\ -" ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h"\ - -INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBreakpoint.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBreakpointLocation.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBroadcaster.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommandInterpreter.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommandReturnObject.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommunication.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCompileUnit.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBData.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBDebugger.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBError.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBEvent.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFileSpec.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFrame.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFunction.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBHostOS.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBInputReader.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBInstruction.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBInstructionList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBLineEntry.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBListener.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBModule.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBProcess.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSourceManager.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBStream.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBStringList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSymbol.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSymbolContext.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTarget.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBType.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeCategory.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeFilter.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeFormat.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeNameSpecifier.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeSummary.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeSynthetic.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i" - -if [ $Debug == 1 ] -then - echo "Header files are:" - echo ${HEADER_FILES} -fi - -if [ $Debug == 1 ] -then - echo "SWIG interface files are:" - echo ${INTERFACE_FILES} -fi - -NeedToUpdate=0 - - -if [ ! -f ${swig_output_file} ] -then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "Failed to find LLDBWrapPython.cpp" - fi -fi - -if [ $NeedToUpdate == 0 ] -then - for hdrfile in ${HEADER_FILES} - do - if [ $hdrfile -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${hdrfile} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - break - fi - done -fi - -if [ $NeedToUpdate == 0 ] -then - for intffile in ${INTERFACE_FILES} - do - if [ $intffile -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${intffile} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - break - fi - done -fi - -if [ $NeedToUpdate == 0 ] -then - if [ ${swig_input_file} -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${swig_input_file} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - fi -fi - -if [ $NeedToUpdate == 0 ] -then - if [ ${swig_python_extensions} -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${swig_python_extensions} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - fi -fi - -if [ $NeedToUpdate == 0 ] -then - if [ ${swig_python_wrapper} -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${swig_python_wrapper} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - fi -fi - -if [ $NeedToUpdate == 0 ] -then - if [ ${swig_python_typemaps} -nt ${swig_output_file} ] - then - NeedToUpdate=1 - if [ $Debug == 1 ] - then - echo "${swig_python_typemaps} is newer than ${swig_output_file}" - echo "swig file will need to be re-built." - fi - fi -fi - -os_name=`uname -s` -python_version=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` - -if [ "$os_name" == "Darwin" ] -then - framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" -else - framework_python_dir="${PYTHON_INSTALL_DIR}/python${python_version}" -fi - - -if [ ! -L "${framework_python_dir}/_lldb.so" ] -then - NeedToUpdate=1 -fi - -if [ ! -f "${framework_python_dir}/lldb.py" ] -then - NeedToUpdate=1 -fi - - -if [ $NeedToUpdate == 0 ] -then - echo "Everything is up-to-date." - exit 0 -else - echo "SWIG needs to be re-run." - if [ -f ${swig_output_file} ] - then - rm ${swig_output_file} - fi -fi - - -# Build the SWIG C++ wrapper file for Python. - -$SWIG -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" - -# Implement the iterator protocol and/or eq/ne operators for some lldb objects. -# Append global variable to lldb Python module. -# And initialize the lldb debugger subsystem. -current_dir=`pwd` -if [ -f "${current_dir}/modify-python-lldb.py" ] -then - python ${current_dir}/modify-python-lldb.py ${CONFIG_BUILD_DIR} -fi - -# Fix the "#include" statement in the swig output file - -if [ -f "${current_dir}/edit-swig-python-wrapper-file.py" ] -then - python ${current_dir}/edit-swig-python-wrapper-file.py - if [ -f "${swig_output_file}.edited" ] - then - mv "${swig_output_file}.edited" ${swig_output_file} - fi -fi - -else - # SDKROOT was not empty, which currently means iOS cross build where python is disabled - rm -rf ${swig_output_file} - touch ${swig_output_file} -fi diff --git a/lldb/scripts/Python/edit-swig-python-wrapper-file.py b/lldb/scripts/Python/edit-swig-python-wrapper-file.py deleted file mode 100644 index d64c0b408164..000000000000 --- a/lldb/scripts/Python/edit-swig-python-wrapper-file.py +++ /dev/null @@ -1,53 +0,0 @@ -# -# edit-swig-python-wrapper-file.py -# -# This script performs some post-processing editing on the C++ file that -# SWIG generates for python, after running on 'lldb.swig'. In -# particular, on Apple systems we want to include the Python.h file that -# is used in the /System/Library/Frameworks/Python.framework, but on other -# systems we want to include plain <Python.h>. So we need to replace: -# -# #include <Python.h> -# -# with: -# -# #if defined (__APPLE__) -# #include <Python/Python.h> -# #else -# #include <Python.h> -# #endif -# -# That's what this python script does. -# - -import os, sys - -include_python = '#include <Python.h>' -include_python_ifdef = '''#if defined (__APPLE__) -#include <Python/Python.h> -#else -#include <Python.h> -#endif -''' - -if len (sys.argv) > 1: - input_dir_name = sys.argv[1] - full_input_name = input_dir_name + "/LLDBWrapPython.cpp" -else: - input_dir_name = os.environ["SRCROOT"] - full_input_name = input_dir_name + "/source/LLDBWrapPython.cpp" -full_output_name = full_input_name + ".edited" - -with open(full_input_name, 'r') as f_in: - with open(full_output_name, 'w') as f_out: - include_python_found = False - for line in f_in: - if not include_python_found: - if line.startswith(include_python): - # Write out the modified lines. - f_out.write(include_python_ifdef) - include_python_found = True - continue - - # Otherwise, copy the line verbatim to the output file. - f_out.write(line) diff --git a/lldb/scripts/Python/finish-swig-Python-LLDB.sh b/lldb/scripts/Python/finish-swig-Python-LLDB.sh deleted file mode 100755 index 13194f4567ab..000000000000 --- a/lldb/scripts/Python/finish-swig-Python-LLDB.sh +++ /dev/null @@ -1,556 +0,0 @@ -#! /bin/sh - -# finish-swig-Python.sh -# -# For the Python script interpreter (external to liblldb) to be able to import -# and use the lldb module, there must be two files, lldb.py and _lldb.so, that -# it can find. lldb.py is generated by SWIG at the same time it generates the -# C++ file. _lldb.so is actually a symlink file that points to the -# LLDB shared library/framework. -# -# The Python script interpreter needs to be able to automatically find -# these two files. On Darwin systems it searches in the LLDB.framework, as -# well as in all the normal Python search paths. On non-Darwin systems -# these files will need to be put someplace where Python will find them. -# -# This shell script creates the _lldb.so symlink in the appropriate place, -# and copies the lldb.py (and embedded_interpreter.py) file to the correct -# directory. -# - -# SRC_ROOT is the root of the lldb source tree. -# TARGET_DIR is where the lldb framework/shared library gets put. -# CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh shell script -# put the lldb.py file it was generated from running SWIG. -# PYTHON_INSTALL_DIR is where non-Darwin systems want to put the .py and .so -# files so that Python can find them automatically. -# debug_flag (optional) determines whether or not this script outputs -# additional information when running. - -SRC_ROOT=$1 -TARGET_DIR=$2 -CONFIG_BUILD_DIR=$3 -PYTHON_INSTALL_DIR=$4 -debug_flag=$5 - -# Make sure SDKROOT is not set, since if it is this is an iOS build where python -# is disabled -if [ "x$SDKROOT" = "x" ] ; then - -if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] -then - Debug=1 -else - Debug=0 -fi - -OS_NAME=`uname -s` -PYTHON_VERSION=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` - - -if [ $Debug == 1 ] -then - echo "The current OS is $OS_NAME" - echo "The Python version is $PYTHON_VERSION" -fi - -# -# Determine where to put the files. - -if [ ${OS_NAME} == "Darwin" ] -then - # We are on a Darwin system, so all the lldb Python files can go - # into the LLDB.framework/Resources/Python subdirectory. - - if [ ! -d "${TARGET_DIR}/LLDB.framework" ] - then - echo "Error: Unable to find LLDB.framework" >&2 - exit 1 - else - if [ $Debug == 1 ] - then - echo "Found ${TARGET_DIR}/LLDB.framework." - fi - fi - - # Make the Python directory in the framework if it doesn't already exist - - framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" -else - # We are on a non-Darwin system, so use the PYTHON_INSTALL_DIR argument, - # and append the python version directory to the end of it. Depending on - # the system other stuff may need to be put here as well. - - framework_python_dir="${PYTHON_INSTALL_DIR}/python${PYTHON_VERSION}" -fi - -# -# Look for the directory in which to put the Python files; if it does not -# already exist, attempt to make it. -# - -if [ $Debug == 1 ] -then - echo "Python files will be put in ${framework_python_dir}" -fi - -if [ ! -d "${framework_python_dir}" ] -then - if [ $Debug == 1 ] - then - echo "Making directory ${framework_python_dir}" - fi - mkdir -p "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "${framework_python_dir} already exists." - fi -fi - -if [ ! -d "${framework_python_dir}" ] -then - echo "Error: Unable to find or create ${framework_python_dir}" >&2 - exit 1 -fi - -# Make the symlink that the script bridge for Python will need in the -# Python framework directory - -if [ ! -L "${framework_python_dir}/_lldb.so" ] -then - if [ $Debug == 1 ] - then - echo "Creating symlink for _lldb.so" - fi - if [ ${OS_NAME} == "Darwin" ] - then - cd "${framework_python_dir}" - ln -s "../../LLDB" _lldb.so - else - cd "${TARGET_DIR}" - ln -s "./LLDB" _lldb.so - fi -else - if [ $Debug == 1 ] - then - echo "${framework_python_dir}/_lldb.so already exists." - fi -fi - -# Copy the python module (lldb.py) that was generated by SWIG -# over to the framework Python directory -if [ -f "${CONFIG_BUILD_DIR}/lldb.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying lldb.py to ${framework_python_dir}" - fi - cp "${CONFIG_BUILD_DIR}/lldb.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${CONFIG_BUILD_DIR}/lldb.py" - fi -fi - -# Copy the embedded interpreter script over to the framework Python directory -if [ -f "${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying embedded_interpreter.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" - fi -fi - -# Copy the C++ STL formatters over to the framework Python directory -if [ -f "${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying gnu_libstdcpp.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/synthetic/libcxx.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying libcxx.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/synthetic/libcxx.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/synthetic/libcxx.py" - fi -fi - -# Copy the ObjC formatters over to the framework Python directory -if [ -f "${SRC_ROOT}/examples/summaries/objc.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying objc.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/objc.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/objc.py" - fi -fi - -# Copy the Cocoa formatters over to the framework Python directory -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFArray.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFArray.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFArray.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFArray.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFDictionary.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFString.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFString.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFString.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFString.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSData.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSData.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSData.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSData.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSMachPort.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSSet.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSSet.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSSet.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSSet.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSNotification.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSException.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSException.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSException.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSException.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBag.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFBag.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFBag.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBag.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFBinaryHeap.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSURL.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSURL.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSURL.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSURL.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSBundle.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSNumber.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSDate.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSDate.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSDate.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSDate.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSIndexSet.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying NSIndexSet.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/NSIndexSet.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSIndexSet.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying CFBitVector.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBitVector.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/Selector.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying Selector.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/Selector.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/Selector.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/Class.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying Class.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/Class.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/Class.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/cache.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying cache.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/cache.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/cache.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/metrics.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying metrics.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/metrics.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/metrics.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/attrib_fromdict.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying attrib_fromdict.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/attrib_fromdict.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/attrib_fromdict.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/Logger.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying Logger.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/Logger.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/Logger.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying objc_lldb.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py" - fi -fi - -if [ -f "${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py" ] -then - if [ $Debug == 1 ] - then - echo "Copying objc_runtime.py to ${framework_python_dir}" - fi - cp "${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py" "${framework_python_dir}" -else - if [ $Debug == 1 ] - then - echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py" - fi -fi - -fi - -exit 0 - diff --git a/lldb/scripts/Python/interface/SBAddress.i b/lldb/scripts/Python/interface/SBAddress.i deleted file mode 100644 index 0bc0c53f794d..000000000000 --- a/lldb/scripts/Python/interface/SBAddress.i +++ /dev/null @@ -1,200 +0,0 @@ -//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"A section + offset based address class. - -The SBAddress class allows addresses to be relative to a section -that can move during runtime due to images (executables, shared -libraries, bundles, frameworks) being loaded at different -addresses than the addresses found in the object file that -represents them on disk. There are currently two types of addresses -for a section: - o file addresses - o load addresses - -File addresses represents the virtual addresses that are in the 'on -disk' object files. These virtual addresses are converted to be -relative to unique sections scoped to the object file so that -when/if the addresses slide when the images are loaded/unloaded -in memory, we can easily track these changes without having to -update every object (compile unit ranges, line tables, function -address ranges, lexical block and inlined subroutine address -ranges, global and static variables) each time an image is loaded or -unloaded. - -Load addresses represents the virtual addresses where each section -ends up getting loaded at runtime. Before executing a program, it -is common for all of the load addresses to be unresolved. When a -DynamicLoader plug-in receives notification that shared libraries -have been loaded/unloaded, the load addresses of the main executable -and any images (shared libraries) will be resolved/unresolved. When -this happens, breakpoints that are in one of these sections can be -set/cleared. - -See docstring of SBFunction for example usage of SBAddress." -) SBAddress; -class SBAddress -{ -public: - - SBAddress (); - - SBAddress (const lldb::SBAddress &rhs); - - SBAddress (lldb::SBSection section, - lldb::addr_t offset); - - %feature("docstring", " - Create an address by resolving a load address using the supplied target. - ") SBAddress; - SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); - - ~SBAddress (); - - bool - IsValid () const; - - void - Clear (); - - addr_t - GetFileAddress () const; - - addr_t - GetLoadAddress (const lldb::SBTarget &target) const; - - void - SetLoadAddress (lldb::addr_t load_addr, - lldb::SBTarget &target); - - bool - OffsetAddress (addr_t offset); - - bool - GetDescription (lldb::SBStream &description); - - lldb::SBSection - GetSection (); - - lldb::addr_t - SBAddress::GetOffset (); - - void - SetAddress (lldb::SBSection section, - lldb::addr_t offset); - - - lldb::AddressClass - GetAddressClass (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// GetSymbolContext() and the following can lookup symbol information for a given address. - /// An address might refer to code or data from an existing module, or it - /// might refer to something on the stack or heap. The following functions - /// will only return valid values if the address has been resolved to a code - /// or data address using 'void SBAddress::SetLoadAddress(...)' or - /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'. - //------------------------------------------------------------------ - ") GetSymbolContext; - lldb::SBSymbolContext - GetSymbolContext (uint32_t resolve_scope); - - %feature("docstring", " - //------------------------------------------------------------------ - /// GetModule() and the following grab individual objects for a given address and - /// are less efficient if you want more than one symbol related objects. - /// Use one of the following when you want multiple debug symbol related - /// objects for an address: - /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); - /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); - /// One or more bits from the SymbolContextItem enumerations can be logically - /// OR'ed together to more efficiently retrieve multiple symbol objects. - //------------------------------------------------------------------ - ") GetModule; - lldb::SBModule - GetModule (); - - lldb::SBCompileUnit - GetCompileUnit (); - - lldb::SBFunction - GetFunction (); - - lldb::SBBlock - GetBlock (); - - lldb::SBSymbol - GetSymbol (); - - lldb::SBLineEntry - GetLineEntry (); - - %pythoncode %{ - def __get_load_addr_property__ (self): - '''Get the load address for a lldb.SBAddress using the current target.''' - return self.GetLoadAddress (target) - - def __set_load_addr_property__ (self, load_addr): - '''Set the load address for a lldb.SBAddress using the current target.''' - return self.SetLoadAddress (load_addr, target) - - def __int__(self): - '''Convert an address to a load address if there is a process and that - process is alive, or to a file address otherwise.''' - if process.is_alive: - return self.GetLoadAddress (target) - else: - return self.GetFileAddress () - - def __oct__(self): - return '%o' % int(self) - - def __hex__(self): - return '0x%x' % int(self) - - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='Returns the same result as GetModule()') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='Returns the same result as GetCompileUnit()') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='Returns the same result as GetLineEntry()') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='Returns the same result as GetFunction()') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='Returns the same result as GetBlock()') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='Returns the same result as GetSymbol()') - - __swig_getmethods__["offset"] = GetOffset - if _newclass: offset = property(GetOffset, None, doc='Returns the same result as GetOffset()') - - __swig_getmethods__["section"] = GetSection - if _newclass: section = property(GetSection, None, doc='Returns the same result as GetSection()') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: file_addr = property(GetFileAddress, None, doc='Returns the same result as GetFileAddress()') - - __swig_getmethods__["load_addr"] = __get_load_addr_property__ - __swig_setmethods__["load_addr"] = __set_load_addr_property__ - if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='Returns a corresponding load address, resolving this SBAddress via lldb.target') - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBBlock.i b/lldb/scripts/Python/interface/SBBlock.i deleted file mode 100644 index cdaf62cbeca3..000000000000 --- a/lldb/scripts/Python/interface/SBBlock.i +++ /dev/null @@ -1,175 +0,0 @@ -//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a lexical block. SBFunction contains SBBlock(s)." -) SBBlock; -class SBBlock -{ -public: - - SBBlock (); - - SBBlock (const lldb::SBBlock &rhs); - - ~SBBlock (); - - %feature("docstring", - "Does this block represent an inlined function?" - ) IsInlined; - bool - IsInlined () const; - - bool - IsValid () const; - - %feature("docstring", " - Get the function name if this block represents an inlined function; - otherwise, return None. - ") GetInlinedName; - const char * - GetInlinedName () const; - - %feature("docstring", " - Get the call site file if this block represents an inlined function; - otherwise, return an invalid file spec. - ") GetInlinedCallSiteFile; - lldb::SBFileSpec - GetInlinedCallSiteFile () const; - - %feature("docstring", " - Get the call site line if this block represents an inlined function; - otherwise, return 0. - ") GetInlinedCallSiteLine; - uint32_t - GetInlinedCallSiteLine () const; - - %feature("docstring", " - Get the call site column if this block represents an inlined function; - otherwise, return 0. - ") GetInlinedCallSiteColumn; - uint32_t - GetInlinedCallSiteColumn () const; - - %feature("docstring", "Get the parent block.") GetParent; - lldb::SBBlock - GetParent (); - - %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; - lldb::SBBlock - GetContainingInlinedBlock (); - - %feature("docstring", "Get the sibling block for this block.") GetSibling; - lldb::SBBlock - GetSibling (); - - %feature("docstring", "Get the first child block.") GetFirstChild; - lldb::SBBlock - GetFirstChild (); - - uint32_t - GetNumRanges (); - - lldb::SBAddress - GetRangeStartAddress (uint32_t idx); - - lldb::SBAddress - GetRangeEndAddress (uint32_t idx); - - uint32_t - GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); - - bool - GetDescription (lldb::SBStream &description); - - lldb::SBValueList - GetVariables (lldb::SBFrame& frame, - bool arguments, - bool locals, - bool statics, - lldb::DynamicValueType use_dynamic); - - lldb::SBValueList - GetVariables (lldb::SBTarget& target, - bool arguments, - bool locals, - bool statics); - - %pythoncode %{ - def get_range_at_index(self, idx): - if idx < self.GetNumRanges(): - return [self.sbblock.GetRangeStartAddress(key), self.sbblock.GetRangeEndAddress(key)] - return [] - - class ranges_access(object): - '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.''' - def __init__(self, sbblock): - self.sbblock = sbblock - - def __len__(self): - if self.sbblock: - return self.sbblock.GetNumRanges() - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - return self.sbblock.get_range_at_index (key); - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_ranges_access_object(self): - '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.''' - return self.ranges_access (self) - - def get_ranges_array(self): - '''An accessor function that returns an array object that contains all ranges in this block object.''' - if not hasattr(self, 'ranges'): - self.ranges = [] - for idx in range(self.num_ranges): - self.ranges.append (self.get_range_at_index (idx)) - return self.ranges - - def get_call_site(self): - return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) - - __swig_getmethods__["parent"] = GetParent - if _newclass: x = property(GetParent, None) - - __swig_getmethods__["first_child"] = GetFirstChild - if _newclass: x = property(GetFirstChild, None) - - __swig_getmethods__["call_site"] = get_call_site - if _newclass: x = property(get_call_site, None) - - __swig_getmethods__["sibling"] = GetSibling - if _newclass: x = property(GetSibling, None) - - __swig_getmethods__["name"] = GetInlinedName - if _newclass: x = property(GetInlinedName, None) - - __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock - if _newclass: x = property(GetContainingInlinedBlock, None) - - __swig_getmethods__["range"] = get_ranges_access_object - if _newclass: x = property(get_ranges_access_object, None) - - __swig_getmethods__["ranges"] = get_ranges_array - if _newclass: x = property(get_ranges_array, None) - - __swig_getmethods__["num_ranges"] = GetNumRanges - if _newclass: x = property(GetNumRanges, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBBreakpoint.i b/lldb/scripts/Python/interface/SBBreakpoint.i deleted file mode 100644 index 0e9a80c2e9bc..000000000000 --- a/lldb/scripts/Python/interface/SBBreakpoint.i +++ /dev/null @@ -1,199 +0,0 @@ -//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a logical breakpoint and its associated settings. - -For example (from test/functionalities/breakpoint/breakpoint_ignore_count/ -TestBreakpointIgnoreCount.py), - - def breakpoint_ignore_count_python(self): - '''Use Python APIs to set breakpoint ignore count.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - self.assertTrue(breakpoint and - breakpoint.GetNumLocations() == 1, - VALID_BREAKPOINT) - - # Get the breakpoint location from breakpoint after we verified that, - # indeed, it has one location. - location = breakpoint.GetLocationAtIndex(0) - self.assertTrue(location and - location.IsEnabled(), - VALID_BREAKPOINT_LOCATION) - - # Set the ignore count on the breakpoint location. - location.SetIgnoreCount(2) - self.assertTrue(location.GetIgnoreCount() == 2, - 'SetIgnoreCount() works correctly') - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process, PROCESS_IS_VALID) - - # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and - # frame#2 should be on main.c:48. - #lldbutil.print_stacktraces(process) - from lldbutil import get_stopped_thread - thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint') - frame0 = thread.GetFrameAtIndex(0) - frame1 = thread.GetFrameAtIndex(1) - frame2 = thread.GetFrameAtIndex(2) - self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and - frame1.GetLineEntry().GetLine() == self.line3 and - frame2.GetLineEntry().GetLine() == self.line4, - STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT) - - # The hit count for the breakpoint should be 3. - self.assertTrue(breakpoint.GetHitCount() == 3) - - process.Continue() - -SBBreakpoint supports breakpoint location iteration, for example, - - for bl in breakpoint: - print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress()) - print 'breakpoint location condition: %s' % hex(bl.GetCondition()) - -and rich comparion methods which allow the API program to use, - - if aBreakpoint == bBreakpoint: - ... - -to compare two breakpoints for equality." -) SBBreakpoint; -class SBBreakpoint -{ -public: - - typedef bool (*BreakpointHitCallback) (void *baton, - SBProcess &process, - SBThread &thread, - lldb::SBBreakpointLocation &location); - - SBBreakpoint (); - - SBBreakpoint (const lldb::SBBreakpoint& rhs); - - ~SBBreakpoint(); - - break_id_t - GetID () const; - - bool - IsValid() const; - - void - ClearAllBreakpointSites (); - - lldb::SBBreakpointLocation - FindLocationByAddress (lldb::addr_t vm_addr); - - lldb::break_id_t - FindLocationIDByAddress (lldb::addr_t vm_addr); - - lldb::SBBreakpointLocation - FindLocationByID (lldb::break_id_t bp_loc_id); - - lldb::SBBreakpointLocation - GetLocationAtIndex (uint32_t index); - - void - SetEnabled (bool enable); - - bool - IsEnabled (); - - uint32_t - GetHitCount () const; - - void - SetIgnoreCount (uint32_t count); - - uint32_t - GetIgnoreCount () const; - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The breakpoint stops only if the condition expression evaluates to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the breakpoint. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - void - SetThreadID (lldb::tid_t sb_thread_id); - - lldb::tid_t - GetThreadID (); - - void - SetThreadIndex (uint32_t index); - - uint32_t - GetThreadIndex() const; - - void - SetThreadName (const char *thread_name); - - const char * - GetThreadName () const; - - void - SetQueueName (const char *queue_name); - - const char * - GetQueueName () const; - - void - SetCallback (BreakpointHitCallback callback, void *baton); - - size_t - GetNumResolvedLocations() const; - - size_t - GetNumLocations() const; - - bool - GetDescription (lldb::SBStream &description); - - static bool - EventIsBreakpointEvent (const lldb::SBEvent &event); - - static lldb::BreakpointEventType - GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); - - static lldb::SBBreakpoint - GetBreakpointFromEvent (const lldb::SBEvent& event); - - static lldb::SBBreakpointLocation - GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); - - static uint32_t - GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBBreakpointLocation.i b/lldb/scripts/Python/interface/SBBreakpointLocation.i deleted file mode 100644 index 093a0e6d380d..000000000000 --- a/lldb/scripts/Python/interface/SBBreakpointLocation.i +++ /dev/null @@ -1,104 +0,0 @@ -//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents one unique instance (by address) of a logical breakpoint. - -A breakpoint location is defined by the breakpoint that produces it, -and the address that resulted in this particular instantiation. -Each breakpoint location has its settable options. - -SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint -for retrieval of an SBBreakpointLocation from an SBBreakpoint." -) SBBreakpointLocation; -class SBBreakpointLocation -{ -public: - - SBBreakpointLocation (); - - SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs); - - ~SBBreakpointLocation (); - - bool - IsValid() const; - - lldb::SBAddress - GetAddress(); - - lldb::addr_t - GetLoadAddress (); - - void - SetEnabled(bool enabled); - - bool - IsEnabled (); - - uint32_t - GetIgnoreCount (); - - void - SetIgnoreCount (uint32_t n); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The breakpoint location stops only if the condition expression evaluates - /// to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the breakpoint location. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - void - SetThreadID (lldb::tid_t sb_thread_id); - - lldb::tid_t - GetThreadID (); - - void - SetThreadIndex (uint32_t index); - - uint32_t - GetThreadIndex() const; - - void - SetThreadName (const char *thread_name); - - const char * - GetThreadName () const; - - void - SetQueueName (const char *queue_name); - - const char * - GetQueueName () const; - - bool - IsResolved (); - - bool - GetDescription (lldb::SBStream &description, DescriptionLevel level); - - SBBreakpoint - GetBreakpoint (); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBBroadcaster.i b/lldb/scripts/Python/interface/SBBroadcaster.i deleted file mode 100644 index ece38f602c49..000000000000 --- a/lldb/scripts/Python/interface/SBBroadcaster.i +++ /dev/null @@ -1,62 +0,0 @@ -//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an entity which can broadcast events. A default broadcaster is -associated with an SBCommandInterpreter, SBProcess, and SBTarget. For -example, use - - broadcaster = process.GetBroadcaster() - -to retrieve the process's broadcaster. - -See also SBEvent for example usage of interacting with a broadcaster." -) SBBroadcaster; -class SBBroadcaster -{ -public: - SBBroadcaster (); - - SBBroadcaster (const char *name); - - SBBroadcaster (const SBBroadcaster &rhs); - - ~SBBroadcaster(); - - bool - IsValid () const; - - void - Clear (); - - void - BroadcastEventByType (uint32_t event_type, bool unique = false); - - void - BroadcastEvent (const lldb::SBEvent &event, bool unique = false); - - void - AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events); - - uint32_t - AddListener (const lldb::SBListener &listener, uint32_t event_mask); - - const char * - GetName () const; - - bool - EventTypeHasListeners (uint32_t event_type); - - bool - RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBCommandInterpreter.i b/lldb/scripts/Python/interface/SBCommandInterpreter.i deleted file mode 100644 index 62aaf8c48aa2..000000000000 --- a/lldb/scripts/Python/interface/SBCommandInterpreter.i +++ /dev/null @@ -1,122 +0,0 @@ -//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"SBCommandInterpreter handles/interprets commands for lldb. You get the -command interpreter from the SBDebugger instance. For example (from test/ -python_api/interpreter/TestCommandInterpreterAPI.py), - - def command_interpreter_api(self): - '''Test the SBCommandInterpreter APIs.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Retrieve the associated command interpreter from our debugger. - ci = self.dbg.GetCommandInterpreter() - self.assertTrue(ci, VALID_COMMAND_INTERPRETER) - - # Exercise some APIs.... - - self.assertTrue(ci.HasCommands()) - self.assertTrue(ci.HasAliases()) - self.assertTrue(ci.HasAliasOptions()) - self.assertTrue(ci.CommandExists('breakpoint')) - self.assertTrue(ci.CommandExists('target')) - self.assertTrue(ci.CommandExists('platform')) - self.assertTrue(ci.AliasExists('file')) - self.assertTrue(ci.AliasExists('run')) - self.assertTrue(ci.AliasExists('bt')) - - res = lldb.SBCommandReturnObject() - ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) - self.assertTrue(res.Succeeded()) - ci.HandleCommand('process launch', res) - self.assertTrue(res.Succeeded()) - - process = ci.GetProcess() - self.assertTrue(process) - - ... - -The HandleCommand() instance method takes two args: the command string and -an SBCommandReturnObject instance which encapsulates the result of command -execution. -") SBCommandInterpreter; -class SBCommandInterpreter -{ -public: - enum - { - eBroadcastBitThreadShouldExit = (1 << 0), - eBroadcastBitResetPrompt = (1 << 1), - eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit - eBroadcastBitAsynchronousOutputData = (1 << 3), - eBroadcastBitAsynchronousErrorData = (1 << 4) - }; - - SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); - - ~SBCommandInterpreter (); - - static const char * - GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); - - static const char * - GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); - - bool - IsValid() const; - - bool - CommandExists (const char *cmd); - - bool - AliasExists (const char *cmd); - - lldb::SBBroadcaster - GetBroadcaster (); - - static const char * - GetBroadcasterClass (); - - bool - HasCommands (); - - bool - HasAliases (); - - bool - HasAliasOptions (); - - lldb::SBProcess - GetProcess (); - - void - SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); - - void - SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); - - lldb::ReturnStatus - HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); - - int - HandleCompletion (const char *current_line, - uint32_t cursor_pos, - int match_start_point, - int max_return_elements, - lldb::SBStringList &matches); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i deleted file mode 100644 index 51d8ca8a77f9..000000000000 --- a/lldb/scripts/Python/interface/SBCommandReturnObject.i +++ /dev/null @@ -1,82 +0,0 @@ -//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a container which holds the result from command execution. -It works with SBCommandInterpreter.HandleCommand() to encapsulate the result -of command execution. - -See SBCommandInterpreter for example usage of SBCommandReturnObject." -) SBCommandReturnObject; -class SBCommandReturnObject -{ -public: - - SBCommandReturnObject (); - - SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); - - ~SBCommandReturnObject (); - - bool - IsValid() const; - - const char * - GetOutput (); - - const char * - GetError (); - - size_t - PutOutput (FILE *fh); - - size_t - GetOutputSize (); - - size_t - GetErrorSize (); - - size_t - PutError (FILE *fh); - - void - Clear(); - - lldb::ReturnStatus - GetStatus(); - - bool - Succeeded (); - - bool - HasResult (); - - void - AppendMessage (const char *message); - - bool - GetDescription (lldb::SBStream &description); - - void - SetImmediateOutputFile (FILE *fh); - - void - SetImmediateErrorFile (FILE *fh); - - void - PutCString(const char* string, int len = -1); - - size_t - Printf(const char* format, ...); - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBCommunication.i b/lldb/scripts/Python/interface/SBCommunication.i deleted file mode 100644 index 99814d9f3034..000000000000 --- a/lldb/scripts/Python/interface/SBCommunication.i +++ /dev/null @@ -1,82 +0,0 @@ -//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBCommunication -{ -public: - enum { - eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost. - eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available. - eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients. - eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread. - eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet. - eAllEventBits = 0xffffffff - }; - - typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); - - SBCommunication (); - SBCommunication (const char * broadcaster_name); - ~SBCommunication (); - - - bool - IsValid () const; - - lldb::SBBroadcaster - GetBroadcaster (); - - static const char *GetBroadcasterClass(); - - lldb::ConnectionStatus - AdoptFileDesriptor (int fd, bool owns_fd); - - lldb::ConnectionStatus - Connect (const char *url); - - lldb::ConnectionStatus - Disconnect (); - - bool - IsConnected () const; - - bool - GetCloseOnEOF (); - - void - SetCloseOnEOF (bool b); - - size_t - Read (void *dst, - size_t dst_len, - uint32_t timeout_usec, - lldb::ConnectionStatus &status); - - size_t - Write (const void *src, - size_t src_len, - lldb::ConnectionStatus &status); - - bool - ReadThreadStart (); - - bool - ReadThreadStop (); - - bool - ReadThreadIsRunning (); - - bool - SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, - void *callback_baton); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBCompileUnit.i b/lldb/scripts/Python/interface/SBCompileUnit.i deleted file mode 100644 index 6f9d023295e2..000000000000 --- a/lldb/scripts/Python/interface/SBCompileUnit.i +++ /dev/null @@ -1,101 +0,0 @@ -//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a compilation unit, or compiled source file. - -SBCompileUnit supports line entry iteration. For example, - - # Now get the SBSymbolContext from this frame. We want everything. :-) - context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) - ... - - compileUnit = context.GetCompileUnit() - - for lineEntry in compileUnit: - print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), - lineEntry.GetLine()) - print 'start addr: %s' % str(lineEntry.GetStartAddress()) - print 'end addr: %s' % str(lineEntry.GetEndAddress()) - -produces: - -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 -start addr: a.out[0x100000d98] -end addr: a.out[0x100000da3] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 -start addr: a.out[0x100000da3] -end addr: a.out[0x100000da9] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 -start addr: a.out[0x100000da9] -end addr: a.out[0x100000db6] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 -start addr: a.out[0x100000db6] -end addr: a.out[0x100000dbc] -... - -See also SBSymbolContext and SBLineEntry" -) SBCompileUnit; -class SBCompileUnit -{ -public: - - SBCompileUnit (); - - SBCompileUnit (const lldb::SBCompileUnit &rhs); - - ~SBCompileUnit (); - - bool - IsValid () const; - - lldb::SBFileSpec - GetFileSpec () const; - - uint32_t - GetNumLineEntries () const; - - lldb::SBLineEntry - GetLineEntryAtIndex (uint32_t idx) const; - - uint32_t - FindLineEntryIndex (uint32_t start_idx, - uint32_t line, - lldb::SBFileSpec *inline_file_spec) const; - - uint32_t - FindLineEntryIndex (uint32_t start_idx, - uint32_t line, - lldb::SBFileSpec *inline_file_spec, - bool exact) const; - - SBFileSpec - GetSupportFileAtIndex (uint32_t idx) const; - - uint32_t - GetNumSupportFiles () const; - - uint32_t - FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: x = property(GetFileSpec, None) - - __swig_getmethods__["num_line_entries"] = GetNumLineEntries - if _newclass: x = property(GetNumLineEntries, None) - %} -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBData.i b/lldb/scripts/Python/interface/SBData.i deleted file mode 100644 index f90dd3e1ba23..000000000000 --- a/lldb/scripts/Python/interface/SBData.i +++ /dev/null @@ -1,300 +0,0 @@ -//===-- SWIG Interface for SBData -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -namespace lldb { - -class SBData -{ -public: - - SBData (); - - SBData (const SBData &rhs); - - ~SBData (); - - uint8_t - GetAddressByteSize (); - - void - SetAddressByteSize (uint8_t addr_byte_size); - - void - Clear (); - - bool - IsValid(); - - size_t - GetByteSize (); - - lldb::ByteOrder - GetByteOrder(); - - void - SetByteOrder (lldb::ByteOrder endian); - - float - GetFloat (lldb::SBError& error, uint32_t offset); - - double - GetDouble (lldb::SBError& error, uint32_t offset); - - long double - GetLongDouble (lldb::SBError& error, uint32_t offset); - - lldb::addr_t - GetAddress (lldb::SBError& error, uint32_t offset); - - uint8_t - GetUnsignedInt8 (lldb::SBError& error, uint32_t offset); - - uint16_t - GetUnsignedInt16 (lldb::SBError& error, uint32_t offset); - - uint32_t - GetUnsignedInt32 (lldb::SBError& error, uint32_t offset); - - uint64_t - GetUnsignedInt64 (lldb::SBError& error, uint32_t offset); - - int8_t - GetSignedInt8 (lldb::SBError& error, uint32_t offset); - - int16_t - GetSignedInt16 (lldb::SBError& error, uint32_t offset); - - int32_t - GetSignedInt32 (lldb::SBError& error, uint32_t offset); - - int64_t - GetSignedInt64 (lldb::SBError& error, uint32_t offset); - - const char* - GetString (lldb::SBError& error, uint32_t offset); - - bool - GetDescription (lldb::SBStream &description, lldb::addr_t base_addr); - - size_t - ReadRawData (lldb::SBError& error, - uint32_t offset, - void *buf, - size_t size); - - void - SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size); - - bool - Append (const SBData& rhs); - - static lldb::SBData - CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data); - - // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len - // should not be renamed or rearranged, because doing so will break the SWIG typemap - static lldb::SBData - CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len); - - bool - SetDataFromCString (const char* data); - - bool - SetDataFromUInt64Array (uint64_t* array, size_t array_len); - - bool - SetDataFromUInt32Array (uint32_t* array, size_t array_len); - - bool - SetDataFromSInt64Array (int64_t* array, size_t array_len); - - bool - SetDataFromSInt32Array (int32_t* array, size_t array_len); - - bool - SetDataFromDoubleArray (double* array, size_t array_len); - - %pythoncode %{ - - class read_data_helper: - def __init__(self, sbdata, readerfunc, item_size): - self.sbdata = sbdata - self.readerfunc = readerfunc - self.item_size = item_size - def __getitem__(self,key): - if isinstance(key,slice): - list = [] - for x in range(*key.indices(self.__len__())): - list.append(self.__getitem__(x)) - return list - if not (isinstance(key,(int,long))): - raise TypeError('must be int') - key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here - error = SBError() - my_data = self.readerfunc(self.sbdata,error,key) - if error.Fail(): - raise IndexError(error.GetCString()) - else: - return my_data - def __len__(self): - return self.sbdata.GetByteSize()/self.item_size - def all(self): - return self[0:len(self)] - - def _make_helper(self, sbdata, getfunc, itemsize): - return self.read_data_helper(sbdata, getfunc, itemsize) - - def _make_helper_uint8(self): - return self._make_helper(self, SBData.GetUnsignedInt8, 1) - - def _make_helper_uint16(self): - return self._make_helper(self, SBData.GetUnsignedInt16, 2) - - def _make_helper_uint32(self): - return self._make_helper(self, SBData.GetUnsignedInt32, 4) - - def _make_helper_uint64(self): - return self._make_helper(self, SBData.GetUnsignedInt64, 8) - - def _make_helper_sint8(self): - return self._make_helper(self, SBData.GetSignedInt8, 1) - - def _make_helper_sint16(self): - return self._make_helper(self, SBData.GetSignedInt16, 2) - - def _make_helper_sint32(self): - return self._make_helper(self, SBData.GetSignedInt32, 4) - - def _make_helper_sint64(self): - return self._make_helper(self, SBData.GetSignedInt64, 8) - - def _make_helper_float(self): - return self._make_helper(self, SBData.GetFloat, 4) - - def _make_helper_double(self): - return self._make_helper(self, SBData.GetDouble, 8) - - def _read_all_uint8(self): - return self._make_helper_uint8().all() - - def _read_all_uint16(self): - return self._make_helper_uint16().all() - - def _read_all_uint32(self): - return self._make_helper_uint32().all() - - def _read_all_uint64(self): - return self._make_helper_uint64().all() - - def _read_all_sint8(self): - return self._make_helper_sint8().all() - - def _read_all_sint16(self): - return self._make_helper_sint16().all() - - def _read_all_sint32(self): - return self._make_helper_sint32().all() - - def _read_all_sint64(self): - return self._make_helper_sint64().all() - - def _read_all_float(self): - return self._make_helper_float().all() - - def _read_all_double(self): - return self._make_helper_double().all() - - __swig_getmethods__["uint8"] = _make_helper_uint8 - if _newclass: uint8 = property(_make_helper_uint8, None, doc='Returns an array-like object out of which you can read uint8 values') - - __swig_getmethods__["uint16"] = _make_helper_uint16 - if _newclass: uint16 = property(_make_helper_uint16, None, doc='Returns an array-like object out of which you can read uint16 values') - - __swig_getmethods__["uint32"] = _make_helper_uint32 - if _newclass: uint32 = property(_make_helper_uint32, None, doc='Returns an array-like object out of which you can read uint32 values') - - __swig_getmethods__["uint64"] = _make_helper_uint64 - if _newclass: uint64 = property(_make_helper_uint64, None, doc='Returns an array-like object out of which you can read uint64 values') - - __swig_getmethods__["sint8"] = _make_helper_sint8 - if _newclass: sint8 = property(_make_helper_sint8, None, doc='Returns an array-like object out of which you can read sint8 values') - - __swig_getmethods__["sint16"] = _make_helper_sint16 - if _newclass: sint16 = property(_make_helper_sint16, None, doc='Returns an array-like object out of which you can read sint16 values') - - __swig_getmethods__["sint32"] = _make_helper_sint32 - if _newclass: sint32 = property(_make_helper_sint32, None, doc='Returns an array-like object out of which you can read sint32 values') - - __swig_getmethods__["sint64"] = _make_helper_sint64 - if _newclass: sint64 = property(_make_helper_sint64, None, doc='Returns an array-like object out of which you can read sint64 values') - - __swig_getmethods__["float"] = _make_helper_float - if _newclass: float = property(_make_helper_float, None, doc='Returns an array-like object out of which you can read float values') - - __swig_getmethods__["double"] = _make_helper_double - if _newclass: double = property(_make_helper_double, None, doc='Returns an array-like object out of which you can read double values') - - __swig_getmethods__["uint8s"] = _read_all_uint8 - if _newclass: uint8s = property(_read_all_uint8, None, doc='Returns an array with all the contents of this SBData represented as uint8 values') - - __swig_getmethods__["uint16s"] = _read_all_uint16 - if _newclass: uint16s = property(_read_all_uint16, None, doc='Returns an array with all the contents of this SBData represented as uint16 values') - - __swig_getmethods__["uint32s"] = _read_all_uint32 - if _newclass: uint32s = property(_read_all_uint32, None, doc='Returns an array with all the contents of this SBData represented as uint32 values') - - __swig_getmethods__["uint64s"] = _read_all_uint64 - if _newclass: uint64s = property(_read_all_uint64, None, doc='Returns an array with all the contents of this SBData represented as uint64 values') - - __swig_getmethods__["sint8s"] = _read_all_sint8 - if _newclass: sint8s = property(_read_all_sint8, None, doc='Returns an array with all the contents of this SBData represented as sint8 values') - - __swig_getmethods__["sint16s"] = _read_all_sint16 - if _newclass: sint16s = property(_read_all_sint16, None, doc='Returns an array with all the contents of this SBData represented as sint16 values') - - __swig_getmethods__["sint32s"] = _read_all_sint32 - if _newclass: sint32s = property(_read_all_sint32, None, doc='Returns an array with all the contents of this SBData represented as sint32 values') - - __swig_getmethods__["sint64s"] = _read_all_sint64 - if _newclass: sint64s = property(_read_all_sint64, None, doc='Returns an array with all the contents of this SBData represented as sint64 values') - - __swig_getmethods__["floats"] = _read_all_float - if _newclass: floats = property(_read_all_float, None, doc='Returns an array with all the contents of this SBData represented as float values') - - __swig_getmethods__["doubles"] = _read_all_double - if _newclass: doubles = property(_read_all_double, None, doc='Returns an array with all the contents of this SBData represented as double values') - - %} - - %pythoncode %{ - __swig_getmethods__["byte_order"] = GetByteOrder - __swig_setmethods__["byte_order"] = SetByteOrder - if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='Allows getting and setting the endianness of this SBData object') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='Returns the size (in bytes) of the contents of this SBData object') - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBDebugger.i b/lldb/scripts/Python/interface/SBDebugger.i deleted file mode 100644 index 465c856f3930..000000000000 --- a/lldb/scripts/Python/interface/SBDebugger.i +++ /dev/null @@ -1,363 +0,0 @@ -//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"SBDebugger is the primordial object that creates SBTargets and provides -access to them. It also manages the overall debugging experiences. - -For example (from example/disasm.py), - -import lldb -import os -import sys - -def disassemble_instructions (insts): - for i in insts: - print i - -... - -# Create a new debugger instance -debugger = lldb.SBDebugger.Create() - -# When we step or continue, don't return from the function until the process -# stops. We do this by setting the async mode to false. -debugger.SetAsync (False) - -# Create a target from a file and arch -print 'Creating a target for \'%s\'' % exe - -target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) - -if target: - # If the target is valid set a breakpoint at main - main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename()); - - print main_bp - - # Launch the process. Since we specified synchronous mode, we won't return - # from this function until we hit the breakpoint at main - process = target.LaunchSimple (None, None, os.getcwd()) - - # Make sure the launch went ok - if process: - # Print some simple process info - state = process.GetState () - print process - if state == lldb.eStateStopped: - # Get the first thread - thread = process.GetThreadAtIndex (0) - if thread: - # Print some simple thread info - print thread - # Get the first frame - frame = thread.GetFrameAtIndex (0) - if frame: - # Print some simple frame info - print frame - function = frame.GetFunction() - # See if we have debug info (a function) - if function: - # We do have a function, print some info for the function - print function - # Now get all instructions for this function and print them - insts = function.GetInstructions(target) - disassemble_instructions (insts) - else: - # See if we have a symbol in the symbol table for where we stopped - symbol = frame.GetSymbol(); - if symbol: - # We do have a symbol, print some info for the symbol - print symbol - # Now get all instructions for this symbol and print them - insts = symbol.GetInstructions(target) - disassemble_instructions (insts) - - registerList = frame.GetRegisters() - print 'Frame registers (size of register set = %d):' % registerList.GetSize() - for value in registerList: - #print value - print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()) - for child in value: - print 'Name: ', child.GetName(), ' Value: ', child.GetValue(frame) - - print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program' - next = sys.stdin.readline() - if not next or next.rstrip('\n') == 'quit': - print 'Terminating the inferior process...' - process.Kill() - else: - # Now continue to the program exit - process.Continue() - # When we return from the above function we will hopefully be at the - # program exit. Print out some process info - print process - elif state == lldb.eStateExited: - print 'Didn\'t hit the breakpoint at main, program has exited...' - else: - print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state) - process.Kill() -") SBDebugger; -class SBDebugger -{ -public: - - static void - Initialize(); - - static void - Terminate(); - - static lldb::SBDebugger - Create(); - - static lldb::SBDebugger - Create(bool source_init_files); - - static void - Destroy (lldb::SBDebugger &debugger); - - static void - MemoryPressureDetected(); - - SBDebugger(); - - SBDebugger(const lldb::SBDebugger &rhs); - - ~SBDebugger(); - - bool - IsValid() const; - - void - Clear (); - - void - SetAsync (bool b); - - bool - GetAsync (); - - void - SkipLLDBInitFiles (bool b); - - void - SetInputFileHandle (FILE *f, bool transfer_ownership); - - void - SetOutputFileHandle (FILE *f, bool transfer_ownership); - - void - SetErrorFileHandle (FILE *f, bool transfer_ownership); - - FILE * - GetInputFileHandle (); - - FILE * - GetOutputFileHandle (); - - FILE * - GetErrorFileHandle (); - - lldb::SBCommandInterpreter - GetCommandInterpreter (); - - void - HandleCommand (const char *command); - - lldb::SBListener - GetListener (); - - void - HandleProcessEvent (const lldb::SBProcess &process, - const lldb::SBEvent &event, - FILE *out, - FILE *err); - - lldb::SBTarget - CreateTarget (const char *filename, - const char *target_triple, - const char *platform_name, - bool add_dependent_modules, - lldb::SBError& sb_error); - - lldb::SBTarget - CreateTargetWithFileAndTargetTriple (const char *filename, - const char *target_triple); - - lldb::SBTarget - CreateTargetWithFileAndArch (const char *filename, - const char *archname); - - lldb::SBTarget - CreateTarget (const char *filename); - - %feature("docstring", - "Return true if target is deleted from the target list of the debugger." - ) DeleteTarget; - bool - DeleteTarget (lldb::SBTarget &target); - - lldb::SBTarget - GetTargetAtIndex (uint32_t idx); - - lldb::SBTarget - FindTargetWithProcessID (pid_t pid); - - lldb::SBTarget - FindTargetWithFileAndArch (const char *filename, - const char *arch); - - uint32_t - GetNumTargets (); - - lldb::SBTarget - GetSelectedTarget (); - - void - SetSelectedTarget (lldb::SBTarget &target); - - lldb::SBSourceManager - GetSourceManager (); - - // REMOVE: just for a quick fix, need to expose platforms through - // SBPlatform from this class. - lldb::SBError - SetCurrentPlatform (const char *platform_name); - - bool - SetCurrentPlatformSDKRoot (const char *sysroot); - - // FIXME: Once we get the set show stuff in place, the driver won't need - // an interface to the Set/Get UseExternalEditor. - bool - SetUseExternalEditor (bool input); - - bool - GetUseExternalEditor (); - - static bool - GetDefaultArchitecture (char *arch_name, size_t arch_name_len); - - static bool - SetDefaultArchitecture (const char *arch_name); - - lldb::ScriptLanguage - GetScriptingLanguage (const char *script_language_name); - - static const char * - GetVersionString (); - - static const char * - StateAsCString (lldb::StateType state); - - static bool - StateIsRunningState (lldb::StateType state); - - static bool - StateIsStoppedState (lldb::StateType state); - - bool - EnableLog (const char *channel, const char ** types); - - void - DispatchInput (void *baton, const void *data, size_t data_len); - - void - DispatchInputInterrupt (); - - void - DispatchInputEndOfFile (); - - void - PushInputReader (lldb::SBInputReader &reader); - - void - NotifyTopInputReader (lldb::InputReaderAction notification); - - bool - InputReaderIsTopReader (const lldb::SBInputReader &reader); - - const char * - GetInstanceName (); - - static SBDebugger - FindDebuggerWithID (int id); - - static lldb::SBError - SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); - - static lldb::SBStringList - GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - GetTerminalWidth () const; - - void - SetTerminalWidth (uint32_t term_width); - - lldb::user_id_t - GetID (); - - const char * - GetPrompt() const; - - void - SetPrompt (const char *prompt); - - lldb::ScriptLanguage - GetScriptLanguage() const; - - void - SetScriptLanguage (lldb::ScriptLanguage script_lang); - - bool - GetCloseInputOnEOF () const; - - void - SetCloseInputOnEOF (bool b); - - lldb::SBTypeCategory - GetCategory (const char* category_name); - - lldb::SBTypeCategory - CreateCategory (const char* category_name); - - bool - DeleteCategory (const char* category_name); - - uint32_t - GetNumCategories (); - - lldb::SBTypeCategory - GetCategoryAtIndex (uint32_t); - - lldb::SBTypeCategory - GetDefaultCategory(); - - lldb::SBTypeFormat - GetFormatForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSummary - GetSummaryForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFilter - GetFilterForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSynthetic - GetSyntheticForType (lldb::SBTypeNameSpecifier); - -}; // class SBDebugger - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBError.i b/lldb/scripts/Python/interface/SBError.i deleted file mode 100644 index 60b051af7c05..000000000000 --- a/lldb/scripts/Python/interface/SBError.i +++ /dev/null @@ -1,126 +0,0 @@ -//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a container for holding any error code. - -For example (from test/python_api/hello_world/TestHelloWorld.py), - - def hello_world_attach_with_id_api(self): - '''Create target, spawn a process, and attach to it by id.''' - - target = self.dbg.CreateTarget(self.exe) - - # Spawn a new process and don't display the stdout if not in TraceOn() mode. - import subprocess - popen = subprocess.Popen([self.exe, 'abc', 'xyz'], - stdout = open(os.devnull, 'w') if not self.TraceOn() else None) - - listener = lldb.SBListener('my.attach.listener') - error = lldb.SBError() - process = target.AttachToProcessWithID(listener, popen.pid, error) - - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - - # Let's check the stack traces of the attached process. - import lldbutil - stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) - self.expect(stacktraces, exe=False, - substrs = ['main.c:%d' % self.line2, - '(int)argc=3']) - - listener = lldb.SBListener('my.attach.listener') - error = lldb.SBError() - process = target.AttachToProcessWithID(listener, popen.pid, error) - - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - -checks that after the attach, there is no error condition by asserting -that error.Success() is True and we get back a valid process object. - -And (from test/python_api/event/TestEvent.py), - - # Now launch the process, and do not stop at entry point. - error = lldb.SBError() - process = target.Launch(listener, None, None, None, None, None, None, 0, False, error) - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - -checks that after calling the target.Launch() method there's no error -condition and we get back a void process object. -") SBError; -class SBError { -public: - SBError (); - - SBError (const lldb::SBError &rhs); - - ~SBError(); - - const char * - GetCString () const; - - void - Clear (); - - bool - Fail () const; - - bool - Success () const; - - uint32_t - GetError () const; - - lldb::ErrorType - GetType () const; - - void - SetError (uint32_t err, lldb::ErrorType type); - - void - SetErrorToErrno (); - - void - SetErrorToGenericError (); - - void - SetErrorString (const char *err_str); - - int - SetErrorStringWithFormat (const char *format, ...); - - bool - IsValid () const; - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - __swig_getmethods__["value"] = GetError - if _newclass: x = property(GetError, None) - - __swig_getmethods__["fail"] = Fail - if _newclass: x = property(Fail, None) - - __swig_getmethods__["success"] = Success - if _newclass: x = property(Success, None) - - __swig_getmethods__["description"] = GetCString - if _newclass: x = property(GetCString, None) - - __swig_getmethods__["type"] = GetType - if _newclass: x = property(GetType, None) - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBEvent.i b/lldb/scripts/Python/interface/SBEvent.i deleted file mode 100644 index b360e34b75f2..000000000000 --- a/lldb/scripts/Python/interface/SBEvent.i +++ /dev/null @@ -1,153 +0,0 @@ -//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBBroadcaster; - -%feature("docstring", -"API clients can register to receive events. - -For example, check out the following output: - -Try wait for event... -Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running} -Event data flavor: Process::ProcessEventData -Process state: running - -Try wait for event... -Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped} -Event data flavor: Process::ProcessEventData -Process state: stopped - -Try wait for event... -Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited} -Event data flavor: Process::ProcessEventData -Process state: exited - -Try wait for event... -timeout occurred waiting for event... - -from test/python_api/event/TestEventspy: - - def do_listen_for_and_print_event(self): - '''Create a listener and use SBEvent API to print the events received.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - - # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process.GetState() == lldb.eStateStopped, - PROCESS_STOPPED) - - # Get a handle on the process's broadcaster. - broadcaster = process.GetBroadcaster() - - # Create an empty event object. - event = lldb.SBEvent() - - # Create a listener object and register with the broadcaster. - listener = lldb.SBListener('my listener') - rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) - self.assertTrue(rc, 'AddListener successfully retruns') - - traceOn = self.TraceOn() - if traceOn: - lldbutil.print_stacktraces(process) - - # Create MyListeningThread class to wait for any kind of event. - import threading - class MyListeningThread(threading.Thread): - def run(self): - count = 0 - # Let's only try at most 4 times to retrieve any kind of event. - # After that, the thread exits. - while not count > 3: - if traceOn: - print 'Try wait for event...' - if listener.WaitForEventForBroadcasterWithType(5, - broadcaster, - lldb.SBProcess.eBroadcastBitStateChanged, - event): - if traceOn: - desc = lldbutil.get_description(event) - print 'Event description:', desc - print 'Event data flavor:', event.GetDataFlavor() - print 'Process state:', lldbutil.state_type_to_str(process.GetState()) - print - else: - if traceOn: - print 'timeout occurred waiting for event...' - count = count + 1 - return - - # Let's start the listening thread to retrieve the events. - my_thread = MyListeningThread() - my_thread.start() - - # Use Python API to continue the process. The listening thread should be - # able to receive the state changed events. - process.Continue() - - # Use Python API to kill the process. The listening thread should be - # able to receive the state changed event, too. - process.Kill() - - # Wait until the 'MyListeningThread' terminates. - my_thread.join() -") SBEvent; -class SBEvent -{ -public: - SBEvent(); - - SBEvent (const lldb::SBEvent &rhs); - - %feature("autodoc", - "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)" - ) SBEvent; - SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len); - - ~SBEvent(); - - bool - IsValid() const; - - const char * - GetDataFlavor (); - - uint32_t - GetType () const; - - lldb::SBBroadcaster - GetBroadcaster () const; - - const char * - GetBroadcasterClass () const; - - bool - BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster); - - void - Clear(); - - static const char * - GetCStringFromEvent (const lldb::SBEvent &event); - - bool - GetDescription (lldb::SBStream &description) const; -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBFileSpec.i b/lldb/scripts/Python/interface/SBFileSpec.i deleted file mode 100644 index ae23c8fd5fc4..000000000000 --- a/lldb/scripts/Python/interface/SBFileSpec.i +++ /dev/null @@ -1,97 +0,0 @@ -//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a file specfication that divides the path into a directory and -basename. The string values of the paths are put into uniqued string pools -for fast comparisons and efficient memory usage. - -For example, the following code - - lineEntry = context.GetLineEntry() - self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory', - exe=False, - substrs = [self.mydir]) - self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename', - exe=False, - substrs = ['main.c']) - self.assertTrue(lineEntry.GetLine() == self.line, - 'The line entry's line number should match ') - -gets the line entry from the symbol context when a thread is stopped. -It gets the file spec corresponding to the line entry and checks that -the filename and the directory matches wat we expect. -") SBFileSpec; -class SBFileSpec -{ -public: - SBFileSpec (); - - SBFileSpec (const lldb::SBFileSpec &rhs); - - SBFileSpec (const char *path);// Deprected, use SBFileSpec (const char *path, bool resolve) - - SBFileSpec (const char *path, bool resolve); - - ~SBFileSpec (); - - bool - IsValid() const; - - bool - Exists () const; - - bool - ResolveExecutableLocation (); - - const char * - GetFilename() const; - - const char * - GetDirectory() const; - - uint32_t - GetPath (char *dst_path, size_t dst_len) const; - - static int - ResolvePath (const char *src_path, char *dst_path, size_t dst_len); - - bool - GetDescription (lldb::SBStream &description) const; - - %pythoncode %{ - def __get_fullpath__(self): - spec_dir = self.GetDirectory() - spec_file = self.GetFilename() - if spec_dir and spec_file: - return '%s/%s' % (spec_dir, spec_file) - elif spec_dir: - return spec_dir - elif spec_file: - return spec_file - return None - - __swig_getmethods__["fullpath"] = __get_fullpath__ - if _newclass: x = property(__get_fullpath__, None) - - __swig_getmethods__["basename"] = GetFilename - if _newclass: x = property(GetFilename, None) - - __swig_getmethods__["dirname"] = GetDirectory - if _newclass: x = property(GetDirectory, None) - - __swig_getmethods__["exists"] = Exists - if _newclass: x = property(Exists, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBFileSpecList.i b/lldb/scripts/Python/interface/SBFileSpecList.i deleted file mode 100644 index 38a6f43bdc76..000000000000 --- a/lldb/scripts/Python/interface/SBFileSpecList.i +++ /dev/null @@ -1,45 +0,0 @@ -//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBFileSpecList -{ -public: - SBFileSpecList (); - - SBFileSpecList (const lldb::SBFileSpecList &rhs); - - ~SBFileSpecList (); - - uint32_t - GetSize () const; - - bool - GetDescription (SBStream &description) const; - - void - Append (const SBFileSpec &sb_file); - - bool - AppendIfUnique (const SBFileSpec &sb_file); - - void - Clear(); - - uint32_t - FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); - - const SBFileSpec - GetFileSpecAtIndex (uint32_t idx) const; - -}; - - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBFrame.i b/lldb/scripts/Python/interface/SBFrame.i deleted file mode 100644 index 4bedbff8cce8..000000000000 --- a/lldb/scripts/Python/interface/SBFrame.i +++ /dev/null @@ -1,343 +0,0 @@ -//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents one of the stack frames associated with a thread. -SBThread contains SBFrame(s). For example (from test/lldbutil.py), - -def print_stacktrace(thread, string_buffer = False): - '''Prints a simple stack trace of this thread.''' - - ... - - for i in range(depth): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - - load_addr = addrs[i].GetLoadAddress(target) - if not function: - file_addr = addrs[i].GetFileAddress() - start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress() - symbol_offset = file_addr - start_addr - print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( - num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset) - else: - print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( - num=i, addr=load_addr, mod=mods[i], - func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i], - file=files[i], line=lines[i], - args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()') - - ... - -And, - - for frame in thread: - print frame - -See also SBThread." -) SBFrame; -class SBFrame -{ -public: - SBFrame (); - - SBFrame (const lldb::SBFrame &rhs); - - ~SBFrame(); - - bool - IsEqual (const lldb::SBFrame &rhs) const; - - bool - IsValid() const; - - uint32_t - GetFrameID () const; - - lldb::addr_t - GetPC () const; - - bool - SetPC (lldb::addr_t new_pc); - - lldb::addr_t - GetSP () const; - - lldb::addr_t - GetFP () const; - - lldb::SBAddress - GetPCAddress () const; - - lldb::SBSymbolContext - GetSymbolContext (uint32_t resolve_scope) const; - - lldb::SBModule - GetModule () const; - - lldb::SBCompileUnit - GetCompileUnit () const; - - lldb::SBFunction - GetFunction () const; - - lldb::SBSymbol - GetSymbol () const; - - %feature("docstring", " - /// Gets the deepest block that contains the frame PC. - /// - /// See also GetFrameBlock(). - ") GetBlock; - lldb::SBBlock - GetBlock () const; - - %feature("docstring", " - /// Get the appropriate function name for this frame. Inlined functions in - /// LLDB are represented by Blocks that have inlined function information, so - /// just looking at the SBFunction or SBSymbol for a frame isn't enough. - /// This function will return the appriopriate function, symbol or inlined - /// function name for the frame. - /// - /// This function returns: - /// - the name of the inlined function (if there is one) - /// - the name of the concrete function (if there is one) - /// - the name of the symbol (if there is one) - /// - NULL - /// - /// See also IsInlined(). - ") GetFunctionName; - const char * - GetFunctionName(); - - %feature("docstring", " - /// Return true if this frame represents an inlined function. - /// - /// See also GetFunctionName(). - ") IsInlined; - bool - IsInlined(); - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") EvaluateExpression; - lldb::SBValue - EvaluateExpression (const char *expr); - - lldb::SBValue - EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic); - - %feature("docstring", " - /// Gets the lexical block that defines the stack frame. Another way to think - /// of this is it will return the block that contains all of the variables - /// for a stack frame. Inlined functions are represented as SBBlock objects - /// that have inlined function information: the name of the inlined function, - /// where it was called from. The block that is returned will be the first - /// block at or above the block for the PC (SBFrame::GetBlock()) that defines - /// the scope of the frame. When a function contains no inlined functions, - /// this will be the top most lexical block that defines the function. - /// When a function has inlined functions and the PC is currently - /// in one of those inlined functions, this method will return the inlined - /// block that defines this frame. If the PC isn't currently in an inlined - /// function, the lexical block that defines the function is returned. - ") GetFrameBlock; - lldb::SBBlock - GetFrameBlock () const; - - lldb::SBLineEntry - GetLineEntry () const; - - lldb::SBThread - GetThread () const; - - const char * - Disassemble () const; - - void - Clear(); - -#ifndef SWIG - bool - operator == (const lldb::SBFrame &rhs) const; - - bool - operator != (const lldb::SBFrame &rhs) const; - -#endif - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") GetVariables; - lldb::SBValueList - GetVariables (bool arguments, - bool locals, - bool statics, - bool in_scope_only); - - lldb::SBValueList - GetVariables (bool arguments, - bool locals, - bool statics, - bool in_scope_only, - lldb::DynamicValueType use_dynamic); - - lldb::SBValueList - GetRegisters (); - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") FindVariable; - lldb::SBValue - FindVariable (const char *var_name); - - lldb::SBValue - FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); - - %feature("docstring", " - /// Get a lldb.SBValue for a variable path. - /// - /// Variable paths can include access to pointer or instance members: - /// rect_ptr->origin.y - /// pt.x - /// Pointer dereferences: - /// *this->foo_ptr - /// **argv - /// Address of: - /// &pt - /// &my_array[3].x - /// Array accesses and treating pointers as arrays: - /// int_array[1] - /// pt_ptr[22].x - /// - /// Unlike EvaluateExpression() which returns lldb.SBValue objects - /// with constant copies of the values at the time of evaluation, - /// the result of this function is a value that will continue to - /// track the current value of the value as execution progresses - /// in the current frame. - ") GetValueForVariablePath; - lldb::SBValue - GetValueForVariablePath (const char *var_path); - - lldb::SBValue - GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic); - - %feature("docstring", " - /// Find variables, register sets, registers, or persistent variables using - /// the frame as the scope. - /// - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") FindValue; - lldb::SBValue - FindValue (const char *name, ValueType value_type); - - lldb::SBValue - FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - def get_all_variables(self): - return self.GetVariables(True,True,True,True) - - def get_arguments(self): - return self.GetVariables(True,False,False,False) - - def get_locals(self): - return self.GetVariables(False,True,False,False) - - def get_statics(self): - return self.GetVariables(False,False,True,False) - - def var(self, var_expr_path): - '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns - a value that represents the variable expression path''' - return self.GetValueForVariablePath(var_expr_path) - - __swig_getmethods__["pc"] = GetPC - __swig_setmethods__["pc"] = SetPC - if _newclass: x = property(GetPC, SetPC) - - __swig_getmethods__["addr"] = GetPCAddress - if _newclass: x = property(GetPCAddress, None) - - __swig_getmethods__["fp"] = GetFP - if _newclass: x = property(GetFP, None) - - __swig_getmethods__["sp"] = GetSP - if _newclass: x = property(GetSP, None) - - __swig_getmethods__["module"] = GetModule - if _newclass: x = property(GetModule, None) - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: x = property(GetCompileUnit, None) - - __swig_getmethods__["function"] = GetFunction - if _newclass: x = property(GetFunction, None) - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: x = property(GetSymbol, None) - - __swig_getmethods__["block"] = GetBlock - if _newclass: x = property(GetBlock, None) - - __swig_getmethods__["is_inlined"] = IsInlined - if _newclass: x = property(IsInlined, None) - - __swig_getmethods__["name"] = GetFunctionName - if _newclass: x = property(GetFunctionName, None) - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: x = property(GetLineEntry, None) - - __swig_getmethods__["thread"] = GetThread - if _newclass: x = property(GetThread, None) - - __swig_getmethods__["disassembly"] = Disassemble - if _newclass: x = property(Disassemble, None) - - __swig_getmethods__["idx"] = GetFrameID - if _newclass: x = property(GetFrameID, None) - - __swig_getmethods__["variables"] = get_all_variables - if _newclass: x = property(get_all_variables, None) - - __swig_getmethods__["vars"] = get_all_variables - if _newclass: x = property(get_all_variables, None) - - __swig_getmethods__["locals"] = get_locals - if _newclass: x = property(get_locals, None) - - __swig_getmethods__["args"] = get_arguments - if _newclass: x = property(get_arguments, None) - - __swig_getmethods__["arguments"] = get_arguments - if _newclass: x = property(get_arguments, None) - - __swig_getmethods__["statics"] = get_statics - if _newclass: x = property(get_statics, None) - - __swig_getmethods__["registers"] = GetRegisters - if _newclass: x = property(GetRegisters, None) - - __swig_getmethods__["regs"] = GetRegisters - if _newclass: x = property(GetRegisters, None) - - %} -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBFunction.i b/lldb/scripts/Python/interface/SBFunction.i deleted file mode 100644 index e259490310b2..000000000000 --- a/lldb/scripts/Python/interface/SBFunction.i +++ /dev/null @@ -1,117 +0,0 @@ -//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a generic function, which can be inlined or not. - -For example (from test/lldbutil.py, but slightly modified for doc purpose), - - ... - - frame = thread.GetFrameAtIndex(i) - addr = frame.GetPCAddress() - load_addr = addr.GetLoadAddress(target) - function = frame.GetFunction() - mod_name = frame.GetModule().GetFileSpec().GetFilename() - - if not function: - # No debug info for 'function'. - symbol = frame.GetSymbol() - file_addr = addr.GetFileAddress() - start_addr = symbol.GetStartAddress().GetFileAddress() - symbol_name = symbol.GetName() - symbol_offset = file_addr - start_addr - print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( - num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset) - else: - # Debug info is available for 'function'. - func_name = frame.GetFunctionName() - file_name = frame.GetLineEntry().GetFileSpec().GetFilename() - line_num = frame.GetLineEntry().GetLine() - print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( - num=i, addr=load_addr, mod=mod_name, - func='%s [inlined]' % func_name] if frame.IsInlined() else func_name, - file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False)) - - ... -") SBFunction; -class SBFunction -{ -public: - - SBFunction (); - - SBFunction (const lldb::SBFunction &rhs); - - ~SBFunction (); - - bool - IsValid () const; - - const char * - GetName() const; - - const char * - GetMangledName () const; - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target); - - lldb::SBAddress - GetStartAddress (); - - lldb::SBAddress - GetEndAddress (); - - uint32_t - GetPrologueByteSize (); - - lldb::SBType - GetType (); - - lldb::SBBlock - GetBlock (); - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - def get_instructions_from_current_target (self): - return self.GetInstructions (target) - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: x = property(GetStartAddress, None) - - __swig_getmethods__["block"] = GetBlock - if _newclass: x = property(GetBlock, None) - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: x = property(GetEndAddress, None) - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: x = property(get_instructions_from_current_target, None) - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: x = property(GetMangledName, None) - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: x = property(GetPrologueByteSize, None) - - __swig_getmethods__["type"] = GetType - if _newclass: x = property(GetType, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBHostOS.i b/lldb/scripts/Python/interface/SBHostOS.i deleted file mode 100644 index 826548a8c5bc..000000000000 --- a/lldb/scripts/Python/interface/SBHostOS.i +++ /dev/null @@ -1,41 +0,0 @@ -//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBHostOS -{ -public: - - static lldb::SBFileSpec - GetProgramFileSpec (); - - static void - ThreadCreated (const char *name); - - static lldb::thread_t - ThreadCreate (const char *name, - void *(*thread_function)(void *), - void *thread_arg, - lldb::SBError *err); - - static bool - ThreadCancel (lldb::thread_t thread, - lldb::SBError *err); - - static bool - ThreadDetach (lldb::thread_t thread, - lldb::SBError *err); - static bool - ThreadJoin (lldb::thread_t thread, - void **result, - lldb::SBError *err); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBInputReader.i b/lldb/scripts/Python/interface/SBInputReader.i deleted file mode 100644 index 939862423579..000000000000 --- a/lldb/scripts/Python/interface/SBInputReader.i +++ /dev/null @@ -1,53 +0,0 @@ -//===-- SWIG Interface for SBInputREader ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBInputReader -{ -public: - - typedef size_t (*Callback) (void *baton, - SBInputReader *reader, - InputReaderAction notification, - const char *bytes, - size_t bytes_len); - - SBInputReader (); - - SBInputReader (const lldb::SBInputReader &rhs); - - ~SBInputReader (); - - SBError - Initialize (SBDebugger &debugger, - Callback callback, - void *callback_baton, - lldb::InputReaderGranularity granularity, - const char *end_token, - const char *prompt, - bool echo); - - bool - IsValid () const; - - bool - IsActive () const; - - bool - IsDone () const; - - void - SetIsDone (bool value); - - InputReaderGranularity - GetGranularity (); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBInstruction.i b/lldb/scripts/Python/interface/SBInstruction.i deleted file mode 100644 index 3c0d65ef842c..000000000000 --- a/lldb/scripts/Python/interface/SBInstruction.i +++ /dev/null @@ -1,103 +0,0 @@ -//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> - -// There's a lot to be fixed here, but need to wait for underlying insn implementation -// to be revised & settle down first. - -namespace lldb { - -class SBInstruction -{ -public: - - SBInstruction (); - - SBInstruction (const SBInstruction &rhs); - - ~SBInstruction (); - - bool - IsValid(); - - lldb::SBAddress - GetAddress(); - - lldb::AddressClass - GetAddressClass (); - - const char * - GetMnemonic (lldb::SBTarget target); - - const char * - GetOperands (lldb::SBTarget target); - - const char * - GetComment (lldb::SBTarget target); - - lldb::SBData - GetData (lldb::SBTarget target); - - size_t - GetByteSize (); - - bool - DoesBranch (); - - void - Print (FILE *out); - - bool - GetDescription (lldb::SBStream &description); - - bool - EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options); - - bool - DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'arm-apple-darwin' - - bool - TestEmulation (lldb::SBStream &output_stream, const char *test_file); - - %pythoncode %{ - def __mnemonic_property__ (self): - return self.GetMnemonic (target) - def __operands_property__ (self): - return self.GetOperands (target) - def __comment_property__ (self): - return self.GetComment (target) - def __file_addr_property__ (self): - return self.GetAddress ().GetFileAddress() - def __load_adrr_property__ (self): - return self.GetComment (target) - - __swig_getmethods__["mnemonic"] = __mnemonic_property__ - if _newclass: x = property(__mnemonic_property__, None) - - __swig_getmethods__["operands"] = __operands_property__ - if _newclass: x = property(__operands_property__, None) - - __swig_getmethods__["comment"] = __comment_property__ - if _newclass: x = property(__comment_property__, None) - - __swig_getmethods__["addr"] = GetAddress - if _newclass: x = property(GetAddress, None) - - __swig_getmethods__["size"] = GetByteSize - if _newclass: x = property(GetByteSize, None) - - __swig_getmethods__["is_branch"] = DoesBranch - if _newclass: x = property(DoesBranch, None) - %} - - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBInstructionList.i b/lldb/scripts/Python/interface/SBInstructionList.i deleted file mode 100644 index b2bb3496e34e..000000000000 --- a/lldb/scripts/Python/interface/SBInstructionList.i +++ /dev/null @@ -1,91 +0,0 @@ -//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> - -namespace lldb { - -%feature("docstring", -"Represents a list of machine instructions. SBFunction and SBSymbol have -GetInstructions() methods which return SBInstructionList instances. - -SBInstructionList supports instruction (SBInstruction instance) iteration. -For example (see also SBDebugger for a more complete example), - -def disassemble_instructions (insts): - for i in insts: - print i - -defines a function which takes an SBInstructionList instance and prints out -the machine instructions in assembly format." -) SBInstructionList; -class SBInstructionList -{ -public: - - SBInstructionList (); - - SBInstructionList (const SBInstructionList &rhs); - - ~SBInstructionList (); - - bool - IsValid () const; - - size_t - GetSize (); - - lldb::SBInstruction - GetInstructionAtIndex (uint32_t idx); - - void - Clear (); - - void - AppendInstruction (lldb::SBInstruction inst); - - void - Print (FILE *out); - - bool - GetDescription (lldb::SBStream &description); - - bool - DumpEmulationForAllInstructions (const char *triple); - - %pythoncode %{ - def __len__(self): - '''Access len of the instruction list.''' - return self.GetSize(); - - def __getitem__(self, key): - '''Access instructions by integer index.''' - if type(key) is int: - # Find an instruction by index - if key < len(self): - return self.GetInstructionAtIndex(key) - elif type(key) is SBAddress: - # Find an instruction using a lldb.SBAddress object - lookup_file_addr = key.file_addr - closest_inst = None - for idx in range(self.GetSize()): - inst = self.GetInstructionAtIndex(idx) - inst_file_addr = inst.addr.file_addr - if inst_file_addr == lookup_file_addr: - return inst - elif inst_file_addr > lookup_file_addr: - return closest_inst - else: - closest_inst = inst - return None - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBLineEntry.i b/lldb/scripts/Python/interface/SBLineEntry.i deleted file mode 100644 index 61d6a64e9ca5..000000000000 --- a/lldb/scripts/Python/interface/SBLineEntry.i +++ /dev/null @@ -1,100 +0,0 @@ -//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Specifies an association with a contiguous range of instructions and -a source file location. SBCompileUnit contains SBLineEntry(s). For example, - - for lineEntry in compileUnit: - print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), - lineEntry.GetLine()) - print 'start addr: %s' % str(lineEntry.GetStartAddress()) - print 'end addr: %s' % str(lineEntry.GetEndAddress()) - -produces: - -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 -start addr: a.out[0x100000d98] -end addr: a.out[0x100000da3] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 -start addr: a.out[0x100000da3] -end addr: a.out[0x100000da9] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 -start addr: a.out[0x100000da9] -end addr: a.out[0x100000db6] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 -start addr: a.out[0x100000db6] -end addr: a.out[0x100000dbc] -... - -See also SBCompileUnit." -) SBLineEntry; -class SBLineEntry -{ -public: - - SBLineEntry (); - - SBLineEntry (const lldb::SBLineEntry &rhs); - - ~SBLineEntry (); - - lldb::SBAddress - GetStartAddress () const; - - lldb::SBAddress - GetEndAddress () const; - - bool - IsValid () const; - - lldb::SBFileSpec - GetFileSpec () const; - - uint32_t - GetLine () const; - - uint32_t - GetColumn () const; - - bool - GetDescription (lldb::SBStream &description); - - void - SetFileSpec (lldb::SBFileSpec filespec); - - void - SetLine (uint32_t line); - - void - SetColumn (uint32_t column); - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: x = property(GetFileSpec, None) - - __swig_getmethods__["line"] = GetLine - if _newclass: x = property(GetLine, None) - - __swig_getmethods__["column"] = GetColumn - if _newclass: x = property(GetColumn, None) - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: x = property(GetStartAddress, None) - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: x = property(GetEndAddress, None) - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBListener.i b/lldb/scripts/Python/interface/SBListener.i deleted file mode 100644 index 9560b91bdb14..000000000000 --- a/lldb/scripts/Python/interface/SBListener.i +++ /dev/null @@ -1,99 +0,0 @@ -//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"API clients can register its own listener to debugger events. - -See aslo SBEvent for example usage of creating and adding a listener." -) SBListener; -class SBListener -{ -public: - SBListener (); - - SBListener (const char *name); - - SBListener (const SBListener &rhs); - - ~SBListener (); - - void - AddEvent (const lldb::SBEvent &event); - - void - Clear (); - - bool - IsValid () const; - - uint32_t - StartListeningForEventClass (SBDebugger &debugger, - const char *broadcaster_class, - uint32_t event_mask); - - uint32_t - StopListeningForEventClass (SBDebugger &debugger, - const char *broadcaster_class, - uint32_t event_mask); - - uint32_t - StartListeningForEvents (const lldb::SBBroadcaster& broadcaster, - uint32_t event_mask); - - bool - StopListeningForEvents (const lldb::SBBroadcaster& broadcaster, - uint32_t event_mask); - - // Returns true if an event was recieved, false if we timed out. - bool - WaitForEvent (uint32_t num_seconds, - lldb::SBEvent &event); - - bool - WaitForEventForBroadcaster (uint32_t num_seconds, - const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - WaitForEventForBroadcasterWithType (uint32_t num_seconds, - const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - PeekAtNextEvent (lldb::SBEvent &sb_event); - - bool - PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - GetNextEvent (lldb::SBEvent &sb_event); - - bool - GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - HandleBroadcastEvent (const lldb::SBEvent &event); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i deleted file mode 100644 index 1b6d4ecac432..000000000000 --- a/lldb/scripts/Python/interface/SBModule.i +++ /dev/null @@ -1,400 +0,0 @@ -//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an executable image and its associated object and symbol files. - -The module is designed to be able to select a single slice of an -executable image as it would appear on disk and during program -execution. - -You can retrieve SBModule from SBSymbolContext, which in turn is available -from SBFrame. - -SBModule supports symbol iteration, for example, - - for symbol in module: - name = symbol.GetName() - saddr = symbol.GetStartAddress() - eaddr = symbol.GetEndAddress() - -and rich comparion methods which allow the API program to use, - - if thisModule == thatModule: - print 'This module is the same as that module' - -to test module equality. A module also contains object file sections, namely -SBSection. SBModule supports section iteration through section_iter(), for -example, - - print 'Number of sections: %d' % module.GetNumSections() - for sec in module.section_iter(): - print sec - -And to iterate the symbols within a SBSection, use symbol_in_section_iter(), - - # Iterates the text section and prints each symbols within each sub-section. - for subsec in text_sec: - print INDENT + repr(subsec) - for sym in exe_module.symbol_in_section_iter(subsec): - print INDENT2 + repr(sym) - print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) - -produces this following output: - - [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text - id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) - symbol type: code - id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) - symbol type: code - id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) - symbol type: code - id = {0x00000023}, name = 'start', address = 0x0000000100001780 - symbol type: code - [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs - id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) - symbol type: trampoline - id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) - symbol type: trampoline - id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) - symbol type: trampoline - id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) - symbol type: trampoline - id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) - symbol type: trampoline - id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) - symbol type: trampoline - id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) - symbol type: trampoline - id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) - symbol type: trampoline - id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) - symbol type: trampoline - id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) - symbol type: trampoline - id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) - symbol type: trampoline - id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) - symbol type: trampoline - [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper - [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring - [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info - [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame -" -) SBModule; -class SBModule -{ -public: - - SBModule (); - - SBModule (const SBModule &rhs); - - SBModule (lldb::SBProcess &process, - lldb::addr_t header_addr); - - ~SBModule (); - - bool - IsValid () const; - - void - Clear(); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get const accessor for the module file specification. - /// - /// This function returns the file for the module on the host system - /// that is running LLDB. This can differ from the path on the - /// platform since we might be doing remote debugging. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - ") GetFileSpec; - lldb::SBFileSpec - GetFileSpec () const; - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get accessor for the module platform file specification. - /// - /// Platform file refers to the path of the module as it is known on - /// the remote system on which it is being debugged. For local - /// debugging this is always the same as Module::GetFileSpec(). But - /// remote debugging might mention a file '/usr/lib/liba.dylib' - /// which might be locally downloaded and cached. In this case the - /// platform file could be something like: - /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' - /// The file could also be cached in a local developer kit directory. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - ") GetPlatformFileSpec; - lldb::SBFileSpec - GetPlatformFileSpec () const; - - bool - SetPlatformFileSpec (const lldb::SBFileSpec &platform_file); - - %feature("docstring", "Returns the UUID of the module as a Python string." - ) GetUUIDString; - const char * - GetUUIDString () const; - - lldb::SBSection - FindSection (const char *sect_name); - - lldb::SBAddress - ResolveFileAddress (lldb::addr_t vm_addr); - - lldb::SBSymbolContext - ResolveSymbolContextForAddress (const lldb::SBAddress& addr, - uint32_t resolve_scope); - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - GetNumCompileUnits(); - - lldb::SBCompileUnit - GetCompileUnitAtIndex (uint32_t); - - size_t - GetNumSymbols (); - - lldb::SBSymbol - GetSymbolAtIndex (size_t idx); - - size_t - GetNumSections (); - - lldb::SBSection - GetSectionAtIndex (size_t idx); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find functions by name. - /// - /// @param[in] name - /// The name of the function we are looking for. - /// - /// @param[in] name_type_mask - /// A logical OR of one or more FunctionNameType enum bits that - /// indicate what kind of names should be used when doing the - /// lookup. Bits include fully qualified names, base names, - /// C++ methods, or ObjC selectors. - /// See FunctionNameType for more details. - /// - /// @return - /// A symbol context list that gets filled in with all of the - /// matches. - //------------------------------------------------------------------ - ") FindFunctions; - lldb::SBSymbolContextList - FindFunctions (const char *name, - uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - - lldb::SBType - FindFirstType (const char* name); - - lldb::SBTypeList - FindTypes (const char* type); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find global and static variables by name. - /// - /// @param[in] target - /// A valid SBTarget instance representing the debuggee. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @param[in] max_matches - /// Allow the number of matches to be limited to \a max_matches. - /// - /// @return - /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ - ") FindGlobalVariables; - lldb::SBValueList - FindGlobalVariables (lldb::SBTarget &target, - const char *name, - uint32_t max_matches); - - lldb::ByteOrder - GetByteOrder (); - - uint32_t - GetAddressByteSize(); - - const char * - GetTriple (); - - uint32_t - GetVersion (uint32_t *versions, - uint32_t num_versions); - - %pythoncode %{ - class symbols_access(object): - re_compile_type = type(re.compile('.')) - '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' - def __init__(self, sbmodule): - self.sbmodule = sbmodule - - def __len__(self): - if self.sbmodule: - return self.sbmodule.GetNumSymbols() - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.sbmodule.GetSymbolAtIndex(key) - elif type(key) is str: - matches = [] - for idx in range(count): - symbol = self.sbmodule.GetSymbolAtIndex(idx) - if symbol.name == key or symbol.mangled == key: - matches.append(symbol) - return matches - elif isinstance(key, self.re_compile_type): - matches = [] - for idx in range(count): - symbol = self.sbmodule.GetSymbolAtIndex(idx) - added = False - name = symbol.name - if name: - re_match = key.search(name) - if re_match: - matches.append(symbol) - added = True - if not added: - mangled = symbol.mangled - if mangled: - re_match = key.search(mangled) - if re_match: - matches.append(symbol) - return matches - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_symbols_access_object(self): - '''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.''' - return self.symbols_access (self) - - def get_symbols_array(self): - '''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.''' - symbols = [] - for idx in range(self.num_symbols): - symbols.append(self.GetSymbolAtIndex(idx)) - return symbols - - class sections_access(object): - re_compile_type = type(re.compile('.')) - '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' - def __init__(self, sbmodule): - self.sbmodule = sbmodule - - def __len__(self): - if self.sbmodule: - return self.sbmodule.GetNumSections() - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.sbmodule.GetSectionAtIndex(key) - elif type(key) is str: - for idx in range(count): - section = self.sbmodule.GetSectionAtIndex(idx) - if section.name == key: - return section - elif isinstance(key, self.re_compile_type): - matches = [] - for idx in range(count): - section = self.sbmodule.GetSectionAtIndex(idx) - name = section.name - if name: - re_match = key.search(name) - if re_match: - matches.append(section) - return matches - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_sections_access_object(self): - '''An accessor function that returns a sections_access() object which allows lazy section array access.''' - return self.sections_access (self) - - def get_sections_array(self): - '''An accessor function that returns an array object that contains all sections in this module object.''' - if not hasattr(self, 'sections'): - self.sections = [] - for idx in range(self.num_sections): - self.sections.append(self.GetSectionAtIndex(idx)) - return self.sections - - __swig_getmethods__["symbols"] = get_symbols_array - if _newclass: x = property(get_symbols_array, None) - - __swig_getmethods__["symbol"] = get_symbols_access_object - if _newclass: x = property(get_symbols_access_object, None) - - __swig_getmethods__["sections"] = get_sections_array - if _newclass: x = property(get_sections_array, None) - - __swig_getmethods__["section"] = get_sections_access_object - if _newclass: x = property(get_sections_access_object, None) - - def get_uuid(self): - return uuid.UUID (self.GetUUIDString()) - - __swig_getmethods__["uuid"] = get_uuid - if _newclass: x = property(get_uuid, None) - - __swig_getmethods__["file"] = GetFileSpec - if _newclass: x = property(GetFileSpec, None) - - __swig_getmethods__["platform_file"] = GetPlatformFileSpec - if _newclass: x = property(GetPlatformFileSpec, None) - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: x = property(GetByteOrder, None) - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: x = property(GetAddressByteSize, None) - - __swig_getmethods__["triple"] = GetTriple - if _newclass: x = property(GetTriple, None) - - __swig_getmethods__["num_symbols"] = GetNumSymbols - if _newclass: x = property(GetNumSymbols, None) - - __swig_getmethods__["num_sections"] = GetNumSections - if _newclass: x = property(GetNumSections, None) - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBProcess.i b/lldb/scripts/Python/interface/SBProcess.i deleted file mode 100644 index 37100557f9cc..000000000000 --- a/lldb/scripts/Python/interface/SBProcess.i +++ /dev/null @@ -1,386 +0,0 @@ -//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the process associated with the target program. - -SBProcess supports thread iteration. For example (from test/lldbutil.py), - -# ================================================== -# Utility functions related to Threads and Processes -# ================================================== - -def get_stopped_threads(process, reason): - '''Returns the thread(s) with the specified stop reason in a list. - - The list can be empty if no such thread exists. - ''' - threads = [] - for t in process: - if t.GetStopReason() == reason: - threads.append(t) - return threads - -... -" -) SBProcess; -class SBProcess -{ -public: - //------------------------------------------------------------------ - /// Broadcaster event bits definitions. - //------------------------------------------------------------------ - enum - { - eBroadcastBitStateChanged = (1 << 0), - eBroadcastBitInterrupt = (1 << 1), - eBroadcastBitSTDOUT = (1 << 2), - eBroadcastBitSTDERR = (1 << 3) - }; - - SBProcess (); - - SBProcess (const lldb::SBProcess& rhs); - - ~SBProcess(); - - static const char * - GetBroadcasterClassName (); - - void - Clear (); - - bool - IsValid() const; - - lldb::SBTarget - GetTarget() const; - - lldb::ByteOrder - GetByteOrder() const; - - %feature("autodoc", " - Writes data into the current process's stdin. API client specifies a Python - string as the only argument. - ") PutSTDIN; - size_t - PutSTDIN (const char *src, size_t src_len); - - %feature("autodoc", " - Reads data from the current process's stdout stream. API client specifies - the size of the buffer to read data into. It returns the byte buffer in a - Python string. - ") GetSTDOUT; - size_t - GetSTDOUT (char *dst, size_t dst_len) const; - - %feature("autodoc", " - Reads data from the current process's stderr stream. API client specifies - the size of the buffer to read data into. It returns the byte buffer in a - Python string. - ") GetSTDERR; - size_t - GetSTDERR (char *dst, size_t dst_len) const; - - void - ReportEventState (const lldb::SBEvent &event, FILE *out) const; - - void - AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Remote connection related functions. These will fail if the - /// process is not in eStateConnected. They are intended for use - /// when connecting to an externally managed debugserver instance. - //------------------------------------------------------------------ - ") RemoteAttachToProcessWithID; - bool - RemoteAttachToProcessWithID (lldb::pid_t pid, - lldb::SBError& error); - - %feature("docstring", - "See SBTarget.Launch for argument description and usage." - ) RemoteLaunch; - bool - RemoteLaunch (char const **argv, - char const **envp, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory, - uint32_t launch_flags, - bool stop_at_entry, - lldb::SBError& error); - - //------------------------------------------------------------------ - // Thread related functions - //------------------------------------------------------------------ - uint32_t - GetNumThreads (); - - lldb::SBThread - GetThreadAtIndex (size_t index); - - lldb::SBThread - GetThreadByID (lldb::tid_t sb_thread_id); - - lldb::SBThread - GetSelectedThread () const; - - bool - SetSelectedThread (const lldb::SBThread &thread); - - bool - SetSelectedThreadByID (uint32_t tid); - - //------------------------------------------------------------------ - // Stepping related functions - //------------------------------------------------------------------ - - lldb::StateType - GetState (); - - int - GetExitStatus (); - - const char * - GetExitDescription (); - - lldb::pid_t - GetProcessID (); - - uint32_t - GetAddressByteSize() const; - - %feature("docstring", " - Kills the process and shuts down all threads that were spawned to - track and monitor process. - ") Destroy; - lldb::SBError - Destroy (); - - lldb::SBError - Continue (); - - lldb::SBError - Stop (); - - %feature("docstring", "Same as Destroy(self).") Destroy; - lldb::SBError - Kill (); - - lldb::SBError - Detach (); - - %feature("docstring", "Sends the process a unix signal.") Signal; - lldb::SBError - Signal (int signal); - - %feature("autodoc", " - Reads memory from the current process's address space and removes any - traps that may have been inserted into the memory. It returns the byte - buffer in a Python string. Example: - - # Read 4 bytes from address 'addr' and assume error.Success() is True. - content = process.ReadMemory(addr, 4, error) - # Use 'ascii' encoding as each byte of 'content' is within [0..255]. - new_bytes = bytearray(content, 'ascii') - ") ReadMemory; - size_t - ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Writes memory to the current process's address space and maintains any - traps that might be present due to software breakpoints. Example: - - # Create a Python string from the byte array. - new_value = str(bytes) - result = process.WriteMemory(addr, new_value, error) - if not error.Success() or result != len(bytes): - print 'SBProcess.WriteMemory() failed!' - ") WriteMemory; - size_t - WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Reads a NULL terminated C string from the current process's address space. - It returns a python string of the exact length, or truncates the string if - the maximum character limit is reached. Example: - - # Read a C string of at most 256 bytes from address '0x1000' - error = lldb.SBError() - cstring = process.ReadCStringFromMemory(0x1000, 256, error) - if error.Success(): - print 'cstring: ', cstring - else - print 'error: ', error - ") ReadCStringFromMemory; - - size_t - ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Reads an unsigned integer from memory given a byte size and an address. - Returns the unsigned integer that was read. Example: - - # Read a 4 byte unsigned integer from address 0x1000 - error = lldb.SBError() - uint = ReadUnsignedFromMemory(0x1000, 4, error) - if error.Success(): - print 'integer: %u' % uint - else - print 'error: ', error - - ") ReadUnsignedFromMemory; - - uint64_t - ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); - - %feature("autodoc", " - Reads a pointer from memory from an address and returns the value. Example: - - # Read a pointer from address 0x1000 - error = lldb.SBError() - ptr = ReadPointerFromMemory(0x1000, error) - if error.Success(): - print 'pointer: 0x%x' % ptr - else - print 'error: ', error - - ") ReadPointerFromMemory; - - lldb::addr_t - ReadPointerFromMemory (addr_t addr, lldb::SBError &error); - - - // Events - static lldb::StateType - GetStateFromEvent (const lldb::SBEvent &event); - - static bool - GetRestartedFromEvent (const lldb::SBEvent &event); - - static lldb::SBProcess - GetProcessFromEvent (const lldb::SBEvent &event); - - static bool - EventIsProcessEvent (const lldb::SBEvent &event); - - lldb::SBBroadcaster - GetBroadcaster () const; - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); - - lldb::SBError - UnloadImage (uint32_t image_token); - - %pythoncode %{ - def __get_is_alive__(self): - '''Returns "True" if the process is currently alive, "False" otherwise''' - s = self.GetState() - if (s == eStateAttaching or - s == eStateLaunching or - s == eStateStopped or - s == eStateRunning or - s == eStateStepping or - s == eStateCrashed or - s == eStateSuspended): - return True - return False - - def __get_is_running__(self): - '''Returns "True" if the process is currently running, "False" otherwise''' - state = self.GetState() - if state == eStateRunning or state == eStateStepping: - return True - return False - - def __get_is_running__(self): - '''Returns "True" if the process is currently stopped, "False" otherwise''' - state = self.GetState() - if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: - return True - return False - - class threads_access(object): - '''A helper object that will lazily hand out thread for a process when supplied an index.''' - def __init__(self, sbprocess): - self.sbprocess = sbprocess - - def __len__(self): - if self.sbprocess: return self.sbprocess.GetNumThreads() - return 0 - - def __getitem__(self, key): - if type(key) is int and key < len(self): - return self.sbprocess.GetThreadAtIndex(key) - return None - - def get_threads_access_object(self): - '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.''' - return self.threads_access (self) - - def get_process_thread_list(self): - '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.''' - threads = [] - for idx in range(self.GetNumThreads()): - threads.append(GetThreadAtIndex(idx)) - return threads - - __swig_getmethods__["threads"] = get_process_thread_list - if _newclass: x = property(get_process_thread_list, None) - - __swig_getmethods__["thread"] = get_threads_access_object - if _newclass: x = property(get_threads_access_object, None) - - __swig_getmethods__["is_alive"] = __get_is_alive__ - if _newclass: x = property(__get_is_alive__, None) - - __swig_getmethods__["is_running"] = __get_is_running__ - if _newclass: x = property(__get_is_running__, None) - - __swig_getmethods__["is_stopped"] = __get_is_running__ - if _newclass: x = property(__get_is_running__, None) - - __swig_getmethods__["id"] = GetProcessID - if _newclass: x = property(GetProcessID, None) - - __swig_getmethods__["target"] = GetTarget - if _newclass: x = property(GetTarget, None) - - __swig_getmethods__["num_threads"] = GetNumThreads - if _newclass: x = property(GetNumThreads, None) - - __swig_getmethods__["selected_thread"] = GetSelectedThread - __swig_setmethods__["selected_thread"] = SetSelectedThread - if _newclass: x = property(GetSelectedThread, SetSelectedThread) - - __swig_getmethods__["state"] = GetState - if _newclass: x = property(GetState, None) - - __swig_getmethods__["exit_state"] = GetExitStatus - if _newclass: x = property(GetExitStatus, None) - - __swig_getmethods__["exit_description"] = GetExitDescription - if _newclass: x = property(GetExitDescription, None) - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: x = property(GetBroadcaster, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBSection.i b/lldb/scripts/Python/interface/SBSection.i deleted file mode 100644 index 95838755c59e..000000000000 --- a/lldb/scripts/Python/interface/SBSection.i +++ /dev/null @@ -1,125 +0,0 @@ -//===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an executable image section. - -SBSection supports iteration through its subsection, represented as SBSection -as well. For example, - - for sec in exe_module: - if sec.GetName() == '__TEXT': - print sec - break - print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections() - for subsec in sec: - print INDENT + repr(subsec) - -produces: - -[0x0000000100000000-0x0000000100002000) a.out.__TEXT - Number of subsections: 6 - [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text - [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs - [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper - [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring - [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info - [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame - -See also SBModule." -) SBSection; - -class SBSection -{ -public: - - SBSection (); - - SBSection (const lldb::SBSection &rhs); - - ~SBSection (); - - bool - IsValid () const; - - const char * - GetName (); - - lldb::SBSection - FindSubSection (const char *sect_name); - - size_t - GetNumSubSections (); - - lldb::SBSection - GetSubSectionAtIndex (size_t idx); - - lldb::addr_t - GetFileAddress (); - - lldb::addr_t - GetByteSize (); - - uint64_t - GetFileOffset (); - - uint64_t - GetFileByteSize (); - - lldb::SBData - GetSectionData (); - - lldb::SBData - GetSectionData (uint64_t offset, - uint64_t size); - - SectionType - GetSectionType (); - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - def get_addr(self): - return SBAddress(self, 0) - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["addr"] = get_addr - if _newclass: x = property(get_addr, None) - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: x = property(GetFileAddress, None) - - __swig_getmethods__["size"] = GetByteSize - if _newclass: x = property(GetByteSize, None) - - __swig_getmethods__["file_offset"] = GetFileOffset - if _newclass: x = property(GetFileOffset, None) - - __swig_getmethods__["file_size"] = GetFileByteSize - if _newclass: x = property(GetFileByteSize, None) - - __swig_getmethods__["data"] = GetSectionData - if _newclass: x = property(GetSectionData, None) - - __swig_getmethods__["type"] = GetSectionType - if _newclass: x = property(GetSectionType, None) - - %} - -private: - - std::auto_ptr<lldb_private::SectionImpl> m_opaque_ap; -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBSourceManager.i b/lldb/scripts/Python/interface/SBSourceManager.i deleted file mode 100644 index 09cd449149d9..000000000000 --- a/lldb/scripts/Python/interface/SBSourceManager.i +++ /dev/null @@ -1,54 +0,0 @@ -//===-- SWIG Interface for SBSourceManager ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a central authority for displaying source code. - -For example (from test/source-manager/TestSourceManager.py), - - # Create the filespec for 'main.c'. - filespec = lldb.SBFileSpec('main.c', False) - source_mgr = self.dbg.GetSourceManager() - # Use a string stream as the destination. - stream = lldb.SBStream() - source_mgr.DisplaySourceLinesWithLineNumbers(filespec, - self.line, - 2, # context before - 2, # context after - '=>', # prefix for current line - stream) - - # 2 - # 3 int main(int argc, char const *argv[]) { - # => 4 printf('Hello world.\\n'); // Set break point at this line. - # 5 return 0; - # 6 } - self.expect(stream.GetData(), 'Source code displayed correctly', - exe=False, - patterns = ['=> %d.*Hello world' % self.line]) -") SBSourceManager; -class SBSourceManager -{ -public: - SBSourceManager (const lldb::SBSourceManager &rhs); - - ~SBSourceManager(); - - size_t - DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - lldb::SBStream &s); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBStream.i b/lldb/scripts/Python/interface/SBStream.i deleted file mode 100644 index 8a6a8e57d695..000000000000 --- a/lldb/scripts/Python/interface/SBStream.i +++ /dev/null @@ -1,94 +0,0 @@ -//===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> - -namespace lldb { - -%feature("docstring", -"Represents a destination for streaming data output to. By default, a string -stream is created. - -For example (from test/source-manager/TestSourceManager.py), - - # Create the filespec for 'main.c'. - filespec = lldb.SBFileSpec('main.c', False) - source_mgr = self.dbg.GetSourceManager() - # Use a string stream as the destination. - stream = lldb.SBStream() - source_mgr.DisplaySourceLinesWithLineNumbers(filespec, - self.line, - 2, # context before - 2, # context after - '=>', # prefix for current line - stream) - - # 2 - # 3 int main(int argc, char const *argv[]) { - # => 4 printf('Hello world.\\n'); // Set break point at this line. - # 5 return 0; - # 6 } - self.expect(stream.GetData(), 'Source code displayed correctly', - exe=False, - patterns = ['=> %d.*Hello world' % self.line]) -") SBStream; -class SBStream -{ -public: - - SBStream (); - - ~SBStream (); - - bool - IsValid() const; - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If this stream is not redirected to a file, it will maintain a local - /// cache for the stream data which can be accessed using this accessor. - //-------------------------------------------------------------------------- - ") GetData; - const char * - GetData (); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If this stream is not redirected to a file, it will maintain a local - /// cache for the stream output whose length can be accessed using this - /// accessor. - //-------------------------------------------------------------------------- - ") GetSize; - size_t - GetSize(); - - void - Printf (const char *format, ...); - - void - RedirectToFile (const char *path, bool append); - - void - RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership); - - void - RedirectToFileDescriptor (int fd, bool transfer_fh_ownership); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If the stream is redirected to a file, forget about the file and if - /// ownership of the file was transfered to this object, close the file. - /// If the stream is backed by a local cache, clear this cache. - //-------------------------------------------------------------------------- - ") Clear; - void - Clear (); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBStringList.i b/lldb/scripts/Python/interface/SBStringList.i deleted file mode 100644 index 901aa88b183a..000000000000 --- a/lldb/scripts/Python/interface/SBStringList.i +++ /dev/null @@ -1,44 +0,0 @@ -//===-- SWIG Interface for SBStringList -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBStringList -{ -public: - - SBStringList (); - - SBStringList (const lldb::SBStringList &rhs); - - ~SBStringList (); - - bool - IsValid() const; - - void - AppendString (const char *str); - - void - AppendList (const char **strv, int strc); - - void - AppendList (const lldb::SBStringList &strings); - - uint32_t - GetSize () const; - - const char * - GetStringAtIndex (size_t idx); - - void - Clear (); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBSymbol.i b/lldb/scripts/Python/interface/SBSymbol.i deleted file mode 100644 index 4995c4f9c494..000000000000 --- a/lldb/scripts/Python/interface/SBSymbol.i +++ /dev/null @@ -1,98 +0,0 @@ -//===-- SWIG Interface for SBSymbol -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the symbol possibly associated with a stack frame. -SBModule contains SBSymbol(s). SBSymbol can also be retrived from SBFrame. - -See also SBModule and SBFrame." -) SBSymbol; -class SBSymbol -{ -public: - - SBSymbol (); - - ~SBSymbol (); - - SBSymbol (const lldb::SBSymbol &rhs); - - bool - IsValid () const; - - - const char * - GetName() const; - - const char * - GetMangledName () const; - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target); - - SBAddress - GetStartAddress (); - - SBAddress - GetEndAddress (); - - uint32_t - GetPrologueByteSize (); - - SymbolType - GetType (); - - bool - GetDescription (lldb::SBStream &description); - - bool - IsExternal(); - - bool - IsSynthetic(); - - %pythoncode %{ - def get_instructions_from_current_target (self): - return self.GetInstructions (target) - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: x = property(GetMangledName, None) - - __swig_getmethods__["type"] = GetType - if _newclass: x = property(GetType, None) - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: x = property(GetStartAddress, None) - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: x = property(GetEndAddress, None) - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: x = property(GetPrologueByteSize, None) - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: x = property(get_instructions_from_current_target, None) - - __swig_getmethods__["external"] = IsExternal - if _newclass: x = property(IsExternal, None) - - __swig_getmethods__["synthetic"] = IsSynthetic - if _newclass: x = property(IsSynthetic, None) - - - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBSymbolContext.i b/lldb/scripts/Python/interface/SBSymbolContext.i deleted file mode 100644 index 4bf7fe347882..000000000000 --- a/lldb/scripts/Python/interface/SBSymbolContext.i +++ /dev/null @@ -1,112 +0,0 @@ -//===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"A context object that provides access to core debugger entities. - -Manay debugger functions require a context when doing lookups. This class -provides a common structure that can be used as the result of a query that -can contain a single result. - -For example, - - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target for the debugger. - target = self.dbg.CreateTarget(exe) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - - # The inferior should stop on 'c'. - from lldbutil import get_stopped_thread - thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - frame0 = thread.GetFrameAtIndex(0) - - # Now get the SBSymbolContext from this frame. We want everything. :-) - context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) - - # Get the module. - module = context.GetModule() - ... - - # And the compile unit associated with the frame. - compileUnit = context.GetCompileUnit() - ... -" -) SBSymbolContext; -class SBSymbolContext -{ -public: - SBSymbolContext (); - - SBSymbolContext (const lldb::SBSymbolContext& rhs); - - ~SBSymbolContext (); - - bool - IsValid () const; - - lldb::SBModule GetModule (); - lldb::SBCompileUnit GetCompileUnit (); - lldb::SBFunction GetFunction (); - lldb::SBBlock GetBlock (); - lldb::SBLineEntry GetLineEntry (); - lldb::SBSymbol GetSymbol (); - - void SetModule (lldb::SBModule module); - void SetCompileUnit (lldb::SBCompileUnit compile_unit); - void SetFunction (lldb::SBFunction function); - void SetBlock (lldb::SBBlock block); - void SetLineEntry (lldb::SBLineEntry line_entry); - void SetSymbol (lldb::SBSymbol symbol); - - lldb::SBSymbolContext - GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc, - lldb::SBAddress &parent_frame_addr) const; - - - bool - GetDescription (lldb::SBStream &description); - - - %pythoncode %{ - __swig_getmethods__["module"] = GetModule - __swig_setmethods__["module"] = SetModule - if _newclass: x = property(GetModule, SetModule) - - __swig_getmethods__["compile_unit"] = GetCompileUnit - __swig_setmethods__["compile_unit"] = SetCompileUnit - if _newclass: x = property(GetCompileUnit, SetCompileUnit) - - __swig_getmethods__["function"] = GetFunction - __swig_setmethods__["function"] = SetFunction - if _newclass: x = property(GetFunction, SetFunction) - - __swig_getmethods__["block"] = GetBlock - __swig_setmethods__["block"] = SetBlock - if _newclass: x = property(GetBlock, SetBlock) - - __swig_getmethods__["symbol"] = GetSymbol - __swig_setmethods__["symbol"] = SetSymbol - if _newclass: x = property(GetSymbol, SetSymbol) - - __swig_getmethods__["line_entry"] = GetLineEntry - __swig_setmethods__["line_entry"] = SetLineEntry - if _newclass: x = property(GetLineEntry, SetLineEntry) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBSymbolContextList.i b/lldb/scripts/Python/interface/SBSymbolContextList.i deleted file mode 100644 index 0a03a22d4ab3..000000000000 --- a/lldb/scripts/Python/interface/SBSymbolContextList.i +++ /dev/null @@ -1,140 +0,0 @@ -//===-- SWIG Interface for SBSymbolContextList ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a list of symbol context object. See also SBSymbolContext. - -For example (from test/python_api/target/TestTargetAPI.py), - - def find_functions(self, exe_name): - '''Exercise SBTaget.FindFunctions() API.''' - exe = os.path.join(os.getcwd(), exe_name) - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - list = lldb.SBSymbolContextList() - num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list) - self.assertTrue(num == 1 and list.GetSize() == 1) - - for sc in list: - self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name) - self.assertTrue(sc.GetSymbol().GetName() == 'c') -") SBSymbolContextList; -class SBSymbolContextList -{ -public: - SBSymbolContextList (); - - SBSymbolContextList (const lldb::SBSymbolContextList& rhs); - - ~SBSymbolContextList (); - - bool - IsValid () const; - - uint32_t - GetSize() const; - - SBSymbolContext - GetContextAtIndex (uint32_t idx); - - void - Append (lldb::SBSymbolContext &sc); - - void - Append (lldb::SBSymbolContextList &sc_list); - - bool - GetDescription (lldb::SBStream &description); - - void - Clear(); - - %pythoncode %{ - def __len__(self): - return self.GetSize() - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.GetContextAtIndex(key) - else: - raise IndexError - raise TypeError - - def get_module_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).module - if obj: - a.append(obj) - return a - - def get_compile_unit_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).compile_unit - if obj: - a.append(obj) - return a - def get_function_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).function - if obj: - a.append(obj) - return a - def get_block_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).block - if obj: - a.append(obj) - return a - def get_symbol_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).symbol - if obj: - a.append(obj) - return a - def get_line_entry_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).line_entry - if obj: - a.append(obj) - return a - __swig_getmethods__["modules"] = get_module_array - if _newclass: x = property(get_module_array, None) - - __swig_getmethods__["compile_units"] = get_compile_unit_array - if _newclass: x = property(get_compile_unit_array, None) - - __swig_getmethods__["functions"] = get_function_array - if _newclass: x = property(get_function_array, None) - - __swig_getmethods__["blocks"] = get_block_array - if _newclass: x = property(get_block_array, None) - - __swig_getmethods__["line_entries"] = get_line_entry_array - if _newclass: x = property(get_line_entry_array, None) - - __swig_getmethods__["symbols"] = get_symbol_array - if _newclass: x = property(get_symbol_array, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i deleted file mode 100644 index fccecd3b490e..000000000000 --- a/lldb/scripts/Python/interface/SBTarget.i +++ /dev/null @@ -1,778 +0,0 @@ -//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBLaunchInfo -{ -public: - SBLaunchInfo (const char **argv); - - uint32_t - GetUserID(); - - uint32_t - GetGroupID(); - - bool - UserIDIsValid (); - - bool - GroupIDIsValid (); - - void - SetUserID (uint32_t uid); - - void - SetGroupID (uint32_t gid); - - uint32_t - GetNumArguments (); - - const char * - GetArgumentAtIndex (uint32_t idx); - - void - SetArguments (const char **argv, bool append); - - uint32_t - GetNumEnvironmentEntries (); - - const char * - GetEnvironmentEntryAtIndex (uint32_t idx); - - void - SetEnvironmentEntries (const char **envp, bool append); - - void - Clear (); - - const char * - GetWorkingDirectory () const; - - void - SetWorkingDirectory (const char *working_dir); - - uint32_t - GetLaunchFlags (); - - void - SetLaunchFlags (uint32_t flags); - - const char * - GetProcessPluginName (); - - void - SetProcessPluginName (const char *plugin_name); - - const char * - GetShell (); - - void - SetShell (const char * path); - - uint32_t - GetResumeCount (); - - void - SetResumeCount (uint32_t c); - - bool - AddCloseFileAction (int fd); - - bool - AddDuplicateFileAction (int fd, int dup_fd); - - bool - AddOpenFileAction (int fd, const char *path, bool read, bool write); - - bool - AddSuppressFileAction (int fd, bool read, bool write); -}; - -class SBAttachInfo -{ -public: - SBAttachInfo (); - - SBAttachInfo (lldb::pid_t pid); - - SBAttachInfo (const char *path, bool wait_for); - - SBAttachInfo (const lldb::SBAttachInfo &rhs); - - lldb::pid_t - GetProcessID (); - - void - SetProcessID (lldb::pid_t pid); - - void - SetExecutable (const char *path); - - void - SetExecutable (lldb::SBFileSpec exe_file); - - bool - GetWaitForLaunch (); - - void - SetWaitForLaunch (bool b); - - uint32_t - GetResumeCount (); - - void - SetResumeCount (uint32_t c); - - const char * - GetProcessPluginName (); - - void - SetProcessPluginName (const char *plugin_name); - - uint32_t - GetUserID(); - - uint32_t - GetGroupID(); - - bool - UserIDIsValid (); - - bool - GroupIDIsValid (); - - void - SetUserID (uint32_t uid); - - void - SetGroupID (uint32_t gid); - - uint32_t - GetEffectiveUserID(); - - uint32_t - GetEffectiveGroupID(); - - bool - EffectiveUserIDIsValid (); - - bool - EffectiveGroupIDIsValid (); - - void - SetEffectiveUserID (uint32_t uid); - - void - SetEffectiveGroupID (uint32_t gid); - - lldb::pid_t - GetParentProcessID (); - - void - SetParentProcessID (lldb::pid_t pid); - - bool - ParentProcessIDIsValid(); -}; - - -%feature("docstring", -"Represents the target program running under the debugger. - -SBTarget supports module, breakpoint, and watchpoint iterations. For example, - - for m in target.module_iter(): - print m - -produces: - -(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out -(x86_64) /usr/lib/dyld -(x86_64) /usr/lib/libstdc++.6.dylib -(x86_64) /usr/lib/libSystem.B.dylib -(x86_64) /usr/lib/system/libmathCommon.A.dylib -(x86_64) /usr/lib/libSystem.B.dylib(__commpage) - -and, - - for b in target.breakpoint_iter(): - print b - -produces: - -SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 -SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 - -and, - - for wp_loc in target.watchpoint_iter(): - print wp_loc - -produces: - -Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw - declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' - hw_index = 0 hit_count = 2 ignore_count = 0" -) SBTarget; -class SBTarget -{ -public: - //------------------------------------------------------------------ - // Broadcaster bits. - //------------------------------------------------------------------ - enum - { - eBroadcastBitBreakpointChanged = (1 << 0), - eBroadcastBitModulesLoaded = (1 << 1), - eBroadcastBitModulesUnloaded = (1 << 2) - }; - - //------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------ - SBTarget (); - - SBTarget (const lldb::SBTarget& rhs); - - //------------------------------------------------------------------ - // Destructor - //------------------------------------------------------------------ - ~SBTarget(); - - static const char * - GetBroadcasterClassName (); - - bool - IsValid() const; - - lldb::SBProcess - GetProcess (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Launch a new process. - /// - /// Launch a new process by spawning a new process using the - /// target object's executable module's file as the file to launch. - /// Arguments are given in \a argv, and the environment variables - /// are in \a envp. Standard input and output files can be - /// optionally re-directed to \a stdin_path, \a stdout_path, and - /// \a stderr_path. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] argv - /// The argument array. - /// - /// @param[in] envp - /// The environment array. - /// - /// @param[in] launch_flags - /// Flags to modify the launch (@see lldb::LaunchFlags) - /// - /// @param[in] stdin_path - /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stdout_path - /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stderr_path - /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] working_directory - /// The working directory to have the child process run in - /// - /// @param[in] launch_flags - /// Some launch options specified by logical OR'ing - /// lldb::LaunchFlags enumeration values together. - /// - /// @param[in] stop_at_endtry - /// If false do not stop the inferior at the entry point. - /// - /// @param[out] - /// An error object. Contains the reason if there is some failure. - /// - /// @return - /// A process object for the newly created process. - //------------------------------------------------------------------ - - For example, - - process = target.Launch(self.dbg.GetListener(), None, None, - None, '/tmp/stdout.txt', None, - None, 0, False, error) - - launches a new process by passing nothing for both the args and the envs - and redirect the standard output of the inferior to the /tmp/stdout.txt - file. It does not specify a working directory so that the debug server - will use its idea of what the current working directory is for the - inferior. Also, we ask the debugger not to stop the inferior at the - entry point. If no breakpoint is specified for the inferior, it should - run to completion if no user interaction is required. - ") Launch; - lldb::SBProcess - Launch (SBListener &listener, - char const **argv, - char const **envp, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory, - uint32_t launch_flags, // See LaunchFlags - bool stop_at_entry, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Launch a new process with sensible defaults. - /// - /// @param[in] argv - /// The argument array. - /// - /// @param[in] envp - /// The environment array. - /// - /// @param[in] working_directory - /// The working directory to have the child process run in - /// - /// Default: listener - /// Set to the target's debugger (SBTarget::GetDebugger()) - /// - /// Default: launch_flags - /// Empty launch flags - /// - /// Default: stdin_path - /// Default: stdout_path - /// Default: stderr_path - /// A pseudo terminal will be used. - /// - /// @return - /// A process object for the newly created process. - //------------------------------------------------------------------ - - For example, - - process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) - - launches a new process by passing 'X', 'Y', 'Z' as the args to the - executable. - ") LaunchSimple; - lldb::SBProcess - LaunchSimple (const char **argv, - const char **envp, - const char *working_directory); - - lldb::SBProcess - Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); - - lldb::SBProcess - Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Attach to process with pid. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] pid - /// The process ID to attach to. - /// - /// @param[out] - /// An error explaining what went wrong if attach fails. - /// - /// @return - /// A process object for the attached process. - //------------------------------------------------------------------ - ") AttachToProcessWithID; - lldb::SBProcess - AttachToProcessWithID (SBListener &listener, - lldb::pid_t pid, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Attach to process with name. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] name - /// Basename of process to attach to. - /// - /// @param[in] wait_for - /// If true wait for a new instance of 'name' to be launched. - /// - /// @param[out] - /// An error explaining what went wrong if attach fails. - /// - /// @return - /// A process object for the attached process. - //------------------------------------------------------------------ - ") AttachToProcessWithName; - lldb::SBProcess - AttachToProcessWithName (SBListener &listener, - const char *name, - bool wait_for, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Connect to a remote debug server with url. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] url - /// The url to connect to, e.g., 'connect://localhost:12345'. - /// - /// @param[in] plugin_name - /// The plugin name to be used; can be NULL. - /// - /// @param[out] - /// An error explaining what went wrong if the connect fails. - /// - /// @return - /// A process object for the connected process. - //------------------------------------------------------------------ - ") ConnectRemote; - lldb::SBProcess - ConnectRemote (SBListener &listener, - const char *url, - const char *plugin_name, - SBError& error); - - lldb::SBFileSpec - GetExecutable (); - - bool - AddModule (lldb::SBModule &module); - - lldb::SBModule - AddModule (const char *path, - const char *triple, - const char *uuid); - - uint32_t - GetNumModules () const; - - lldb::SBModule - GetModuleAtIndex (uint32_t idx); - - bool - RemoveModule (lldb::SBModule module); - - lldb::SBDebugger - GetDebugger() const; - - lldb::SBModule - FindModule (const lldb::SBFileSpec &file_spec); - - lldb::ByteOrder - GetByteOrder (); - - uint32_t - GetAddressByteSize(); - - const char * - GetTriple (); - - lldb::SBError - SetSectionLoadAddress (lldb::SBSection section, - lldb::addr_t section_base_addr); - - lldb::SBError - ClearSectionLoadAddress (lldb::SBSection section); - - lldb::SBError - SetModuleLoadAddress (lldb::SBModule module, - int64_t sections_offset); - - lldb::SBError - ClearModuleLoadAddress (lldb::SBModule module); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find functions by name. - /// - /// @param[in] name - /// The name of the function we are looking for. - /// - /// @param[in] name_type_mask - /// A logical OR of one or more FunctionNameType enum bits that - /// indicate what kind of names should be used when doing the - /// lookup. Bits include fully qualified names, base names, - /// C++ methods, or ObjC selectors. - /// See FunctionNameType for more details. - /// - /// @return - /// A lldb::SBSymbolContextList that gets filled in with all of - /// the symbol contexts for all the matches. - //------------------------------------------------------------------ - ") FindFunctions; - lldb::SBSymbolContextList - FindFunctions (const char *name, - uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - - lldb::SBType - FindFirstType (const char* type); - - lldb::SBTypeList - FindTypes (const char* type); - - lldb::SBSourceManager - GetSourceManager (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find global and static variables by name. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @param[in] max_matches - /// Allow the number of matches to be limited to \a max_matches. - /// - /// @return - /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ - ") FindGlobalVariables; - lldb::SBValueList - FindGlobalVariables (const char *name, - uint32_t max_matches); - - void - Clear (); - - lldb::SBAddress - ResolveLoadAddress (lldb::addr_t vm_addr); - - SBSymbolContext - ResolveSymbolContextForAddress (const SBAddress& addr, - uint32_t resolve_scope); - - lldb::SBBreakpoint - BreakpointCreateByLocation (const char *file, uint32_t line); - - lldb::SBBreakpoint - BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); - - lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, - uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits - const SBFileSpecList &module_list, - const SBFileSpecList &comp_unit_list); - - lldb::SBBreakpoint - BreakpointCreateByNames (const char *symbol_name[], - uint32_t num_names, - uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits - const SBFileSpecList &module_list, - const SBFileSpecList &comp_unit_list); - - lldb::SBBreakpoint - BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateForException (lldb::LanguageType language, - bool catch_bp, - bool throw_bp); - - lldb::SBBreakpoint - BreakpointCreateByAddress (addr_t address); - - uint32_t - GetNumBreakpoints () const; - - lldb::SBBreakpoint - GetBreakpointAtIndex (uint32_t idx) const; - - bool - BreakpointDelete (break_id_t break_id); - - lldb::SBBreakpoint - FindBreakpointByID (break_id_t break_id); - - bool - EnableAllBreakpoints (); - - bool - DisableAllBreakpoints (); - - bool - DeleteAllBreakpoints (); - - uint32_t - GetNumWatchpoints () const; - - lldb::SBWatchpoint - GetWatchpointAtIndex (uint32_t idx) const; - - bool - DeleteWatchpoint (lldb::watch_id_t watch_id); - - lldb::SBWatchpoint - FindWatchpointByID (lldb::watch_id_t watch_id); - - bool - EnableAllWatchpoints (); - - bool - DisableAllWatchpoints (); - - bool - DeleteAllWatchpoints (); - - lldb::SBWatchpoint - WatchAddress (lldb::addr_t addr, - size_t size, - bool read, - bool write); - - - lldb::SBBroadcaster - GetBroadcaster () const; - - lldb::SBInstructionList - ReadInstructions (lldb::SBAddress base_addr, uint32_t count); - - lldb::SBInstructionList - GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); - - bool - GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - - %pythoncode %{ - class modules_access(object): - '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' - def __init__(self, sbtarget): - self.sbtarget = sbtarget - - def __len__(self): - if self.sbtarget: - return self.sbtarget.GetNumModules() - return 0 - - def __getitem__(self, key): - num_modules = self.sbtarget.GetNumModules() - if type(key) is int: - if key < num_modules: - return self.sbtarget.GetModuleAtIndex(key) - elif type(key) is str: - if key.find('/') == -1: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.file.basename == key: - return module - else: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.file.fullpath == key: - return module - # See if the string is a UUID - the_uuid = uuid.UUID(key) - if the_uuid: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.uuid == the_uuid: - return module - elif type(key) is uuid.UUID: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.uuid == key: - return module - elif type(key) is re.SRE_Pattern: - matching_modules = [] - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - re_match = key.search(module.path.fullpath) - if re_match: - matching_modules.append(module) - return matching_modules - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_modules_access_object(self): - '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' - return self.modules_access (self) - - def get_modules_array(self): - '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' - modules = [] - for idx in range(self.GetNumModules()): - modules.append(self.GetModuleAtIndex(idx)) - return modules - - __swig_getmethods__["modules"] = get_modules_array - if _newclass: x = property(get_modules_array, None) - - __swig_getmethods__["module"] = get_modules_access_object - if _newclass: x = property(get_modules_access_object, None) - - __swig_getmethods__["process"] = GetProcess - if _newclass: x = property(GetProcess, None) - - __swig_getmethods__["executable"] = GetExecutable - if _newclass: x = property(GetExecutable, None) - - __swig_getmethods__["debugger"] = GetDebugger - if _newclass: x = property(GetDebugger, None) - - __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints - if _newclass: x = property(GetNumBreakpoints, None) - - __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints - if _newclass: x = property(GetNumWatchpoints, None) - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: x = property(GetBroadcaster, None) - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: x = property(GetByteOrder, None) - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: x = property(GetAddressByteSize, None) - - __swig_getmethods__["triple"] = GetTriple - if _newclass: x = property(GetTriple, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBThread.i b/lldb/scripts/Python/interface/SBThread.i deleted file mode 100644 index 93fd7f98e1ed..000000000000 --- a/lldb/scripts/Python/interface/SBThread.i +++ /dev/null @@ -1,240 +0,0 @@ -//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a thread of execution. SBProcess contains SBThread(s). - -SBThread supports frame iteration. For example (from test/python_api/ -lldbutil/iter/TestLLDBIterator.py), - - from lldbutil import print_stacktrace - stopped_due_to_breakpoint = False - for thread in process: - if self.TraceOn(): - print_stacktrace(thread) - ID = thread.GetThreadID() - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - stopped_due_to_breakpoint = True - for frame in thread: - self.assertTrue(frame.GetThread().GetThreadID() == ID) - if self.TraceOn(): - print frame - - self.assertTrue(stopped_due_to_breakpoint) - -See also SBProcess and SBFrame." -) SBThread; -class SBThread -{ -public: - SBThread (); - - SBThread (const lldb::SBThread &thread); - - ~SBThread(); - - bool - IsValid() const; - - void - Clear (); - - lldb::StopReason - GetStopReason(); - - %feature("docstring", " - /// Get the number of words associated with the stop reason. - /// See also GetStopReasonDataAtIndex(). - ") GetStopReasonDataCount; - size_t - GetStopReasonDataCount(); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// Get information associated with a stop reason. - /// - /// Breakpoint stop reasons will have data that consists of pairs of - /// breakpoint IDs followed by the breakpoint location IDs (they always come - /// in pairs). - /// - /// Stop Reason Count Data Type - /// ======================== ===== ========================================= - /// eStopReasonNone 0 - /// eStopReasonTrace 0 - /// eStopReasonBreakpoint N duple: {breakpoint id, location id} - /// eStopReasonWatchpoint 1 watchpoint id - /// eStopReasonSignal 1 unix signal number - /// eStopReasonException N exception data - /// eStopReasonPlanComplete 0 - //-------------------------------------------------------------------------- - ") GetStopReasonDataAtIndex; - uint64_t - GetStopReasonDataAtIndex(uint32_t idx); - - %feature("autodoc", " - Pass only an (int)length and expect to get a Python string describing the - stop reason. - ") GetStopDescription; - size_t - GetStopDescription (char *dst, size_t dst_len); - - SBValue - GetStopReturnValue (); - - lldb::tid_t - GetThreadID () const; - - uint32_t - GetIndexID () const; - - const char * - GetName () const; - - const char * - GetQueueName() const; - - void - StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); - - void - StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); - - void - StepOut (); - - void - StepOutOfFrame (lldb::SBFrame &frame); - - void - StepInstruction(bool step_over); - - SBError - StepOverUntil (lldb::SBFrame &frame, - lldb::SBFileSpec &file_spec, - uint32_t line); - - void - RunToAddress (lldb::addr_t addr); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// LLDB currently supports process centric debugging which means when any - /// thread in a process stops, all other threads are stopped. The Suspend() - /// call here tells our process to suspend a thread and not let it run when - /// the other threads in a process are allowed to run. So when - /// SBProcess::Continue() is called, any threads that aren't suspended will - /// be allowed to run. If any of the SBThread functions for stepping are - /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the - /// thread will now be allowed to run and these funtions will simply return. - /// - /// Eventually we plan to add support for thread centric debugging where - /// each thread is controlled individually and each thread would broadcast - /// its state, but we haven't implemented this yet. - /// - /// Likewise the SBThread::Resume() call will again allow the thread to run - /// when the process is continued. - /// - /// Suspend() and Resume() functions are not currently reference counted, if - /// anyone has the need for them to be reference counted, please let us - /// know. - //-------------------------------------------------------------------------- - ") Suspend; - bool - Suspend(); - - bool - Resume (); - - bool - IsSuspended(); - - uint32_t - GetNumFrames (); - - lldb::SBFrame - GetFrameAtIndex (uint32_t idx); - - lldb::SBFrame - GetSelectedFrame (); - - lldb::SBFrame - SetSelectedFrame (uint32_t frame_idx); - - lldb::SBProcess - GetProcess (); - - bool - GetDescription (lldb::SBStream &description) const; - - %pythoncode %{ - class frames_access(object): - '''A helper object that will lazily hand out frames for a thread when supplied an index.''' - def __init__(self, sbthread): - self.sbthread = sbthread - - def __len__(self): - if self.sbthread: - return self.sbthread.GetNumFrames() - return 0 - - def __getitem__(self, key): - if type(key) is int and key < self.sbthread.GetNumFrames(): - return self.sbthread.GetFrameAtIndex(key) - return None - - def get_frames_access_object(self): - '''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.''' - return self.frames_access (self) - - def get_thread_frames(self): - '''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.''' - frames = [] - for frame in self: - frames.append(frame) - return frames - - __swig_getmethods__["id"] = GetThreadID - if _newclass: x = property(GetThreadID, None) - - __swig_getmethods__["idx"] = GetIndexID - if _newclass: x = property(GetIndexID, None) - - __swig_getmethods__["return_value"] = GetStopReturnValue - if _newclass: x = property(GetStopReturnValue, None) - - __swig_getmethods__["process"] = GetProcess - if _newclass: x = property(GetProcess, None) - - __swig_getmethods__["num_frames"] = GetNumFrames - if _newclass: x = property(GetNumFrames, None) - - __swig_getmethods__["frames"] = get_thread_frames - if _newclass: x = property(get_thread_frames, None) - - __swig_getmethods__["frame"] = get_frames_access_object - if _newclass: x = property(get_frames_access_object, None) - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["queue"] = GetQueueName - if _newclass: x = property(GetQueueName, None) - - __swig_getmethods__["stop_reason"] = GetStopReason - if _newclass: x = property(GetStopReason, None) - - __swig_getmethods__["is_suspended"] = IsSuspended - if _newclass: x = property(IsSuspended, None) - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i deleted file mode 100644 index 2b1d972fd8ac..000000000000 --- a/lldb/scripts/Python/interface/SBType.i +++ /dev/null @@ -1,303 +0,0 @@ -//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", -"Represents a member of a type in lldb. -") SBTypeMember; - -class SBTypeMember -{ -public: - SBTypeMember (); - - SBTypeMember (const lldb::SBTypeMember& rhs); - - ~SBTypeMember(); - - bool - IsValid() const; - - const char * - GetName (); - - lldb::SBType - GetType (); - - uint64_t - GetOffsetInBytes(); - - uint64_t - GetOffsetInBits(); - - %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["type"] = GetType - if _newclass: x = property(GetType, None) - - __swig_getmethods__["byte_offset"] = GetOffsetInBytes - if _newclass: x = property(GetOffsetInBytes, None) - - __swig_getmethods__["bit_offset"] = GetOffsetInBits - if _newclass: x = property(GetOffsetInBits, None) - %} - -protected: - std::auto_ptr<lldb_private::TypeMemberImpl> m_opaque_ap; -}; - -%feature("docstring", -"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule -returns a SBType. - -SBType supports the eq/ne operator. For example, - -main.cpp: - -class Task { -public: - int id; - Task *next; - Task(int i, Task *n): - id(i), - next(n) - {} -}; - -int main (int argc, char const *argv[]) -{ - Task *task_head = new Task(-1, NULL); - Task *task1 = new Task(1, NULL); - Task *task2 = new Task(2, NULL); - Task *task3 = new Task(3, NULL); // Orphaned. - Task *task4 = new Task(4, NULL); - Task *task5 = new Task(5, NULL); - - task_head->next = task1; - task1->next = task2; - task2->next = task4; - task4->next = task5; - - int total = 0; - Task *t = task_head; - while (t != NULL) { - if (t->id >= 0) - ++total; - t = t->next; - } - printf('We have a total number of %d tasks\\n', total); - - // This corresponds to an empty task list. - Task *empty_task_head = new Task(-1, NULL); - - return 0; // Break at this line -} - -find_type.py: - - # Get the type 'Task'. - task_type = target.FindFirstType('Task') - self.assertTrue(task_type) - - # Get the variable 'task_head'. - frame0.FindVariable('task_head') - task_head_type = task_head.GetType() - self.assertTrue(task_head_type.IsPointerType()) - - # task_head_type is 'Task *'. - task_pointer_type = task_type.GetPointerType() - self.assertTrue(task_head_type == task_pointer_type) - - # Get the child mmember 'id' from 'task_head'. - id = task_head.GetChildMemberWithName('id') - id_type = id.GetType() - - # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h). - int_type = id_type.GetBasicType(lldb.eBasicTypeInt) - # id_type and int_type should be the same type! - self.assertTrue(id_type == int_type) - -... -") SBType; -class SBType -{ -public: - SBType (); - - SBType (const lldb::SBType &rhs); - - ~SBType (); - - bool - IsValid(); - - size_t - GetByteSize(); - - bool - IsPointerType(); - - bool - IsReferenceType(); - - lldb::SBType - GetPointerType(); - - lldb::SBType - GetPointeeType(); - - lldb::SBType - GetReferenceType(); - - lldb::SBType - GetDereferencedType(); - - lldb::SBType - GetUnqualifiedType(); - - lldb::SBType - GetBasicType (lldb::BasicType type); - - uint32_t - GetNumberOfFields (); - - uint32_t - GetNumberOfDirectBaseClasses (); - - uint32_t - GetNumberOfVirtualBaseClasses (); - - lldb::SBTypeMember - GetFieldAtIndex (uint32_t idx); - - lldb::SBTypeMember - GetDirectBaseClassAtIndex (uint32_t idx); - - lldb::SBTypeMember - GetVirtualBaseClassAtIndex (uint32_t idx); - - const char* - GetName(); - - lldb::TypeClass - GetTypeClass (); - - uint32_t - GetNumberOfTemplateArguments (); - - lldb::SBType - GetTemplateArgumentType (uint32_t idx); - - lldb::TemplateArgumentKind - GetTemplateArgumentKind (uint32_t idx); - - bool - IsTypeComplete (); - - %pythoncode %{ - def template_arg_array(self): - num_args = self.num_template_args - if num_args: - template_args = [] - for i in range(num_args): - template_args.append(self.GetTemplateArgumentType(i)) - return template_args - return None - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["size"] = GetByteSize - if _newclass: x = property(GetByteSize, None) - - __swig_getmethods__["is_pointer"] = IsPointerType - if _newclass: x = property(IsPointerType, None) - - __swig_getmethods__["is_reference"] = IsReferenceType - if _newclass: x = property(IsReferenceType, None) - - __swig_getmethods__["num_fields"] = GetNumberOfFields - if _newclass: x = property(GetNumberOfFields, None) - - __swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses - if _newclass: x = property(GetNumberOfDirectBaseClasses, None) - - __swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses - if _newclass: x = property(GetNumberOfVirtualBaseClasses, None) - - __swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments - if _newclass: x = property(GetNumberOfTemplateArguments, None) - - __swig_getmethods__["template_args"] = template_arg_array - if _newclass: x = property(template_arg_array, None) - - __swig_getmethods__["class"] = GetTypeClass - if _newclass: x = property(GetTypeClass, None) - - __swig_getmethods__["is_complete"] = IsTypeComplete - if _newclass: is_complete = property(IsTypeComplete, None) - %} - -}; - -%feature("docstring", -"Represents a list of SBTypes. The FindTypes() method of SBTarget/SBModule -returns a SBTypeList. - -SBTypeList supports SBType iteration. For example, - -main.cpp: - -class Task { -public: - int id; - Task *next; - Task(int i, Task *n): - id(i), - next(n) - {} -}; - -... - -find_type.py: - - # Get the type 'Task'. - type_list = target.FindTypes('Task') - self.assertTrue(len(type_list) == 1) - # To illustrate the SBType iteration. - for type in type_list: - # do something with type - -... -") SBTypeList; -class SBTypeList -{ -public: - SBTypeList(); - - bool - IsValid(); - - void - Append (lldb::SBType type); - - lldb::SBType - GetTypeAtIndex (uint32_t index); - - uint32_t - GetSize(); - - ~SBTypeList(); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBTypeCategory.i b/lldb/scripts/Python/interface/SBTypeCategory.i deleted file mode 100644 index fa1a63c7df3d..000000000000 --- a/lldb/scripts/Python/interface/SBTypeCategory.i +++ /dev/null @@ -1,140 +0,0 @@ -//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a category that can contain formatters for types. - ") SBTypeCategory; - - class SBTypeCategory - { - public: - - SBTypeCategory(); - - SBTypeCategory (const lldb::SBTypeCategory &rhs); - - ~SBTypeCategory (); - - bool - IsValid() const; - - bool - GetEnabled (); - - void - SetEnabled (bool); - - const char* - GetName(); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - uint32_t - GetNumFormats (); - - uint32_t - GetNumSummaries (); - - uint32_t - GetNumFilters (); - - uint32_t - GetNumSynthetics (); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForFilterAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForFormatAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForSummaryAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); - - lldb::SBTypeFilter - GetFilterForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFormat - GetFormatForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSummary - GetSummaryForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSynthetic - GetSyntheticForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFilter - GetFilterAtIndex (uint32_t); - - lldb::SBTypeFormat - GetFormatAtIndex (uint32_t); - - lldb::SBTypeSummary - GetSummaryAtIndex (uint32_t); - - lldb::SBTypeSynthetic - GetSyntheticAtIndex (uint32_t); - - bool - AddTypeFormat (lldb::SBTypeNameSpecifier, - lldb::SBTypeFormat); - - bool - DeleteTypeFormat (lldb::SBTypeNameSpecifier); - - bool - AddTypeSummary (lldb::SBTypeNameSpecifier, - lldb::SBTypeSummary); - - bool - DeleteTypeSummary (lldb::SBTypeNameSpecifier); - - bool - AddTypeFilter (lldb::SBTypeNameSpecifier, - lldb::SBTypeFilter); - - bool - DeleteTypeFilter (lldb::SBTypeNameSpecifier); - - bool - AddTypeSynthetic (lldb::SBTypeNameSpecifier, - lldb::SBTypeSynthetic); - - bool - DeleteTypeSynthetic (lldb::SBTypeNameSpecifier); - - %pythoncode %{ - __swig_getmethods__["num_formats"] = GetNumFormats - if _newclass: x = property(GetNumFormats, None) - __swig_getmethods__["num_summaries"] = GetNumSummaries - if _newclass: x = property(GetNumSummaries, None) - __swig_getmethods__["num_filters"] = GetNumFilters - if _newclass: x = property(GetNumFilters, None) - __swig_getmethods__["num_synthetics"] = GetNumSynthetics - if _newclass: x = property(GetNumSynthetics, None) - - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["enabled"] = GetEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: x = property(GetEnabled, SetEnabled) - %} - - }; - - -} // namespace lldb - diff --git a/lldb/scripts/Python/interface/SBTypeFilter.i b/lldb/scripts/Python/interface/SBTypeFilter.i deleted file mode 100644 index 046859a68bf7..000000000000 --- a/lldb/scripts/Python/interface/SBTypeFilter.i +++ /dev/null @@ -1,69 +0,0 @@ -//===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a filter that can be associated to one or more types. - ") SBTypeFilter; - - class SBTypeFilter - { - public: - - SBTypeFilter(); - - SBTypeFilter (uint32_t options); - - SBTypeFilter (const lldb::SBTypeFilter &rhs); - - ~SBTypeFilter (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeFilter &rhs); - - uint32_t - GetNumberOfExpressionPaths (); - - const char* - GetExpressionPathAtIndex (uint32_t i); - - bool - ReplaceExpressionPathAtIndex (uint32_t i, const char* item); - - void - AppendExpressionPath (const char* item); - - void - Clear(); - - uint32_t - GetOptions(); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: x = property(GetOptions, SetOptions) - - __swig_getmethods__["count"] = GetNumberOfExpressionPaths - if _newclass: x = property(GetNumberOfExpressionPaths, None) - %} - - }; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBTypeFormat.i b/lldb/scripts/Python/interface/SBTypeFormat.i deleted file mode 100644 index 2116a02affce..000000000000 --- a/lldb/scripts/Python/interface/SBTypeFormat.i +++ /dev/null @@ -1,64 +0,0 @@ -//===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a format that can be associated to one or more types. - ") SBTypeFormat; - - class SBTypeFormat - { - public: - - SBTypeFormat(); - - SBTypeFormat (lldb::Format format, uint32_t options = 0); - - SBTypeFormat (const lldb::SBTypeFormat &rhs); - - ~SBTypeFormat (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeFormat &rhs); - - lldb::Format - GetFormat (); - - uint32_t - GetOptions(); - - void - SetFormat (lldb::Format); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: x = property(GetFormat, SetFormat) - - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: x = property(GetOptions, SetOptions) - %} - - }; - - -} // namespace lldb - diff --git a/lldb/scripts/Python/interface/SBTypeNameSpecifier.i b/lldb/scripts/Python/interface/SBTypeNameSpecifier.i deleted file mode 100644 index 8bb69a7d3978..000000000000 --- a/lldb/scripts/Python/interface/SBTypeNameSpecifier.i +++ /dev/null @@ -1,62 +0,0 @@ -//===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a general way to provide a type name to LLDB APIs. - ") SBTypeNameSpecifier; - - class SBTypeNameSpecifier - { - public: - - SBTypeNameSpecifier(); - - SBTypeNameSpecifier (const char* name, - bool is_regex = false); - - SBTypeNameSpecifier (SBType type); - - SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); - - ~SBTypeNameSpecifier (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeNameSpecifier &rhs); - - const char* - GetName(); - - lldb::SBType - GetType (); - - bool - IsRegex(); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: x = property(GetName, None) - - __swig_getmethods__["is_regex"] = IsRegex - if _newclass: x = property(IsRegex, None) - %} - - - }; - -} // namespace lldb - diff --git a/lldb/scripts/Python/interface/SBTypeSummary.i b/lldb/scripts/Python/interface/SBTypeSummary.i deleted file mode 100644 index f96897752bf5..000000000000 --- a/lldb/scripts/Python/interface/SBTypeSummary.i +++ /dev/null @@ -1,93 +0,0 @@ -//===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a summary that can be associated to one or more types. - ") SBTypeSummary; - - class SBTypeSummary - { - public: - - SBTypeSummary(); - - static SBTypeSummary - CreateWithSummaryString (const char* data, uint32_t options = 0); - - static SBTypeSummary - CreateWithFunctionName (const char* data, uint32_t options = 0); - - static SBTypeSummary - CreateWithScriptCode (const char* data, uint32_t options = 0); - - SBTypeSummary (const lldb::SBTypeSummary &rhs); - - ~SBTypeSummary (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeSummary &rhs); - - bool - IsFunctionCode(); - - bool - IsFunctionName(); - - bool - IsSummaryString(); - - const char* - GetData (); - - void - SetSummaryString (const char* data); - - void - SetFunctionName (const char* data); - - void - SetFunctionCode (const char* data); - - uint32_t - GetOptions (); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: x = property(GetOptions, SetOptions) - - __swig_getmethods__["is_summary_string"] = IsSummaryString - if _newclass: x = property(IsSummaryString, None) - - __swig_getmethods__["is_function_name"] = IsFunctionName - if _newclass: x = property(IsFunctionName, None) - - __swig_getmethods__["is_function_code"] = IsFunctionCode - if _newclass: x = property(IsFunctionCode, None) - - __swig_getmethods__["summary_data"] = GetData - if _newclass: x = property(GetData, None) - %} - - }; - -} // namespace lldb - diff --git a/lldb/scripts/Python/interface/SBTypeSynthetic.i b/lldb/scripts/Python/interface/SBTypeSynthetic.i deleted file mode 100644 index 3e785ff9b5c1..000000000000 --- a/lldb/scripts/Python/interface/SBTypeSynthetic.i +++ /dev/null @@ -1,74 +0,0 @@ -//===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a summary that can be associated to one or more types. - ") SBTypeSynthetic; - - class SBTypeSynthetic - { - public: - - SBTypeSynthetic(); - - static lldb::SBTypeSynthetic - CreateWithClassName (const char* data, uint32_t options = 0); - - static lldb::SBTypeSynthetic - CreateWithScriptCode (const char* data, uint32_t options = 0); - - SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); - - ~SBTypeSynthetic (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeSynthetic &rhs); - - bool - IsClassCode(); - - const char* - GetData (); - - void - SetClassName (const char* data); - - void - SetClassCode (const char* data); - - uint32_t - GetOptions (); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: x = property(GetOptions, SetOptions) - - __swig_getmethods__["contains_code"] = IsClassCode - if _newclass: x = property(IsClassCode, None) - - __swig_getmethods__["synthetic_data"] = GetData - if _newclass: x = property(GetData, None) - %} - - }; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBValue.i b/lldb/scripts/Python/interface/SBValue.i deleted file mode 100644 index d529e656099d..000000000000 --- a/lldb/scripts/Python/interface/SBValue.i +++ /dev/null @@ -1,474 +0,0 @@ -//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the value of a variable, a register, or an expression. - -SBValue supports iteration through its child, which in turn is represented -as an SBValue. For example, we can get the general purpose registers of a -frame as an SBValue, and iterate through all the registers, - - registerSet = frame.GetRegisters() # Returns an SBValueList. - for regs in registerSet: - if 'general purpose registers' in regs.getName().lower(): - GPRs = regs - break - - print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren()) - for reg in GPRs: - print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue() - -produces the output: - -General Purpose Registers (number of children = 21): -Name: rax Value: 0x0000000100000c5c -Name: rbx Value: 0x0000000000000000 -Name: rcx Value: 0x00007fff5fbffec0 -Name: rdx Value: 0x00007fff5fbffeb8 -Name: rdi Value: 0x0000000000000001 -Name: rsi Value: 0x00007fff5fbffea8 -Name: rbp Value: 0x00007fff5fbffe80 -Name: rsp Value: 0x00007fff5fbffe60 -Name: r8 Value: 0x0000000008668682 -Name: r9 Value: 0x0000000000000000 -Name: r10 Value: 0x0000000000001200 -Name: r11 Value: 0x0000000000000206 -Name: r12 Value: 0x0000000000000000 -Name: r13 Value: 0x0000000000000000 -Name: r14 Value: 0x0000000000000000 -Name: r15 Value: 0x0000000000000000 -Name: rip Value: 0x0000000100000dae -Name: rflags Value: 0x0000000000000206 -Name: cs Value: 0x0000000000000027 -Name: fs Value: 0x0000000000000010 -Name: gs Value: 0x0000000000000048 - -See also linked_list_iter() for another perspective on how to iterate through an -SBValue instance which interprets the value object as representing the head of a -linked list." -) SBValue; -class SBValue -{ -public: - SBValue (); - - SBValue (const SBValue &rhs); - - ~SBValue (); - - bool - IsValid(); - - void - Clear(); - - SBError - GetError(); - - lldb::user_id_t - GetID (); - - const char * - GetName(); - - const char * - GetTypeName (); - - size_t - GetByteSize (); - - bool - IsInScope (); - - lldb::Format - GetFormat (); - - void - SetFormat (lldb::Format format); - - const char * - GetValue (); - - int64_t - GetValueAsSigned(SBError& error, int64_t fail_value=0); - - uint64_t - GetValueAsUnsigned(SBError& error, uint64_t fail_value=0); - - int64_t - GetValueAsSigned(int64_t fail_value=0); - - uint64_t - GetValueAsUnsigned(uint64_t fail_value=0); - - ValueType - GetValueType (); - - bool - GetValueDidChange (); - - const char * - GetSummary (); - - const char * - GetObjectDescription (); - - lldb::SBValue - GetDynamicValue (lldb::DynamicValueType use_dynamic); - - lldb::SBValue - GetStaticValue (); - - lldb::SBValue - GetNonSyntheticValue (); - - bool - IsDynamic(); - - const char * - GetLocation (); - - bool - SetValueFromCString (const char *value_str); - - lldb::SBTypeFormat - GetTypeFormat (); - - lldb::SBTypeSummary - GetTypeSummary (); - - lldb::SBTypeFilter - GetTypeFilter (); - - lldb::SBTypeSynthetic - GetTypeSynthetic (); - - lldb::SBValue - GetChildAtIndex (uint32_t idx); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get a child value by index from a value. - /// - /// Structs, unions, classes, arrays and and pointers have child - /// values that can be access by index. - /// - /// Structs and unions access child members using a zero based index - /// for each child member. For - /// - /// Classes reserve the first indexes for base classes that have - /// members (empty base classes are omitted), and all members of the - /// current class will then follow the base classes. - /// - /// Pointers differ depending on what they point to. If the pointer - /// points to a simple type, the child at index zero - /// is the only child value available, unless \a synthetic_allowed - /// is \b true, in which case the pointer will be used as an array - /// and can create 'synthetic' child values using positive or - /// negative indexes. If the pointer points to an aggregate type - /// (an array, class, union, struct), then the pointee is - /// transparently skipped and any children are going to be the indexes - /// of the child values within the aggregate type. For example if - /// we have a 'Point' type and we have a SBValue that contains a - /// pointer to a 'Point' type, then the child at index zero will be - /// the 'x' member, and the child at index 1 will be the 'y' member - /// (the child at index zero won't be a 'Point' instance). - /// - /// Arrays have a preset number of children that can be accessed by - /// index and will returns invalid child values for indexes that are - /// out of bounds unless the \a synthetic_allowed is \b true. In this - /// case the array can create 'synthetic' child values for indexes - /// that aren't in the array bounds using positive or negative - /// indexes. - /// - /// @param[in] idx - /// The index of the child value to get - /// - /// @param[in] use_dynamic - /// An enumeration that specifies wether to get dynamic values, - /// and also if the target can be run to figure out the dynamic - /// type of the child value. - /// - /// @param[in] synthetic_allowed - /// If \b true, then allow child values to be created by index - /// for pointers and arrays for indexes that normally wouldn't - /// be allowed. - /// - /// @return - /// A new SBValue object that represents the child member value. - //------------------------------------------------------------------ - ") GetChildAtIndex; - lldb::SBValue - GetChildAtIndex (uint32_t idx, - lldb::DynamicValueType use_dynamic, - bool can_create_synthetic); - - lldb::SBValue - CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type); - - lldb::SBValue - SBValue::Cast (lldb::SBType type); - - lldb::SBValue - CreateValueFromExpression (const char *name, const char* expression); - - lldb::SBValue - CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type); - - lldb::SBValue - CreateValueFromData (const char* name, - lldb::SBData data, - lldb::SBType type); - - lldb::SBType - GetType(); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Returns the child member index. - /// - /// Matches children of this object only and will match base classes and - /// member names if this is a clang typed object. - /// - /// @param[in] name - /// The name of the child value to get - /// - /// @return - /// An index to the child member value. - //------------------------------------------------------------------ - ") GetIndexOfChildWithName; - uint32_t - GetIndexOfChildWithName (const char *name); - - lldb::SBValue - GetChildMemberWithName (const char *name); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Returns the child member value. - /// - /// Matches child members of this object and child members of any base - /// classes. - /// - /// @param[in] name - /// The name of the child value to get - /// - /// @param[in] use_dynamic - /// An enumeration that specifies wether to get dynamic values, - /// and also if the target can be run to figure out the dynamic - /// type of the child value. - /// - /// @return - /// A new SBValue object that represents the child member value. - //------------------------------------------------------------------ - ") GetChildMemberWithName; - lldb::SBValue - GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); - - %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d." - ) GetValueForExpressionPath; - lldb::SBValue - GetValueForExpressionPath(const char* expr_path); - - uint32_t - GetNumChildren (); - - void * - GetOpaqueType(); - - lldb::SBValue - Dereference (); - - lldb::SBValue - AddressOf(); - - bool - TypeIsPointerType (); - - lldb::SBTarget - GetTarget(); - - lldb::SBProcess - GetProcess(); - - lldb::SBThread - GetThread(); - - lldb::SBFrame - GetFrame(); - - %feature("docstring", " - /// Find and watch a variable. - /// It returns an SBWatchpoint, which may be invalid. - ") Watch; - lldb::SBWatchpoint - Watch (bool resolve_location, bool read, bool write); - - %feature("docstring", " - /// Find and watch the location pointed to by a variable. - /// It returns an SBWatchpoint, which may be invalid. - ") WatchPointee; - lldb::SBWatchpoint - WatchPointee (bool resolve_location, bool read, bool write); - - bool - GetDescription (lldb::SBStream &description); - - bool - GetExpressionPath (lldb::SBStream &description); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get an SBData wrapping what this SBValue points to. - /// - /// This method will dereference the current SBValue, if its - /// data type is a T* or T[], and extract item_count elements - /// of type T from it, copying their contents in an SBData. - /// - /// @param[in] item_idx - /// The index of the first item to retrieve. For an array - /// this is equivalent to array[item_idx], for a pointer - /// to *(pointer + item_idx). In either case, the measurement - /// unit for item_idx is the sizeof(T) rather than the byte - /// - /// @param[in] item_count - /// How many items should be copied into the output. By default - /// only one item is copied, but more can be asked for. - /// - /// @return - /// An SBData with the contents of the copied items, on success. - /// An empty SBData otherwise. - //------------------------------------------------------------------ - ") GetPointeeData; - lldb::SBData - GetPointeeData (uint32_t item_idx = 0, - uint32_t item_count = 1); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get an SBData wrapping the contents of this SBValue. - /// - /// This method will read the contents of this object in memory - /// and copy them into an SBData for future use. - /// - /// @return - /// An SBData with the contents of this SBValue, on success. - /// An empty SBData otherwise. - //------------------------------------------------------------------ - ") GetData; - lldb::SBData - GetData (); - - lldb::addr_t - GetLoadAddress(); - - lldb::SBAddress - GetAddress(); - - %feature("docstring", "Returns an expression path for this value." - ) GetExpressionPath; - bool - GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); - - %pythoncode %{ - def __get_dynamic__ (self): - '''Helper function for the "SBValue.dynamic" property.''' - return self.GetDynamicValue (eDynamicCanRunTarget) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='Returns the name of this SBValue as a string') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='Returns an SBType that represents the type of this SBValue') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='Returns the size (in bytes) of the data contained in this SBValue') - - __swig_getmethods__["is_in_scope"] = IsInScope - if _newclass: is_in_scope = property(IsInScope, None, doc='Returns True if this SBValue represents an item that is currently in lexical scope') - - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: format = property(GetName, SetFormat, doc='Returns the format for this SBValue') - - __swig_getmethods__["value"] = GetValue - __swig_setmethods__["value"] = SetValueFromCString - if _newclass: value = property(GetValue, SetValueFromCString, doc='Returns the value of this SBValue as a string') - - __swig_getmethods__["value_type"] = GetValueType - if _newclass: value_type = property(GetValueType, None, doc='Returns the type of entry stored in this SBValue') - - __swig_getmethods__["changed"] = GetValueDidChange - if _newclass: changed = property(GetValueDidChange, None, doc='Returns True if this SBValue represents an item that has changed') - - __swig_getmethods__["data"] = GetData - if _newclass: data = property(GetData, None, doc='Returns an SBData wrapping the contents of this SBValue') - - __swig_getmethods__["load_addr"] = GetLoadAddress - if _newclass: load_addr = property(GetLoadAddress, None, doc='Returns the load address (target address) of this SBValue as a number') - - __swig_getmethods__["addr"] = GetAddress - if _newclass: addr = property(GetAddress, None, doc='Returns the address of this SBValue as an SBAddress') - - __swig_getmethods__["deref"] = Dereference - if _newclass: deref = property(Dereference, None, doc='Returns an SBValue that is created by dereferencing this SBValue') - - __swig_getmethods__["address_of"] = AddressOf - if _newclass: address_of = property(AddressOf, None, doc='Returns an SBValue that wraps the address-of this SBValue') - - __swig_getmethods__["error"] = GetError - if _newclass: error = property(GetError, None, doc='Returns the SBError currently associated to this SBValue') - - __swig_getmethods__["summary"] = GetSummary - if _newclass: summary = property(GetSummary, None, doc='Returns the summary for this SBValue as a string') - - __swig_getmethods__["description"] = GetObjectDescription - if _newclass: description = property(GetObjectDescription, None, doc='Returns the language-specific description of this SBValue as a string') - - __swig_getmethods__["dynamic"] = __get_dynamic__ - if _newclass: description = property(__get_dynamic__, None, doc='Gets the dynamic type for a value') - - __swig_getmethods__["location"] = GetLocation - if _newclass: location = property(GetLocation, None, doc='Returns the location of this SBValue as a string') - - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='Returns an SBTarget for the target from which this SBValue comes') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='Returns an SBProcess for the process from which this SBValue comes') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='Returns an SBThread for the thread from which this SBValue comes') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='Returns an SBFrame for the stack frame from which this SBValue comes') - - __swig_getmethods__["num_children"] = GetNumChildren - if _newclass: num_children = property(GetNumChildren, None, doc='Returns the number of child SBValues that this SBValue has') - - __swig_getmethods__["unsigned"] = GetValueAsUnsigned - if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='Returns the value of this SBValue as an unsigned number') - - __swig_getmethods__["signed"] = GetValueAsSigned - if _newclass: signed = property(GetValueAsSigned, None, doc='Returns the value of this SBValue as a signed number') - - def get_expr_path(self): - s = SBStream() - self.GetExpressionPath (s) - return s.GetData() - - __swig_getmethods__["path"] = get_expr_path - if _newclass: path = property(get_expr_path, None, doc='Returns the expression path that one can use to reach this SBValue') - %} - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBValueList.i b/lldb/scripts/Python/interface/SBValueList.i deleted file mode 100644 index 1bc904980ef1..000000000000 --- a/lldb/scripts/Python/interface/SBValueList.i +++ /dev/null @@ -1,138 +0,0 @@ -//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a collection of SBValues. Both SBFrame's GetVariables() and -GetRegisters() return a SBValueList. - -SBValueList supports SBValue iteration. For example (from test/lldbutil.py), - -def get_registers(frame, kind): - '''Returns the registers given the frame and the kind of registers desired. - - Returns None if there's no such kind. - ''' - registerSet = frame.GetRegisters() # Return type of SBValueList. - for value in registerSet: - if kind.lower() in value.GetName().lower(): - return value - - return None - -def get_GPRs(frame): - '''Returns the general purpose registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_GPRs - regs = get_GPRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'general purpose') - -def get_FPRs(frame): - '''Returns the floating point registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_FPRs - regs = get_FPRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'floating point') - -def get_ESRs(frame): - '''Returns the exception state registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_ESRs - regs = get_ESRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'exception state')" -) SBValueList; -class SBValueList -{ -public: - - SBValueList (); - - SBValueList (const lldb::SBValueList &rhs); - - ~SBValueList(); - - bool - IsValid() const; - - void - Clear(); - - void - Append (const lldb::SBValue &val_obj); - - void - Append (const lldb::SBValueList& value_list); - - uint32_t - GetSize() const; - - lldb::SBValue - GetValueAtIndex (uint32_t idx) const; - - lldb::SBValue - FindValueObjectByUID (lldb::user_id_t uid); - %pythoncode %{ - def __len__(self): - return self.GetSize() - - def __getitem__(self, key): - count = len(self) - #------------------------------------------------------------ - # Access with "int" to get Nth item in the list - #------------------------------------------------------------ - if type(key) is int: - if key < count: - return self.GetValueAtIndex(key) - #------------------------------------------------------------ - # Access with "str" to get values by name - #------------------------------------------------------------ - elif type(key) is str: - matches = [] - for idx in range(count): - value = self.GetValueAtIndex(idx) - if value.name == key: - matches.append(value) - return matches - #------------------------------------------------------------ - # Match with regex - #------------------------------------------------------------ - elif isinstance(key, type(re.compile('.'))): - matches = [] - for idx in range(count): - value = self.GetValueAtIndex(idx) - re_match = key.search(value.name) - if re_match: - matches.append(value) - return matches - - %} - - -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBWatchpoint.i b/lldb/scripts/Python/interface/SBWatchpoint.i deleted file mode 100644 index 23c27d8905ed..000000000000 --- a/lldb/scripts/Python/interface/SBWatchpoint.i +++ /dev/null @@ -1,89 +0,0 @@ -//===-- SWIG Interface for SBWatchpoint -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an instance of watchpoint for a specific target program. - -A watchpoint is determined by the address and the byte size that resulted in -this particular instantiation. Each watchpoint has its settable options. - -See also SBTarget.watchpoint_iter() for example usage of iterating through the -watchpoints of the target." -) SBWatchpoint; -class SBWatchpoint -{ -public: - - SBWatchpoint (); - - SBWatchpoint (const lldb::SBWatchpoint &rhs); - - ~SBWatchpoint (); - - bool - IsValid(); - - SBError - GetError(); - - watch_id_t - GetID (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// With -1 representing an invalid hardware index. - //------------------------------------------------------------------ - ") GetHardwareIndex; - int32_t - GetHardwareIndex (); - - lldb::addr_t - GetWatchAddress (); - - size_t - GetWatchSize(); - - void - SetEnabled(bool enabled); - - bool - IsEnabled (); - - uint32_t - GetHitCount (); - - uint32_t - GetIgnoreCount (); - - void - SetIgnoreCount (uint32_t n); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the watchpoint. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The watchpoint stops only if the condition expression evaluates to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - bool - GetDescription (lldb::SBStream &description, DescriptionLevel level); -}; - -} // namespace lldb diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py deleted file mode 100644 index 75f97e78ba9e..000000000000 --- a/lldb/scripts/Python/modify-python-lldb.py +++ /dev/null @@ -1,437 +0,0 @@ -# -# modify-python-lldb.py -# -# This script modifies the lldb module (which was automatically generated via -# running swig) to support iteration and/or equality operations for certain lldb -# objects, implements truth value testing for certain lldb objects, and adds a -# global variable 'debugger_unique_id' which is initialized to 0. -# -# As a cleanup step, it also removes the 'residues' from the autodoc features of -# swig. For an example, take a look at SBTarget.h header file, where we take -# advantage of the already existing doxygen C++-docblock and make it the Python -# docstring for the same method. The 'residues' in this context include the -# '#endif', the '#ifdef SWIG', the c comment marker, the trailing blank (SPC's) -# line, and the doxygen comment start marker. -# -# In addition to the 'residues' removal during the cleanup step, it also -# transforms the 'char' data type (which was actually 'char *' but the 'autodoc' -# feature of swig removes ' *' from it) into 'str' (as a Python str type). -# -# It also calls SBDebugger.Initialize() to initialize the lldb debugger -# subsystem. -# - -import sys, re, StringIO - -if len (sys.argv) != 2: - output_name = "./lldb.py" -else: - output_name = sys.argv[1] + "/lldb.py" - -# print "output_name is '" + output_name + "'" - -# -# Residues to be removed. -# -c_endif_swig = "#endif" -c_ifdef_swig = "#ifdef SWIG" -c_comment_marker = "//------------" -# The pattern for recognizing the doxygen comment block line. -doxygen_comment_start = re.compile("^\s*(/// ?)") -# The demarcation point for turning on/off residue removal state. -# When bracketed by the lines, the CLEANUP_DOCSTRING state (see below) is ON. -toggle_docstring_cleanup_line = ' """' - -def char_to_str_xform(line): - """This transforms the 'char', i.e, 'char *' to 'str', Python string.""" - line = line.replace(' char', ' str') - line = line.replace('char ', 'str ') - # Special case handling of 'char **argv' and 'char **envp'. - line = line.replace('str argv', 'list argv') - line = line.replace('str envp', 'list envp') - return line - -# -# The one-liner docstring also needs char_to_str transformation, btw. -# -TWO_SPACES = ' ' * 2 -EIGHT_SPACES = ' ' * 8 -one_liner_docstring_pattern = re.compile('^(%s|%s)""".*"""$' % (TWO_SPACES, EIGHT_SPACES)) - -# -# lldb_helpers and lldb_iter() should appear before our first SB* class definition. -# -lldb_helpers = ''' -# ================================== -# Helper function for SBModule class -# ================================== -def in_range(symbol, section): - """Test whether a symbol is within the range of a section.""" - symSA = symbol.GetStartAddress().GetFileAddress() - symEA = symbol.GetEndAddress().GetFileAddress() - secSA = section.GetFileAddress() - secEA = secSA + section.GetByteSize() - - if symEA != LLDB_INVALID_ADDRESS: - if secSA <= symSA and symEA <= secEA: - return True - else: - return False - else: - if secSA <= symSA and symSA < secEA: - return True - else: - return False -''' - -lldb_iter_def = ''' -# =================================== -# 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) - -# ============================================================================== -# The modify-python-lldb.py script is responsible for post-processing this SWIG- -# generated lldb.py module. It is responsible for adding the above lldb_iter() -# function definition as well as the supports, in the following, for iteration -# protocol: __iter__, rich comparison methods: __eq__ and __ne__, truth value -# testing (and built-in operation bool()): __nonzero__, and built-in function -# len(): __len__. -# ============================================================================== -''' - -# -# linked_list_iter() is a special purpose iterator to treat the SBValue as the -# head of a list data structure, where you specify the child member name which -# points to the next item on the list and you specify the end-of-list function -# which takes an SBValue and returns True if EOL is reached and False if not. -# -linked_list_iter_def = ''' - def __eol_test__(val): - """Default function for end of list test takes an SBValue object. - - Return True if val is invalid or it corresponds to a null pointer. - Otherwise, return False. - """ - if not val or val.GetValueAsUnsigned() == 0: - return True - else: - return False - - # ================================================== - # Iterator for lldb.SBValue treated as a linked list - # ================================================== - def linked_list_iter(self, next_item_name, end_of_list_test=__eol_test__): - """Generator adaptor to support iteration for SBValue as a linked list. - - linked_list_iter() is a special purpose iterator to treat the SBValue as - the head of a list data structure, where you specify the child member - name which points to the next item on the list and you specify the - end-of-list test function which takes an SBValue for an item and returns - True if EOL is reached and False if not. - - linked_list_iter() also detects infinite loop and bails out early. - - The end_of_list_test arg, if omitted, defaults to the __eol_test__ - function above. - - For example, - - # Get Frame #0. - ... - - # Get variable 'task_head'. - task_head = frame0.FindVariable('task_head') - ... - - for t in task_head.linked_list_iter('next'): - print t - """ - if end_of_list_test(self): - return - item = self - visited = set() - try: - while not end_of_list_test(item) and not item.GetValueAsUnsigned() in visited: - visited.add(item.GetValueAsUnsigned()) - yield item - # Prepare for the next iteration. - item = item.GetChildMemberWithName(next_item_name) - except: - # Exception occurred. Stop the generator. - pass - - return -''' - -# This supports the iteration protocol. -iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" -module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" -breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" -watchpoint_iter = " def watchpoint_iter(self): return lldb_iter(self, '%s', '%s')" -section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')" -compile_unit_iter = " def compile_unit_iter(self): return lldb_iter(self, '%s', '%s')" - -# Called to implement the built-in function len(). -# Eligible objects are those containers with unambiguous iteration support. -len_def = " def __len__(self): return self.%s()" - -# This supports the rich comparison methods of __eq__ and __ne__. -eq_def = " def __eq__(self, other): return isinstance(other, %s) and %s" -ne_def = " def __ne__(self, other): return not self.__eq__(other)" - -# Called to implement truth value testing and the built-in operation bool(); -# should return False or True, or their integer equivalents 0 or 1. -# Delegate to self.IsValid() if it is defined for the current lldb object. -nonzero_def = " def __nonzero__(self): return self.IsValid()" - -# A convenience iterator for SBSymbol! -symbol_in_section_iter_def = ''' - def symbol_in_section_iter(self, section): - """Given a module and its contained section, returns an iterator on the - symbols within the section.""" - for sym in self: - if in_range(sym, section): - yield sym -''' - -# -# This dictionary defines a mapping from classname to (getsize, getelem) tuple. -# -d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), - 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'), - 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'), - 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'), - 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'), - 'SBSection': ('GetNumSubSections', 'GetSubSectionAtIndex'), - 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'), - - 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'), - 'SBStringList': ('GetSize', 'GetStringAtIndex',), - 'SBSymbolContextList': ('GetSize', 'GetContextAtIndex'), - 'SBTypeList': ('GetSize', 'GetTypeAtIndex'), - 'SBValueList': ('GetSize', 'GetValueAtIndex'), - - 'SBType': ('GetNumberChildren', 'GetChildAtIndex'), - 'SBValue': ('GetNumChildren', 'GetChildAtIndex'), - - # SBTarget needs special processing, see below. - 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), - 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'), - 'watchpoint': ('GetNumWatchpoints', 'GetWatchpointAtIndex') - }, - - # SBModule has an additional section_iter(), see below. - 'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'), - # And compile_unit_iter(). - 'SBModule-compile-unit': ('GetNumCompileUnits', 'GetCompileUnitAtIndex'), - # As well as symbol_in_section_iter(). - 'SBModule-symbol-in-section': symbol_in_section_iter_def - } - -# -# This dictionary defines a mapping from classname to equality method name(s). -# -e = { 'SBAddress': ['GetFileAddress', 'GetModule'], - 'SBBreakpoint': ['GetID'], - 'SBWatchpoint': ['GetID'], - 'SBFileSpec': ['GetFilename', 'GetDirectory'], - 'SBModule': ['GetFileSpec', 'GetUUIDString'], - 'SBType': ['GetByteSize', 'GetName'] - } - -def list_to_frag(list): - """Transform a list to equality program fragment. - - For example, ['GetID'] is transformed to 'self.GetID() == other.GetID()', - and ['GetFilename', 'GetDirectory'] to 'self.GetFilename() == other.GetFilename() - and self.GetDirectory() == other.GetDirectory()'. - """ - if not list: - raise Exception("list should be non-empty") - frag = StringIO.StringIO() - for i in range(len(list)): - if i > 0: - frag.write(" and ") - frag.write("self.{0}() == other.{0}()".format(list[i])) - return frag.getvalue() - -class NewContent(StringIO.StringIO): - """Simple facade to keep track of the previous line to be committed.""" - def __init__(self): - StringIO.StringIO.__init__(self) - self.prev_line = None - def add_line(self, a_line): - """Add a line to the content, if there is a previous line, commit it.""" - if self.prev_line != None: - print >> self, self.prev_line - self.prev_line = a_line - def del_line(self): - """Forget about the previous line, do not commit it.""" - self.prev_line = None - def del_blank_line(self): - """Forget about the previous line if it is a blank line.""" - if self.prev_line != None and not self.prev_line.strip(): - self.prev_line = None - def finish(self): - """Call this when you're finished with populating content.""" - if self.prev_line != None: - print >> self, self.prev_line - self.prev_line = None - -# The new content will have the iteration protocol defined for our lldb objects. -new_content = NewContent() - -with open(output_name, 'r') as f_in: - content = f_in.read() - -# The pattern for recognizing the beginning of an SB class definition. -class_pattern = re.compile("^class (SB.*)\(_object\):$") - -# The pattern for recognizing the beginning of the __init__ method definition. -init_pattern = re.compile("^ def __init__\(self.*\):") - -# The pattern for recognizing the beginning of the IsValid method definition. -isvalid_pattern = re.compile("^ def IsValid\(") - -# These define the states of our finite state machine. -NORMAL = 0 -DEFINING_ITERATOR = 1 -DEFINING_EQUALITY = 2 -CLEANUP_DOCSTRING = 4 - -# The lldb_iter_def only needs to be inserted once. -lldb_iter_defined = False; - -# Our FSM begins its life in the NORMAL state, and transitions to the -# DEFINING_ITERATOR and/or DEFINING_EQUALITY state whenever it encounters the -# beginning of certain class definitions, see dictionaries 'd' and 'e' above. -# -# Note that the two states DEFINING_ITERATOR and DEFINING_EQUALITY are -# orthogonal in that our FSM can be in one, the other, or both states at the -# same time. During such time, the FSM is eagerly searching for the __init__ -# method definition in order to insert the appropriate method(s) into the lldb -# module. -# -# The state CLEANUP_DOCSTRING can be entered from either the NORMAL or the -# DEFINING_ITERATOR/EQUALITY states. While in this state, the FSM is fixing/ -# cleaning the Python docstrings generated by the swig docstring features. -# -# The FSM, in all possible states, also checks the current input for IsValid() -# definition, and inserts a __nonzero__() method definition to implement truth -# value testing and the built-in operation bool(). -state = NORMAL -for line in content.splitlines(): - # Handle the state transition into CLEANUP_DOCSTRING state as it is possible - # to enter this state from either NORMAL or DEFINING_ITERATOR/EQUALITY. - # - # If ' """' is the sole line, prepare to transition to the - # CLEANUP_DOCSTRING state or out of it. - if line == toggle_docstring_cleanup_line: - if state & CLEANUP_DOCSTRING: - # Special handling of the trailing blank line right before the '"""' - # end docstring marker. - new_content.del_blank_line() - state ^= CLEANUP_DOCSTRING - else: - state |= CLEANUP_DOCSTRING - - if state == NORMAL: - match = class_pattern.search(line) - # Inserts lldb_helpers and the lldb_iter() definition before the first - # class definition. - if not lldb_iter_defined and match: - new_content.add_line(lldb_helpers) - new_content.add_line(lldb_iter_def) - lldb_iter_defined = True - - # If we are at the beginning of the class definitions, prepare to - # transition to the DEFINING_ITERATOR/DEFINING_EQUALITY state for the - # right class names. - if match: - cls = match.group(1) - if cls in d: - # Adding support for iteration for the matched SB class. - state |= DEFINING_ITERATOR - if cls in e: - # Adding support for eq and ne for the matched SB class. - state |= DEFINING_EQUALITY - - if (state & DEFINING_ITERATOR) or (state & DEFINING_EQUALITY): - match = init_pattern.search(line) - if match: - # We found the beginning of the __init__ method definition. - # This is a good spot to insert the iter and/or eq-ne support. - # - # But note that SBTarget has three types of iterations. - if cls == "SBTarget": - new_content.add_line(module_iter % (d[cls]['module'])) - new_content.add_line(breakpoint_iter % (d[cls]['breakpoint'])) - new_content.add_line(watchpoint_iter % (d[cls]['watchpoint'])) - else: - if (state & DEFINING_ITERATOR): - new_content.add_line(iter_def % d[cls]) - new_content.add_line(len_def % d[cls][0]) - if (state & DEFINING_EQUALITY): - new_content.add_line(eq_def % (cls, list_to_frag(e[cls]))) - new_content.add_line(ne_def) - - # SBModule has extra SBSection, SBCompileUnit iterators and symbol_in_section_iter()! - if cls == "SBModule": - new_content.add_line(section_iter % d[cls+'-section']) - new_content.add_line(compile_unit_iter % d[cls+'-compile-unit']) - new_content.add_line(d[cls+'-symbol-in-section']) - - # This special purpose iterator is for SBValue only!!! - if cls == "SBValue": - new_content.add_line(linked_list_iter_def) - - # Next state will be NORMAL. - state = NORMAL - - if (state & CLEANUP_DOCSTRING): - # Cleanse the lldb.py of the autodoc'ed residues. - if c_ifdef_swig in line or c_endif_swig in line: - continue - # As well as the comment marker line. - if c_comment_marker in line: - continue - - # Also remove the '\a ' and '\b 'substrings. - line = line.replace('\a ', '') - line = line.replace('\b ', '') - # And the leading '///' substring. - doxygen_comment_match = doxygen_comment_start.match(line) - if doxygen_comment_match: - line = line.replace(doxygen_comment_match.group(1), '', 1) - - line = char_to_str_xform(line) - - # Note that the transition out of CLEANUP_DOCSTRING is handled at the - # beginning of this function already. - - # This deals with one-liner docstring, for example, SBThread.GetName: - # """GetName(self) -> char""". - if one_liner_docstring_pattern.match(line): - line = char_to_str_xform(line) - - # Look for 'def IsValid(*args):', and once located, add implementation - # of truth value testing for this object by delegation. - if isvalid_pattern.search(line): - new_content.add_line(nonzero_def) - - # Pass the original line of content to new_content. - new_content.add_line(line) - -# We are finished with recording new content. -new_content.finish() - -with open(output_name, 'w') as f_out: - f_out.write(new_content.getvalue()) - f_out.write("debugger_unique_id = 0\n") - f_out.write("SBDebugger.Initialize()\n") diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig deleted file mode 100644 index cd8f1cfc5f03..000000000000 --- a/lldb/scripts/Python/python-extensions.swig +++ /dev/null @@ -1,680 +0,0 @@ - -%extend lldb::SBAddress { - PyObject *lldb::SBAddress::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBBlock { - PyObject *lldb::SBBlock::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - - } -} -%extend lldb::SBBreakpoint { - PyObject *lldb::SBBreakpoint::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBBreakpointLocation { - PyObject *lldb::SBBreakpointLocation::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelFull); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBCommandReturnObject { - PyObject *lldb::SBCommandReturnObject::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBCompileUnit { - PyObject *lldb::SBCompileUnit::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBData { - PyObject *lldb::SBData::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBDebugger { - PyObject *lldb::SBDebugger::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBError { - PyObject *lldb::SBError::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBFileSpec { - PyObject *lldb::SBFileSpec::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBFrame { - PyObject *lldb::SBFrame::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBFunction { - PyObject *lldb::SBFunction::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBInstruction { - PyObject *lldb::SBInstruction::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBInstructionList { - PyObject *lldb::SBInstructionList::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBLineEntry { - PyObject *lldb::SBLineEntry::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBModule { - PyObject *lldb::SBModule::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBProcess { - PyObject *lldb::SBProcess::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBSection { - PyObject *lldb::SBSection::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBSymbol { - PyObject *lldb::SBSymbol::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBSymbolContext { - PyObject *lldb::SBSymbolContext::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBSymbolContextList { - PyObject *lldb::SBSymbolContextList::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTarget { - PyObject *lldb::SBTarget::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBType { - PyObject *lldb::SBType::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeCategory { - PyObject *lldb::SBTypeCategory::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeFilter { - PyObject *lldb::SBTypeFilter::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeFormat { - PyObject *lldb::SBTypeFormat::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeMember { - PyObject *lldb::SBTypeMember::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeNameSpecifier { - PyObject *lldb::SBTypeNameSpecifier::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeSummary { - PyObject *lldb::SBTypeSummary::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBTypeSynthetic { - PyObject *lldb::SBTypeSynthetic::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBThread { - PyObject *lldb::SBThread::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBValue { - PyObject *lldb::SBValue::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} -%extend lldb::SBValueList { - PyObject *lldb::SBValueList::__repr__ (){ - lldb::SBStream description; - const size_t n = $self->GetSize(); - if (n) - { - for (size_t i=0; i<n; ++i) - $self->GetValueAtIndex(i).GetDescription(description); - } - else - { - description.Printf("<empty> lldb.SBValueList()"); - } - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - return Py_None; - } -} -%extend lldb::SBWatchpoint { - PyObject *lldb::SBWatchpoint::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelVerbose); - const char *desc = description.GetData(); - size_t desc_len = description.GetSize(); - if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) - --desc_len; - if (desc_len > 0) - return PyString_FromStringAndSize (desc, desc_len); - else - return PyString_FromString(""); - } -} - -%pythoncode %{ - -class declaration(object): - '''A class that represents a source declaration location with file, line and column.''' - def __init__(self, file, line, col): - self.file = file - self.line = line - self.col = col - -class value(object): - '''A class designed to wrap lldb.SBValue() objects so the resulting object - can be used as a variable would be in code. So if you have a Point structure - variable in your code in the current frame named "pt", you can initialize an instance - of this class with it: - - pt = lldb.value(lldb.frame.FindVariable("pt")) - print pt - print pt.x - print pt.y - - pt = lldb.value(lldb.frame.FindVariable("rectangle_array")) - print rectangle_array[12] - print rectangle_array[5].origin.x''' - def __init__(self, sbvalue): - self.sbvalue = sbvalue - - def __nonzero__(self): - return self.sbvalue.__nonzero__() - - def __str__(self): - return self.sbvalue.__str__() - - def __getitem__(self, key): - # Allow array access if this value has children... - if type(key) is int: - return value(self.sbvalue.GetValueForExpressionPath("[%i]" % key)) - raise TypeError - - def __getattr__(self, name): - child_sbvalue = self.sbvalue.GetChildMemberWithName (name) - if child_sbvalue: - return value(child_sbvalue) - raise AttributeError - - def __add__(self, other): - return int(self) + int(other) - - def __sub__(self, other): - return int(self) - int(other) - - def __mul__(self, other): - return int(self) * int(other) - - def __floordiv__(self, other): - return int(self) // int(other) - - def __mod__(self, other): - return int(self) % int(other) - - def __divmod__(self, other): - return int(self) % int(other) - - def __pow__(self, other): - return int(self) ** int(other) - - def __lshift__(self, other): - return int(self) << int(other) - - def __rshift__(self, other): - return int(self) >> int(other) - - def __and__(self, other): - return int(self) & int(other) - - def __xor__(self, other): - return int(self) ^ int(other) - - def __or__(self, other): - return int(self) | int(other) - - def __div__(self, other): - return int(self) / int(other) - - def __truediv__(self, other): - return int(self) / int(other) - - def __iadd__(self, other): - result = self.__add__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __isub__(self, other): - result = self.__sub__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __imul__(self, other): - result = self.__mul__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __idiv__(self, other): - result = self.__div__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __itruediv__(self, other): - result = self.__truediv__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ifloordiv__(self, other): - result = self.__floordiv__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __imod__(self, other): - result = self.__and__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ipow__(self, other): - result = self.__pow__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ipow__(self, other, modulo): - result = self.__pow__(self, other, modulo) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ilshift__(self, other): - result = self.__lshift__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __irshift__(self, other): - result = self.__rshift__(other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __iand__(self, other): - result = self.__and__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ixor__(self, other): - result = self.__xor__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __ior__(self, other): - result = self.__ior__(self, other) - self.sbvalue.SetValueFromCString (str(result)) - return result - - def __neg__(self): - return -int(self) - - def __pos__(self): - return +int(self) - - def __abs__(self): - return abs(int(self)) - - def __invert__(self): - return ~int(self) - - def __complex__(self): - return complex (int(self)) - - def __int__(self): - return self.sbvalue.GetValueAsSigned() - - def __long__(self): - return self.sbvalue.GetValueAsSigned() - - def __float__(self): - return float (self.sbvalue.GetValueAsSigned()) - - def __oct__(self): - return '0%o' % self.sbvalue.GetValueAsUnsigned() - - def __hex__(self): - return '0x%x' % self.sbvalue.GetValueAsUnsigned() - - def __eq__(self, other): - return self.sbvalue.GetValueAsUnsigned() == self.sbvalue.GetValueAsUnsigned() - - def __neq__(self, other): - return not self.__eq__(other) -%} - diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig deleted file mode 100644 index 0eca5ea3778f..000000000000 --- a/lldb/scripts/Python/python-typemaps.swig +++ /dev/null @@ -1,332 +0,0 @@ -/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */ - -%typemap(in) char ** { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $1 = (char **) malloc((size+1) * sizeof(char*)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyString_Check(o)) - $1[i] = PyString_AsString(o); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - free($1); - return NULL; - } - } - $1[i] = 0; - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) char** { - free((char *) $1); -} - -%typemap(out) char** { - int len; - int i; - len = 0; - while ($1[len]) len++; - $result = PyList_New(len); - for (i = 0; i < len; i++) { - PyList_SetItem($result, i, PyString_FromString($1[i])); - } -} - -/* Typemap definitions to allow SWIG to properly handle char buffer. */ - -// typemap for a char buffer -// See also SBThread::GetStopDescription. -%typemap(in) (char *dst, size_t dst_len) { - if (!PyInt_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; - } - $2 = PyInt_AsLong($input); - if ($2 <= 0) { - PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; - } - $1 = (char *) malloc($2); -} - -// Return the char buffer. Discarding any previous return result -// See also SBThread::GetStopDescription. -%typemap(argout) (char *dst, size_t dst_len) { - Py_XDECREF($result); /* Blow away any previous result */ - $result = PyString_FromStringAndSize(($1),result); - free($1); -} - - -// typemap for an outgoing buffer -// See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). -%typemap(in) (const char *cstr, uint32_t cstr_len) { - if (PyString_Check($input)) { - $1 = (char *) PyString_AsString($input); - $2 = PyString_Size($input); - } - else if(PyByteArray_Check($input)) { - $1 = (char *) PyByteArray_AsString($input); - $2 = PyByteArray_Size($input); - } - else { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } -} -// Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len). -%typemap(in) (const char *src, size_t src_len) { - if (PyString_Check($input)) { - $1 = (char *) PyString_AsString($input); - $2 = PyString_Size($input); - } - else if(PyByteArray_Check($input)) { - $1 = (char *) PyByteArray_AsString($input); - $2 = PyByteArray_Size($input); - } - else { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } -} -// And SBProcess::WriteMemory. -%typemap(in) (const void *buf, size_t size) { - if (PyString_Check($input)) { - $1 = (void *) PyString_AsString($input); - $2 = PyString_Size($input); - } - else if(PyByteArray_Check($input)) { - $1 = (void *) PyByteArray_AsString($input); - $2 = PyByteArray_Size($input); - } - else { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } -} - -// typemap for an incoming buffer -// See also SBProcess::ReadMemory. -%typemap(in) (void *buf, size_t size) { - if (!PyInt_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; - } - $2 = PyInt_AsLong($input); - if ($2 <= 0) { - PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; - } - $1 = (void *) malloc($2); -} - -// Return the buffer. Discarding any previous return result -// See also SBProcess::ReadMemory. -%typemap(argout) (void *buf, size_t size) { - Py_XDECREF($result); /* Blow away any previous result */ - $result = PyString_FromStringAndSize(static_cast<const char*>($1),result); - free($1); -} - -// these typemaps allow Python users to pass list objects -// and have them turn into C++ arrays (this is useful, for instance -// when creating SBData objects from lists of numbers) -%typemap(in) (uint64_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (uint64_t*) malloc(size * sizeof(uint64_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (uint64_t* array, size_t array_len) { - free($1); -} - -%typemap(in) (uint32_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (uint32_t*) malloc(size * sizeof(uint32_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (uint32_t* array, size_t array_len) { - free($1); -} - -%typemap(in) (int64_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (int64_t*) malloc(size * sizeof(int64_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (int64_t* array, size_t array_len) { - free($1); -} - -%typemap(in) (int32_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (int32_t*) malloc(size * sizeof(int32_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (int32_t* array, size_t array_len) { - free($1); -} - -%typemap(in) (double* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (double*) malloc(size * sizeof(double)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyFloat_Check(o)) { - $1[i] = PyFloat_AsDouble(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain floating-point numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (double* array, size_t array_len) { - free($1); -} - -// these typemaps wrap SBModule::GetVersion() from requiring a memory buffer -// to the more Pythonic style where a list is returned and no previous allocation -// is necessary - this will break if more than 50 versions are ever returned -%typemap(typecheck) (uint32_t *versions, uint32_t num_versions) { - $1 = ($input == Py_None ? 1 : 0); -} - -%typemap(in, numinputs=0) (uint32_t *versions) { - $1 = (uint32_t*)malloc(sizeof(uint32_t) * 50); -} - -%typemap(in, numinputs=0) (uint32_t num_versions) { - $1 = 50; -} - -%typemap(argout) (uint32_t *versions, uint32_t num_versions) { - uint32_t count = result; - if (count >= $2) - count = $2; - PyObject* list = PyList_New(count); - for (int j = 0; j < count; j++) - { - if ($1[j] < UINT32_MAX) - { - PyObject* item = PyInt_FromLong($1[j]); - int ok = PyList_SetItem(list,j,item); - if (ok != 0) - { - $result = Py_None; - break; - } - } - else - break; - } - $result = list; -} - -%typemap(freearg) (uint32_t *versions) { - free($1); -}
\ No newline at end of file diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig deleted file mode 100644 index 1442608d6bb4..000000000000 --- a/lldb/scripts/Python/python-wrapper.swig +++ /dev/null @@ -1,748 +0,0 @@ -%wrapper %{ - -class PyErr_Cleaner -{ -public: - PyErr_Cleaner(bool print=false) : - m_print(print) - { - } - - ~PyErr_Cleaner() - { - if (PyErr_Occurred()) - { - if(m_print) - PyErr_Print(); - PyErr_Clear(); - } - } - -private: - bool m_print; -}; - -// resolve a dotted Python name in the form -// foo.bar.baz.Foobar to an actual Python object -// if pmodule is NULL, the __main__ module will be used -// as the starting point for the search - -static PyObject* -ResolvePythonName(const char* name, - PyObject* pmodule = NULL) -{ - if (!name) - return pmodule; - - PyErr_Cleaner pyerr_cleanup(true); // show Python errors - - PyObject* main_dict; - - if (!pmodule) - { - pmodule = PyImport_AddModule ("__main__"); - if (!pmodule) - return NULL; - } - - if (!PyDict_Check(pmodule)) - { - main_dict = PyModule_GetDict (pmodule); - if (!main_dict) - return NULL; - } - else - main_dict = pmodule; - - const char* dot_pos = ::strchr(name, '.'); - - PyObject *dest_object; - PyObject *key, *value; - Py_ssize_t pos = 0; - - if (!dot_pos) - { - dest_object = NULL; - while (PyDict_Next (main_dict, &pos, &key, &value)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), name) == 0) - { - dest_object = value; - break; - } - } - if (!dest_object || dest_object == Py_None) - return NULL; - return dest_object; - } - else - { - size_t len = dot_pos - name; - std::string piece(name,len); - pmodule = ResolvePythonName(piece.c_str(), main_dict); - if (!pmodule) - return NULL; - name = dot_pos+1; - return ResolvePythonName(dot_pos+1,pmodule); // tail recursion.. should be optimized by the compiler - } -} - -static PyObject* -FindSessionDictionary(const char *session_dictionary_name) -{ - return ResolvePythonName(session_dictionary_name, NULL); -} - -// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) -// and is used when a script command is attached to a breakpoint for execution. - -SWIGEXPORT bool -LLDBSwigPythonBreakpointCallbackFunction -( - const char *python_function_name, - const char *session_dictionary_name, - const lldb::StackFrameSP& frame_sp, - const lldb::BreakpointLocationSP& bp_loc_sp -) -{ - lldb::SBFrame sb_frame (frame_sp); - lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); - - bool stop_at_breakpoint = true; - PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); - PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); - - if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL) - return stop_at_breakpoint; - - if (!python_function_name || !session_dictionary_name) - return stop_at_breakpoint; - - PyObject *session_dict, *pfunc; - PyObject *pargs, *pvalue; - - session_dict = FindSessionDictionary (session_dictionary_name); - if (session_dict != NULL) - { - pfunc = ResolvePythonName (python_function_name, session_dict); - if (pfunc != NULL) - { - // Set up the arguments and call the function. - - if (PyCallable_Check (pfunc)) - { - pargs = PyTuple_New (3); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return stop_at_breakpoint; - } - - PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj - PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj - PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL) - { - Py_DECREF (pvalue); - } - else if (PyErr_Occurred ()) - { - PyErr_Clear(); - } - Py_INCREF (session_dict); - } - else if (PyErr_Occurred()) - { - PyErr_Clear(); - } - } - else if (PyErr_Occurred()) - { - PyErr_Clear(); - } - } - else if (PyErr_Occurred ()) - { - PyErr_Clear (); - } - return stop_at_breakpoint; -} - -SWIGEXPORT bool -LLDBSwigPythonCallTypeScript -( - const char *python_function_name, - const void *session_dictionary, - const lldb::ValueObjectSP& valobj_sp, - void** pyfunct_wrapper, - std::string& retval -) -{ - lldb::SBValue sb_value (valobj_sp); - - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &sb_value, SWIGTYPE_p_lldb__SBValue, 0); - - if (ValObj_PyObj == NULL) - return false; - - if (!python_function_name || !session_dictionary) - return false; - - PyObject *session_dict = (PyObject*)session_dictionary, *pfunc = NULL, *pargs = NULL, *pvalue = NULL; - - if (pyfunct_wrapper && *pyfunct_wrapper && PyFunction_Check (*pyfunct_wrapper)) - { - pfunc = (PyObject*)(*pyfunct_wrapper); - if (pfunc->ob_refcnt == 1) - { - Py_XDECREF(pfunc); - pfunc = NULL; - } - } - - if (PyDict_Check(session_dict)) - { - PyErr_Cleaner pyerr_cleanup(true); // show Python errors - - if (!pfunc) - { - pfunc = ResolvePythonName (python_function_name, session_dict); - if (!pfunc || !PyFunction_Check (pfunc)) - return false; - else - { - if (pyfunct_wrapper) - *pyfunct_wrapper = pfunc; - } - } - /*else - printf("caching works!!!!\n");*/ - - pargs = PyTuple_Pack(2, ValObj_PyObj, session_dict); - if (pargs == NULL) - return false; - - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL && pvalue != Py_None && PyString_Check(pvalue)) - retval.assign(PyString_AsString(pvalue)); - Py_XDECREF (pvalue); - Py_INCREF (session_dict); - } - return true; -} - -SWIGEXPORT void* -LLDBSwigPythonCreateSyntheticProvider -( - const std::string python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP& valobj_sp -) -{ - PyObject* retval = NULL; - - if (python_class_name.empty() || !session_dictionary_name) - Py_RETURN_NONE; - - // I do not want the SBValue to be deallocated when going out of scope because python - // has ownership of it and will manage memory for this object by itself - lldb::SBValue *valobj_sb = new lldb::SBValue(valobj_sp); - - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *)valobj_sb, SWIGTYPE_p_lldb__SBValue, 0); - - if (ValObj_PyObj == NULL) - Py_RETURN_NONE; - - const char* python_function_name = python_class_name.c_str(); - - PyObject *session_dict, *pfunc; - PyObject *pvalue; - - session_dict = FindSessionDictionary (session_dictionary_name); - if (session_dict != NULL) - { - pfunc = ResolvePythonName (python_function_name, session_dict); - if (pfunc != NULL) - { - // Set up the arguments and call the function. - - if (PyCallable_Check (pfunc)) - { - PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict); - - if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear(); - return retval; - } - - if (argList == NULL) - { - return retval; - } - - Py_INCREF(ValObj_PyObj); - - pvalue = PyObject_CallObject(pfunc, argList); - - Py_DECREF(argList); - - if (pvalue != NULL) - { - if (pvalue != Py_None) - retval = pvalue; - else - { - retval = Py_None; - Py_INCREF(retval); - } - } - else if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear(); - } - Py_INCREF (session_dict); - } - else if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - } - else if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - } - else if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear (); - } - if (retval) - return retval; - else - Py_RETURN_NONE; -} - -/* -these four calls below are meant to support -Python-based synthetic children providers -they essentially mimic the four pure virtual -method calls provided by the frontend class -*/ - -SWIGEXPORT uint32_t -LLDBSwigPython_CalculateNumChildren -( - PyObject *implementor -) -{ - - static char callee_name[] = "num_children"; - - if (implementor == NULL || implementor == Py_None) - return 0; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return UINT32_MAX; - } - long retval = PyInt_AsLong(py_return); - Py_DECREF(py_return); - if (retval >= 0) - return (uint32_t)retval; - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - return 0; -} - -SWIGEXPORT PyObject* -LLDBSwigPython_GetChildAtIndex -( - PyObject *implementor, - uint32_t idx -) -{ - - static char callee_name[] = "get_child_at_index"; - static char param_format[] = "i"; - - if (implementor == NULL || implementor == Py_None) - return NULL; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, idx); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return NULL; - } - - lldb::SBValue* sbvalue_ptr = NULL; - - if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1) - { - Py_DECREF(py_return); - return NULL; - } - - if (sbvalue_ptr == NULL) - return NULL; - - return py_return; -} - -SWIGEXPORT int -LLDBSwigPython_GetIndexOfChildWithName -( - PyObject *implementor, - const char* child_name -) -{ - static char callee_name[] = "get_child_index"; - static char param_format[] = "s"; - - if (implementor == NULL || implementor == Py_None) - return 0; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, child_name); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return UINT32_MAX; - } - long retval = PyInt_AsLong(py_return); - Py_DECREF(py_return); - if (retval >= 0) - return (uint32_t)retval; - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - return 0; -} - -SWIGEXPORT bool -LLDBSwigPython_UpdateSynthProviderInstance -( - PyObject *implementor -) -{ - - bool ret_val = false; - - static char callee_name[] = "update"; - - if (implementor == NULL || implementor == Py_None) - return ret_val; - - // all this code is here because update is optional, so we don't want to bother trying to call it unless it's been def:ined for us - // other synth provider calls are mandatory, so we want to fail in a very obvious way if they are missing! - PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name); - - if (PyErr_Occurred()) - { - PyErr_Clear(); - } - - if (pmeth == NULL || pmeth == Py_None) - { - Py_XDECREF(pmeth); - return ret_val; - } - - if (PyCallable_Check(pmeth) == 0) - { - if (PyErr_Occurred()) - { - PyErr_Clear(); - } - - Py_XDECREF(pmeth); - return ret_val; - } - - if (PyErr_Occurred()) - { - PyErr_Clear(); - } - - Py_XDECREF(pmeth); - - // right now we know this function exists and is callable.. - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL); - - // if it fails, print the error but otherwise go on - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == Py_True) - ret_val = true; - - Py_XDECREF(py_return); - - return ret_val; - -} - -SWIGEXPORT void* -LLDBSWIGPython_CastPyObjectToSBValue -( - PyObject* data -) -{ - lldb::SBValue* sb_ptr = NULL; - - int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0); - - if (valid_cast == -1) - return NULL; - - return sb_ptr; -} - -// Currently, SBCommandReturnObjectReleaser wraps an std::auto_ptr to an -// lldb_private::CommandReturnObject. This means that the destructor for the -// SB object will deallocate its contained CommandReturnObject. Because that -// object is used as the real return object for Python-based commands, we want -// it to stay around. Thus, we release the auto_ptr before returning from -// LLDBSwigPythonCallCommand, and to guarantee that the release will occur no -// matter how we exit from the function, we have a releaser object whose -// destructor does the right thing for us -class SBCommandReturnObjectReleaser -{ -public: - SBCommandReturnObjectReleaser (lldb::SBCommandReturnObject &obj) : - m_command_return_object_ref (obj) - { - } - - ~SBCommandReturnObjectReleaser () - { - m_command_return_object_ref.Release(); - } -private: - lldb::SBCommandReturnObject &m_command_return_object_ref; -}; - -SWIGEXPORT bool -LLDBSwigPythonCallCommand -( - const char *python_function_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger, - const char* args, - std::string& err_msg, - lldb_private::CommandReturnObject& cmd_retobj -) -{ - - lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj); - SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb); - lldb::SBDebugger debugger_sb(debugger); - - bool retval = false; - - PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0); - PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &cmd_retobj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); - - if (DebuggerObj_PyObj == NULL) - return retval; - - if (CmdRetObj_PyObj == NULL) - return retval; - - if (!python_function_name || !session_dictionary_name) - return retval; - - PyObject *session_dict, *pfunc; - PyObject *pargs, *pvalue; - - session_dict = FindSessionDictionary (session_dictionary_name); - if (session_dict != NULL) - { - pfunc = ResolvePythonName (python_function_name, session_dict); - if (pfunc != NULL) - { - // Set up the arguments and call the function. - - if (PyCallable_Check (pfunc)) - { - pargs = PyTuple_New (4); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return retval; - } - - PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj - PyTuple_SetItem (pargs, 1, PyString_FromString(args)); - PyTuple_SetItem (pargs, 2, CmdRetObj_PyObj); // This "steals" a reference to CmdRetObj_PyObj - PyTuple_SetItem (pargs, 3, session_dict); // This "steals" a reference to session_dict - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL) - { - if (pvalue == Py_None) // no error - { - err_msg.clear(); - retval = true; - } - else - { - // return value is an error string - if (PyString_CheckExact(pvalue)) - err_msg.assign(PyString_AsString(pvalue)); - retval = false; - } - Py_DECREF (pvalue); - } - else if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear(); - } - Py_INCREF (session_dict); - } - else if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - } - else if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - } - else if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear (); - } - return retval; -} - -SWIGEXPORT bool -LLDBSwigPythonCallModuleInit -( - const std::string python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger -) -{ - - lldb::SBDebugger debugger_sb(debugger); - - bool retval = false; - - PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0); - - if (DebuggerObj_PyObj == NULL) - return retval; - - if (!(python_module_name.length()) || !session_dictionary_name) - return retval; - - PyObject *session_dict, *pfunc; - PyObject *pargs, *pvalue; - - session_dict = FindSessionDictionary (session_dictionary_name); - - std::string python_function_name_string = python_module_name + (".__lldb_init_module"); - const char* python_function_name = python_function_name_string.c_str(); - - if (session_dict != NULL) - { - pfunc = ResolvePythonName (python_function_name, session_dict); - - if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that - { - PyErr_Clear(); - return true; - } - - if (pfunc == NULL) - return true; - else - { - // Set up the arguments and call the function. - - if (PyCallable_Check (pfunc)) - { - pargs = PyTuple_New (2); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return retval; - } - - PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj - PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear(); - } - else - { - retval = true; - Py_XDECREF (pvalue); - } - Py_INCREF (session_dict); - } - else if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - } - } - return retval; -} - -%} |
