Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No gdb debugging symbol table files #2236

Closed
1 task done
HaoZeke opened this issue May 21, 2018 · 4 comments
Closed
1 task done

No gdb debugging symbol table files #2236

HaoZeke opened this issue May 21, 2018 · 4 comments
Labels
Type: Discussion This issue is open for discussion.

Comments

@HaoZeke
Copy link

HaoZeke commented May 21, 2018

  • Be sure to check the existing issues (both open and closed!).

So the problem is that I am unable to use gdb helper functions like py-bt with pipenv projects.

Basically:

$ pipenv shell
$ gdb
>>> py-bt
Undefined command: "py-bt".  Try "help".
>>> py-list
Undefined command: "py-list".  Try "help".

From within a project with pipenv shell.

Pipenv details

Please run $ python -m pipenv.help, and paste the results here.

python -m pipenv.help                   03:13:43 
$ python -m pipenv.help output

Pipenv version: '2018.05.18'

Pipenv location: '/usr/lib/python3.6/site-packages/pipenv'

Python location: '/bin/python'

Other Python installations in PATH:

  • 2.7: /bin/python2.7

  • 2.7: /bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.6: /bin/python3.6m

  • 3.6: /bin/python3.6

  • 3.6: /usr/bin/python3.6

  • 3.6.5: /bin/python

  • 3.6.5: /usr/bin/python

  • 2.7.15: /bin/python2

  • 2.7.15: /usr/bin/python2

  • 3.6.5: /bin/python3

  • 3.6.5: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.5',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.16.9-2-ck-haswell',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP PREEMPT Thu May 17 11:49:15 EDT 2018',
 'python_full_version': '3.6.5',
 'python_version': '3.6',
 'sys_platform': 'linux'}

