Cannot start dbg on my python C extension
Asked Answered
K

1

8

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

Koon answered 7/1, 2018 at 20:14 Comment(3)
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.Isocline
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)Koon
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 prefixIsocline
U
10

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

Upcoming answered 26/10, 2018 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.