#!/bin/bash # # Install Voltron for whichever debuggers are detected (only GDB and LLDB so # far). # function usage { cat <> ${GDB_INIT_FILE} fi if [ "${BACKEND_LLDB}" -eq 1 ]; then # Find the Python version used by LLDB LLDB_PYVER=$(${LLDB} -Qxb --one-line 'script import platform; print(".".join(platform.python_version_tuple()[:2]))'|tail -1) LLDB_PYTHON=$(${LLDB} -Qxb --one-line 'script import sys; print(sys.executable)'|tail -1) LLDB_PYTHON="${LLDB_PYTHON/%$LLDB_PYVER/}${LLDB_PYVER}" ${LLDB_PYTHON} -m pip install --user --upgrade six if [ -n "${VENV}" ]; then echo "Creating virtualenv..." ${LLDB_PYTHON} -m pip install --user virtualenv ${LLDB_PYTHON} -m virtualenv "${VENV}" LLDB_PYTHON="${VENV}/bin/python" LLDB_SITE_PACKAGES=$(find "${VENV}" -name site-packages) elif [ -z "${USER_MODE}" ]; then LLDB_SITE_PACKAGES=$(${LLDB} -Qxb --one-line 'script import site; print(site.getsitepackages()[0])'|tail -1) else LLDB_SITE_PACKAGES=$(${LLDB} -Qxb --one-line 'script import site; print(site.getusersitepackages())'|tail -1) fi install_packages if [ "$LLDB_SITE_PACKAGES" == "$GDB_SITE_PACKAGES" ]; then echo "Skipping installation for LLDB - same site-packages directory" else # Install Voltron and dependencies ${SUDO} ${LLDB_PYTHON} -m pip install -U $USER_MODE $DEV_MODE . fi # Add Voltron to lldbinit LLDB_INIT_FILE="${HOME}/.lldbinit" if [ -e ${LLDB_INIT_FILE} ]; then sed -i.bak '/voltron/d' ${LLDB_INIT_FILE} fi if [ -z "${DEV_MODE}" ]; then LLDB_ENTRY_FILE="$LLDB_SITE_PACKAGES/voltron/entry.py" else LLDB_ENTRY_FILE="$(pwd)/voltron/entry.py" fi if [ -n "${VENV}" ]; then echo "script import sys;sys.path.append('${LLDB_SITE_PACKAGES}')" >> ${LLDB_INIT_FILE} fi echo "command script import $LLDB_ENTRY_FILE" >> ${LLDB_INIT_FILE} fi if [ "${BACKEND_GDB}" -ne 1 ] && [ "${BACKEND_LLDB}" -ne 1 ]; then # Find system Python PYTHON=$(command -v python) PYVER=$(${PYTHON} -c 'import platform; print(".".join(platform.python_version_tuple()[:2]))') if [ -z $USER_MODE ]; then PYTHON_SITE_PACKAGES=$(${PYTHON} -c 'import site; print(site.getsitepackages()[0])') else PYTHON_SITE_PACKAGES=$(${PYTHON} -c 'import site; print(site.getusersitepackages())') fi install_packages # Install Voltron and dependencies ${SUDO} ${PYTHON} -m pip install -U $USER_MODE $DEV_MODE . fi set +x echo "==============================================================" if [ "${BACKEND_GDB}" -eq 1 ]; then echo "Installed for GDB (${GDB}):" echo " Python: $GDB_PYTHON" echo " Packages directory: $GDB_SITE_PACKAGES" echo " Added voltron to: $GDB_INIT_FILE" echo " Entry point: $GDB_ENTRY_FILE" fi if [ "${BACKEND_LLDB}" -eq 1 ]; then echo "Installed for LLDB (${LLDB}):" echo " Python: $LLDB_PYTHON" echo " Packages directory: $LLDB_SITE_PACKAGES" echo " Added voltron to: $LLDB_INIT_FILE" echo " Entry point: $LLDB_ENTRY_FILE" fi if [ "${BACKEND_GDB}" -ne 1 ] && [ "${BACKEND_LLDB}" -ne 1 ]; then if [ -z "${GDB}" ] && [ -z "${LLDB}" ]; then echo -n "Couldn't find any debuggers. " else echo -n "No debuggers selected. " fi echo "Installed using the Python in your path:" echo " Python: $PYTHON" echo " Packages directory: $PYTHON_SITE_PACKAGES" echo " Did not add Voltron to any debugger init files." fi