System environment variables:

  • XDG_SEAT_PATH
  • XDG_CONFIG_DIRS
  • LANG
  • DISPLAY
  • SHLVL
  • LOGNAME
  • XDG_VTNR
  • LANGUAGE
  • PWD
  • MOZ_PLUGIN_PATH
  • XDG_GREETER_DATA_DIR
  • MAVEN_OPTS
  • XAUTHORITY
  • XDG_DATA_HOME
  • XDG_SESSION_ID
  • GTK2_RC_FILES
  • DESKTOP_SESSION
  • XDG_SESSION_DESKTOP
  • GDMSESSION
  • COLORTERM
  • DBUS_SESSION_BUS_ADDRESS
  • VTE_VERSION
  • MAIL
  • XDG_DATA_DIRS
  • _
  • _LXSESSION_PID
  • XDG_MENU_PREFIX
  • SHELL
  • XDG_CONFIG_HOME
  • SAL_USE_VCLPLUGIN
  • XDG_SESSION_TYPE
  • TERM
  • GTK_MODULES
  • XDG_CURRENT_DESKTOP
  • PATH
  • HOME
  • XDG_SEAT
  • TILIX_ID
  • USER
  • XDG_RUNTIME_DIR
  • XDG_SESSION_PATH
  • OLDPWD
  • PAGER
  • LESS
  • LESSCHARSET
  • LESS_TERMCAP_mb
  • LESS_TERMCAP_md
  • LESS_TERMCAP_me
  • LESS_TERMCAP_se
  • LESS_TERMCAP_so
  • LESS_TERMCAP_ue
  • LESS_TERMCAP_us
  • LSCOLORS
  • GOPATH
  • GOBIN
  • CORRECT_IGNORE
  • CORRECT_IGNORE_FILE
  • WORDCHARS
  • HISTFILE
  • HISTSIZE
  • SAVEHIST
  • LISTMAX
  • INTERACTIVE_FILTER
  • DOTPATH
  • SSH_AUTH_SOCK
  • SSH_AGENT_PID
  • LS_COLORS
  • EDITOR
  • userid
  • groupid
  • GOCACHE
  • WORKON_HOME
  • _VIRTUALENVWRAPPER_API
  • VIRTUALENVWRAPPER_SCRIPT
  • USE_CCACHE
  • PACMAN
  • _SILENT_JAVA_OPTIONS
  • JAVA_FONTS
  • MPD_HOST
  • WINEPREFIX
  • WINEARCH
  • QT_QPA_PLATFORMTHEME
  • QT_AUTO_SCREEN_SCALE_FACTOR
  • LD
  • USE_HOST_LEX
  • _JAVA_AWT_WM_NONREPARENTING
  • GPG_TTY
  • DOCKER_ID_USER
  • INFINALITY_FT_BRIGHTNESS
  • INFINALITY_FT_FILTER_PARAMS
  • LD_LIBRARY_PATH
  • C_INCLUDE_PATH
  • CPLUS_INCLUDE_PATH
  • CPATH
  • PYTHONPATH
  • ZPLUG_ROOT
  • PERIOD
  • FPATH
  • ZPLUG_HOME
  • ZPLUG_THREADS
  • ZPLUG_PROTOCOL
  • ZPLUG_FILTER
  • ZPLUG_LOADFILE
  • ZPLUG_USE_CACHE
  • ZPLUG_ERROR_LOG
  • ZPLUG_BIN
  • ZPLUG_CACHE_DIR
  • ZPLUG_REPOS
  • _ZPLUG_VERSION
  • _ZPLUG_URL
  • _ZPLUG_OHMYZSH
  • _ZPLUG_PREZTO
  • _ZPLUG_AWKPATH
  • _ZPLUG_CONFIG_SUBSHELL
  • NVM_LAZY_LOAD
  • NVM_DIR
  • ENHANCD_DIR
  • ENHANCD_DISABLE_DOT
  • ENHANCD_DISABLE_HYPHEN
  • ENHANCD_DISABLE_HOME
  • ENHANCD_DOT_ARG
  • ENHANCD_HYPHEN_ARG
  • ENHANCD_HOME_ARG
  • ENHANCD_DOT_SHOW_FULLPATH
  • ENHANCD_USE_FUZZY_MATCH
  • ENHANCD_ROOT
  • ENHANCD_COMMAND
  • ENHANCD_FILTER
  • GIT_FZF
  • FZF_DEFAULT_OPTS
  • ZSH
  • ZSH_CACHE_DIR
  • LC_ALL
  • LC_CTYPE
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: $HOME/.zplug/bin:/bin:$HOME/Git/Github/Dotfiles/Scripts:$HOME/.node_modules/bin:$HOME/.local/bin:$HOME/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/opt/cxoffice/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$HOME/.rvm/bin:$HOME/.local/bin/gitHelpers:$HOME/.local/bin/droidHelpers:$HOME/.local/bin/dockerHelpers:$HOME/.local/bin/shellHelpers:$HOME/.local/bin/fileHelpers:$HOME/.local/bin/webHelpers:$HOME/.local/bin/installHelpers:$HOME/.cargo/bin:$HOME/.go/bin:$HOME/Git/Github/Linux/xmr-stak-cpu/bin:/var/lib/snapd/snap/bin:/$HOME/.gem/ruby/2.4.0/bin:$HOME/LabWork/IITB/Icover:/root/.gem/ruby/2.2.0/bin:$HOME/Matlab/MATLAB_Production_Server/R2015a/bin:$HOME/.gem/ruby/2.2.0/bin:$HOME/.gem/ruby/2.3.0/bin:/opt/schrodinger2016-2:$HOME/Git/Github/mylammps/src:$HOME/Git/Github/espresso/build:$HOME/Git/Github/Scripts/Build:$HOME/Git/Github/Scripts/System:$HOME/.local/g16:/usr/local/MATLAB/R2017a/bin
  • SHELL: /bin/zsh
  • EDITOR: nvim
  • LANG: en_US.UTF-8
  • PWD: $HOME/.virtualenvs/pyProj-UoyQSP0Z


Expected result

I expected the stack trace. Or atleast recognition of the command.

Basically something like:

(gdb) py-list
2025        # Open external files with our Mac app
2026        if sys.platform == "darwin" and 'Spyder.app' in __file__:
2027            main.connect(app, SIGNAL('open_external_file(QString)'),
2028                         lambda fname: main.open_external_file(fname))
2029
>2030        app.exec_()
2031        return main
2032
2033
2034    def __remove_temp_session():
2035        if osp.isfile(TEMP_SESSION_PATH):
Actual result

So the actual result is already above.

Additional information pertaining to this is:

