Giter Site home page Giter Site logo

lldbpycharm's Introduction

Debug lldb Python scripts in PyCharm

This is the setup I use to work on lldb Python scripts in PyCharm with debugging and code-completion:

pycharm_debugging.png

lldb_debugging.png

First you will need a copy of lldb with an ad-hoc signature; otherwise, PyCharm won't be able to attach:

cp "$(xcrun -f lldb)" unsigned_lldb
codesign --force --sign - unsigned_lldb

Next you will need a virtual environment:

sh -c 'exec "$(xcode-select -p)"/Library/Frameworks/Python3.framework/Versions/Current/bin/python3 -m venv python_env'

Make a script for lldb and import it in .lldbinit. If you are on an arm64 macOS you will need to compile a custom pydevd shim because PyCharm only ships x86_64 binary. The source code for the shim is shipped with PyCharm:

cd "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac"
g++ -fPIC -D_REENTRANT -std=c++11 -arch arm64 -c -o attach_arm64.o attach.cpp
g++ -dynamiclib -nostartfiles -arch arm64 -o attach_arm64.dylib attach_arm64.o -lc

and use configure_pydevd() from pydevd_support.py.

Now run lldb:

DYLD_FRAMEWORK_PATH="$(dirname $(xcode-select -p))/SharedFrameworks" ./unsigned_lldb --local-lldbinit

Attach to the lldb process in PyCharm, set a breakpoint and run the command. PyCharm will break at a breakpoint, and you will be able to debug.

For completions support create a pth pointer to the lldb module:

echo "$(dirname $(xcode-select -p))"/SharedFrameworks/LLDB.framework/Versions/A/Resources/Python > "$(echo python_env/lib/python*)/site-packages/lldb.pth"

completion.png

lldbpycharm's People

Contributors

abdulowork avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

geekonion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.