4

I'd like to print Eigen matrices and vectors in gdb, and so I added the extension to do so found here: https://bitbucket.org/eigen/eigen/src/12a658962d4e/debug/gdb/printers.py

When I try to call print on some Eigen type in ddd, however, I get the following error:

Python Exception <class 'TypeError'> 'map' object is not subscriptable: 
Python Exception <class 'TypeError'> 'map' object is not subscriptable: 
Python Exception <class 'TypeError'> 'map' object is not subscriptable:

Based on this post I checked that my gcc version is 4.8.2 and my gdb version is 7.7.1, so neither of those are the problem.

Any ideas on how I might be able to fix this?

Community
  • 1
  • 1
rkeatin3
  • 88
  • 6

1 Answers1

2

Can you make sure that 2.7.6 is the version that gdb uses by making the following check from it?

  1. Start gdb.
  2. Type:

    import sys

    print (sys.version)

  3. End with CTRL+D

user2658323
  • 543
  • 4
  • 15
  • This is the output I get: 3.4.0 (default, Apr 11 2014, 13:08:40) – rkeatin3 Feb 04 '15 at 15:39
  • So that's the difference then. The script uses python 2 syntax, whether your gdb interpreter uses python 3. It has to be adapted to work in your environment. Related: https://stackoverflow.com/questions/6800481/python-map-object-is-not-subscriptable – user2658323 Feb 05 '15 at 15:18
  • Fixed, thanks! I was hoping it would print Matlab-style rather than element by element, but I guess there's my reason to learn a little python... – rkeatin3 Feb 05 '15 at 16:07
  • 1
    I used 2to3 tool (https://docs.python.org/2.7/library/2to3.html) to convert eigen-3.2.5/debug/gdb/printers.py and resolved the problem. – zhanxw Apr 27 '16 at 17:42