gdb embeds python3.3, but support scripts are not compatible

Bug #1241668 reported by Russell Power
48
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Python
Fix Released
Unknown
gdb (Ubuntu)
Invalid
Medium
Unassigned
Saucy
Invalid
Undecided
Unassigned
python2.7 (Ubuntu)
Fix Released
Medium
Unassigned
Saucy
Won't Fix
Medium
Unassigned
python3.3 (Ubuntu)
Fix Released
Medium
Unassigned
Saucy
Won't Fix
Medium
Unassigned

Bug Description

The saucy gdb appears to be linked against libpython3.3.

This results in a conflict when trying to debug python2.7 programs, which use the python2.7-dbg.py scripts from python2.7-dbg. This makes debugging Python programs difficult.

  File "/usr/lib/debug/usr/bin/python2.7-gdb.py", line 54
    Py_TPFLAGS_HEAPTYPE = (1L << 9)
                            ^
SyntaxError: invalid syntax
  File "/usr/lib/debug/usr/bin/python2.7-gdb.py", line 54
    Py_TPFLAGS_HEAPTYPE = (1L << 9)

There are also invalid print statements that show up as well.

If these are updated, then the file parses, but `py-bt` fails with:

Error occurred in Python command: global name 'long' is not defined

Updating all of the long() references to int() doesn't work:

Error occurred in Python command: 'gdb.Value' object cannot be interpreted as an integer

Tags: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdb (Ubuntu):
status: New → Confirmed
Revision history for this message
David Coles (dcoles) wrote :

Looks like the cause of the "'gdb.Value' object cannot be interpreted as an integer" error is the range function not being able to turn a gdb.Value into an int. Put an explicit `int(val)` in there and I can get py-bt and py-list to work again.

I've attached a patch with the changes I've made, but I want to check that this doesn't break Python 2.7 support and clean it up a bit more (pretty sure that `long` and `int` have been unified for a while now) before submitting this upstream.

Changed in python:
status: Unknown → New
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Python 3 support" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Matthias Klose (doko) wrote :

please attach the patch to the upstream issue as well.

Matthias Klose (doko)
Changed in gdb (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Triaged
status: Triaged → Invalid
Changed in python2.7 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in python3.3 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in gdb (Ubuntu Saucy):
status: New → Invalid
Changed in python2.7 (Ubuntu Saucy):
importance: Undecided → Medium
status: New → Triaged
Changed in python3.3 (Ubuntu Saucy):
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Steve Langasek (vorlon) wrote :

jtaylor points out on IRC that fixing the syntax with 2to3 is insufficient to make this actually work.

Test case:

  $ sudo apt-get install python3-dbg gdb
  $ 2to3 /usr/lib/debug/usr/bin/python3.3m-gdb.py > /tmp/python-gdb.patch
  $ cd / && sudo patch -p0 < /tmp/python-gdb.patch
  $ gdb --args python3-dbg /usr/bin/lsb_release
  (gdb) break PyTuple_Size
  (gdb) run
  (gdb) bt

With gdb compiled for python3, instead of getting useful python information in the backtrace, you get python exceptions:

(gdb) bt
#0 PyTuple_Size (
    op=(None, <code at remote 0x7ffff7fe8340>, '_make_relax_case.<locals>._relax_case', <code at remote 0x7ffff7fe8400>)) at ../Objects/tupleobject.c:127
#1 0x00000000006567c0 in PyFunction_NewWithQualName (
Python Exception <class 'AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
    code=<code at remote 0x7ffff7fe84c0>, globals=,
    qualname='_make_relax_case') at ../Objects/funcobject.c:29
Python Exception <class 'TypeError'> 'gdb.Value' object cannot be interpreted as an integer:
<snip>

so this seems to need some further help.

Revision history for this message
Steve Langasek (vorlon) wrote :

jtaylor clarified that he had managed to misapply the patch from the upstream bug, and if it's applied correctly gdb works without generating python exceptions.

Changed in python:
status: New → Fix Released
Revision history for this message
Peter Feiner (pete5) wrote :

For anybody that's too impatient to wait for the saucy packages to be updated, here's how you apply the patch yourself:

wget -O - http://hg.python.org/cpython/raw-file/ef4636faf8bd/Tools/gdb/libpython.py | sudo tee /usr/lib/debug/usr/bin/python2.7-gdb.py

wget -O - http://hg.python.org/cpython/raw-file/752db82b7933/Tools/gdb/libpython.py | sudo tee /usr/lib/debug/usr/bin/python3.3m-gdb.py

Revision history for this message
Matthias Klose (doko) wrote :

fixed in trusty and utopic

Changed in python2.7 (Ubuntu):
status: Triaged → Fix Released
Changed in python3.3 (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Rolf Leggewie (r0lf) wrote :

saucy has seen the end of its life and is no longer receiving any updates. Marking the saucy task for this ticket as "Won't Fix".

Changed in python2.7 (Ubuntu Saucy):
status: Triaged → Won't Fix
Changed in python3.3 (Ubuntu Saucy):
status: Triaged → Won't Fix
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-tripleoclient 0.0.10

This issue was fixed in the openstack/python-tripleoclient 0.0.10 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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