20

I am using the Eigen C++ library downloadable from http://eigen.tuxfamily.org/. This is a C++ library for easier handling of Matrices and Arrays. I use g++ compiler and gdb for debugging. However, I found that I am unable to print the content of a Matrix (provided by Eigen) while using gdb.

Sooraj
  • 585
  • 1
  • 6
  • 12

3 Answers3

26

One trick you can use is the .data() member, it gives you a pointer to the raw array that contains the data. With that you can print it in GDB like so:

print *X.data()@Length_X

where X is the eigen variable and Length_X is the product of its rows and columns.

Kirillvh
  • 401
  • 4
  • 5
25

You have to install a gdb extension that you can find in eigen/debug/gdb/.

The comment at the beginning of the file explains how to install it.

Vikas
  • 2,220
  • 1
  • 15
  • 12
ggael
  • 28,425
  • 2
  • 65
  • 71
0

There is a github project specifically for adding eigen printing support to GDB.

It appears to be based on the code linked in this answer.

nobane
  • 76
  • 1
  • 7