My sense is that your problem is that you are invoking the pyenv
shim file, not the python
executable with gdb
. gdb
must be provided with the python
executable file path, not the shim script file. It needs the python
executable to load the symbols, etc.
Example:
> pyenv virtualenv 3.10 66824320
> pyenv local 66824320
> which python
> /Users/$USER/.pyenv/shims/python
>
> cat `which python` #!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x
program="${0##*/}"
export PYENV_ROOT="/Users/$USER/.pyenv"
exec "/usr/local/opt/pyenv/bin/pyenv" exec "$program" "$@"
what you need to open is:
> pyenv which python
/Users/$USER/.pyenv/versions/66824320/bin/python
to run gdb with the real python binary you need to pass the python executable file to gdb:
> gdb `pyenv which python`
GNU gdb (GDB) 13.2
Copyright (C) 2023 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-apple-darwin22.4.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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"...
Reading symbols from /Users/$USER/.pyenv/versions/66824320/bin/python...
Thus:
> gdb -ex r --args `pyenv which python` crash.py