Add Python support to GDB

Bug #1294231 reported by BSA
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Fix Released
Wishlist
Terry Guo

Bug Description

Modern IDE (Qt Creator) uses python scripts to dump containers in human readable view. But w/o support for Python GDB session closes. So it is difficult to debug programs using Qt Creator.

Revision history for this message
BSA (b-s-a) wrote :
Joey Ye (jinyun-ye)
Changed in gcc-arm-embedded:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Fatih Aşıcı (fatih-asici) wrote :

Cross-compiling python with mingw32 under Linux is not easy. It is not supported by upstream. There are some patches proposed; but they are difficult to maintain and not based on the latest version of Python 2.x.

Using the official binary package of Python 2.7.6, it is easy to build gdb with python support using mingw32 under Linux. The attached patch has the necessary changes.

At build time we can either,

 - download Python MSI file and extract it (not sure if it is possible) or,
 - consider Python is pre-installed (under Windows or with Wine) or,
 - include Python binaries inside source package (an archive like [1] is enough)

If we decide to include Python binaries inside the output package, then we must also include python27.dll which is normally installed into c:\windows\system32.

[1] http://master.qt-project.org/development_releases/prebuilt/gdb/build-prerequisites/

Terry Guo (terry.guo)
Changed in gcc-arm-embedded:
assignee: nobody → Terry Guo (terry.guo)
Revision history for this message
Terry Guo (terry.guo) wrote :

Thank you all for valuable inputs. I did some experiments with above suggestions and other suggestions. Here are my conclusions:

1). The most easy way is to use --with-python=yes when build for Linux on Ubuntu machine. The good thing is no need to include Python in release packages. The shortcoming is the generated tool chain will depend on a specific version Python library, which is the python version in the build machine. Thus not so portable. This way works for Linux build and Mac build, not for Mingw build.

2). Alternatively we can get Python source and build it in a static way. Then config gdb with option --with-python=PATH-TO-STATIC-PATH and build gdb. All the Python components will be statically linked to generated gdb. No more dependence on system python libraries. The shortcoming is we have to include Python source in our source package for user who want to rebuild everything from scratch. Fortunately Python is GPL license compatible stated at https://docs.python.org/2/license.html. Quoted here "The GPL-compatible licenses make it possible to combine Python with other software that is released under the GPL;" This way works for Linux build and Mac build, not for Mingw build.

3). For mingw build for windows platform, the Fatih's suggestions works well. I install Python 2.7 and then copy the installed folder to Ubuntu build machine, then configure gdb --with-python=PATH-TO-WIN-FOLDER, then perform normal mingw build. The generated gdb does support python now. But the shortcoming is it requires user to install corresponding python in their platform, otherwise gdb can not be initiated properly. This probably because we don't statically link python to gdb. So not good at portability either.

4). As suggested by Joey, we can take a small but practical step at the moment by enabling --with-python=yes for Ubuntu PPA build.

This requirement is still opening, any sharing and thoughts are welcomed.

Revision history for this message
Fatih Aşıcı (fatih-asici) wrote :

Qt developers provide some binaries for python enabled gdb[1]. It seems the linux binaries are built with the second method. Mingw32 builds link to python dynamically and contain python27.dll and other python files.

[1] http://master.qt-project.org/development_releases/prebuilt/gdb/

Revision history for this message
Fatih Aşıcı (fatih-asici) wrote :
Revision history for this message
Joey Ye (jinyun-ye) wrote :

GDB python support has been added into 4.9 2014q4 release. Please invoke with command arm-none-eabi-gdb-py

Changed in gcc-arm-embedded:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.