Virtualenv: gdb Python extensions not properly linked into new virtualenv

Created on 28 Aug 2014  ·  5Comments  ·  Source: pypa/virtualenv

I was playing around with virtualenv and gdb for debugging Python apps(that call out to some C libraries I wanted to inspect).

System:

$ virtualenv --version
1.11.4
$ uname -a
Linux virtual-machine 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ /usr/bin/python2.7-dbg --version
Python 2.7.6
$ gdb --version
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7

Setup of virtual environment:

$ virtualenv -p /usr/bin/python2.7-dbg debugenv
$ source debugenv/bin/activate

Testing gdb Python extended commands(fails):

(debugenv)$ gdb --args python
(gdb) py-bt
Undefined command: "py-bt".  Try "help".

This person on StackOverflow had a solution posted:
http://stackoverflow.com/questions/22931774/how-to-use-gdb-python-debugging-extension-inside-virtualenv

(debugenv)$ ln -s /usr/lib/debug/usr/bin/python2.7-gdb.py /path/to/debugenv/bin/python2.7-dbg-gdb.py
(debugenv)$ gdb --args python
(gdb) py-bt
Python Exception <class 'gdb.error'> No frame is currently selected.: 
Error occurred in Python command: No frame is currently selected.

I'm not sure if this should be implemented in virtualenv itself if it detects a Python debug executable is being used, but this was slightly annoying/confusing to deal with and wanted to make the virtualenv team aware.

bug help-wanted

Most helpful comment

Still a problem with python3.6-dbg on ubuntu 18.10

All 5 comments

Sweet i run into that same problem, thanks so far. If it doesn't hurt it should be added.

I meet this error, when import libpython and use py-bt: "Error occurred in Python command: __init__() takes exactly 3 arguments (2 given)"

This is still an issue?

I got the same problem:

(gdb) py-list
Undefined command: "py-list"

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

Still a problem with python3.6-dbg on ubuntu 18.10

Was this page helpful?
0 / 5 - 0 ratings