Pipenv output
gdb
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
>>> show auto-load scripts-directory
List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load.
>>> set debug auto-load
>>> file python
Reading symbols from python...(no debugging symbols found)...done.
auto-load: Attempted file "$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.gdb" does not exist.
auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load".
auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load".
auto-load: Attempted file "/usr/lib/debug$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.gdb" does not exist.
auto-load: Attempted file "/usr/share/gdb/auto-load$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.gdb" does not exist.
auto-load: Attempted file "$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.py" does not exist.
auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load".
auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load".
auto-load: Attempted file "/usr/lib/debug$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.py" does not exist.
auto-load: Attempted file "/usr/share/gdb/auto-load$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.py" does not exist.
auto-load: Attempted file "$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.scm" does not exist.
auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load".
auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load".
auto-load: Attempted file "/usr/lib/debug$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.scm" does not exist.
auto-load: Attempted file "/usr/share/gdb/auto-load$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.scm" does not exist.
Expected Output
(gdb) show auto-load scripts-directory
List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load.
(gdb) set debug auto-load
(gdb) file /usr/bin/python
Reading symbols from /usr/bin/python...Reading symbols from /usr/lib/debug//usr/bin/python2.7...done.
auto-load: Attempted file "/usr/lib/debug/usr/bin/python2.7-gdb.gdb" does not exist.
auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load".
auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load".
auto-load: Attempted file "/usr/share/gdb/auto-load/usr/lib/debug/usr/bin/python2.7-gdb.gdb" does not exist.
auto-load: Attempted file "/usr/lib/debug/usr/bin/python2.7-gdb.py" exists.
auto-load: Loading python script "/usr/lib/debug/usr/bin/python2.7-gdb.py" by extension for objfile "/usr/lib/debug/usr/bin/python2.7".
Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
numpy = "*"
scipy = "*"
dbg = "*"

[dev-packages]

[requires]
python_version = "2.7"
Commands
$ pipenv --two
# Not really necessary here
$ pipenv install numpy scipy
$ gdb
>>> py-bt
>>> py-list
@uranusjr
Copy link
Member

I’m not vey familar with GDB’s Python extensions. Does it work if you use a plain virtualenv? How did you set up your development environment before adopting Pipenv? Maybe we can find out what Pipenv does wrong by comparing the two approaches.

@HaoZeke
Copy link
Author

HaoZeke commented May 22, 2018

Well I need to rebuild my python from the ABS (on ArchLinux there are no debug packages), after that I will run into whats basically described over at pypa/virtualenv#644.

However I was under the impression that pipenv ought to pull debugging symbol tables while initializing the virtualenv..

@pbasista
Copy link

If I understand correctly, this happens in a pipenv:

auto-load: Attempted file "/usr/lib/debug$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.gdb" does not exist.

and this happens outside of a pipenv:

auto-load: Attempted file "/usr/lib/debug/usr/bin/python2.7-gdb.py" exists.

I assume that pipenv does not copy the necessary GDB scripts to the newly created virtualenvs and therefore GDB needs to load them from their original locations.

This can be achieved by using a symlinked Python executable from within a virtualenv. GDB uses full path to the executable, after following symlinks, to construct the path to the required GDB script. That is why you see GDB attempting to load a file from a strange path /usr/lib/debug$HOME/.virtualenvs/pyProj-UoyQSP0Z/bin/python2-gdb.gdb inside pipenv. If possible, configure pipenv so that symlinks, not copies, of the Python executables, are used.

If symlinks are not an option, you can copy the GDB scripts to the locations where GDB expects to find them. You may also modify auto-load scripts-directory and auto-load safe-path according to your needs. It would change the starting points where GDB looks for the scripts to auto-load. But the actual script paths would still be derived from the full path to the object file (in this case the Python executable). I am not aware of a way to change that behavior.

@uranusjr
Copy link
Member

uranusjr commented Jun 6, 2018

I’m a bit torned on deciding whether this should be classified as an upstream issue. Maybe virtualenv (and the built-in venv) should be responsible for this. Do they have this problem on their own? (I image they do.) What do their maintainers have to say on this issue?

@uranusjr uranusjr added the Type: Discussion This issue is open for discussion. label Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Discussion This issue is open for discussion.
Projects
None yet
Development

No branches or pull requests

4 participants