Im using python3.6.1 installed in pyenv. I have problem with running gdb on my code. When I run gdb --args python mycode.py
it ends with error "/home/vydra/.pyenv/shims/python": not in executable format: File format not recognized
Asked
Active
Viewed 1,116 times
6

wyDra
- 65
- 5
-
have you checked the contents of `/home/vydra/.pyenv/shims/python` ? it's probably a script that runs something else. gdb can only debug real executables. – Jean-François Fabre Jan 07 '18 at 20:44
-
yes, that's the problem. is there any easy way, how to "persuade" gdb to run it anyway? because it's quite complicated, and it would be easier install python from source, but I'd like to avoid it. (my distro doesn't provide package for python version I need, and that's why I am using pyenv) – wyDra Jan 07 '18 at 21:09
-
check what's in `/home/vydra/.pyenv/shims/python` since it's probably a script. Change the line where it runs the actual python exe by adding gdb prefix – Jean-François Fabre Jan 07 '18 at 21:24
1 Answers
7
As suggested by Jean-François Fabre, the python file installed by pyenv is actually a bash script. You can easily make gdb run this script with:
gdb -ex r --args bash python mycode.py
See this question for other approaches: Use GDB to debug a C++ program called from a shell script

krassowski
- 13,598
- 4
- 60
- 92