Skip to content

Instantly share code, notes, and snippets.

@tyhoff tyhoff/.gdbinit
Last active Apr 13, 2020

Embed
What would you like to do?
.gdbinit modifications for using a Virtual/Conda environment with GDB Python scripts
# All of your normal .gdbinit commands, functions, and setup tasks
# Update GDB's Python paths with the `sys.path` values of the local Python installation,
# whether that is brew'ed Python, a virtualenv, or another system python.
# Convert GDB to interpret in Python
python
import os,subprocess,sys
# Execute a Python using the user's shell and pull out the sys.path (for site-packages)
paths = subprocess.check_output('python -c "import os,sys;print(os.linesep.join(sys.path).strip())"',shell=True).decode("utf-8").split()
# Extend GDB's Python's search path
sys.path.extend(paths)
end
@tyhoff

This comment has been minimized.

Copy link
Owner Author

tyhoff commented Apr 12, 2020

This was created for users to get around GDB not loading the activated virtual environments Python modules

If you are looking for an equivalent .lldbinit version, check out the other Gist:
https://gist.github.com/tyhoff/7a286945ef75947ad49a347dbc8708ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.