Search code examples
pythongdbpython-c-apipyenv

Cannot start dbg on my python C extension


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


Solution

  • 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