I am trying to see the contents of an Eigen vector in the Locals and Expressions window of the QtCreator:
I see that it is a vector with 10 components:
but when I click it open I get:
I tried to use this script to do the trick. I saved it along with an empty __init__.py file into folder ~/Scripts/Eigen and created the .gdbinit file:
python
import sys
sys.path.insert(0, '/home/martin/Scripts/Eigen')
from printers import register_eigen_printers
register_eigen_printers (None)
end
I restarted QtCreator and nothing changed. I have checked the "read .gdbinit at startup" option in QtCreator settings and still nothing.
What is worrying me is that I know that in the past the viewing of Eigen objects worked without me meddling with some scripts.
Please, what am I doing wrong?
I am using:
gcc version 4.8.1
Ubuntu 13.10
gdb 7.6.1-ubuntu
Qt Creator 3.0.0
Based on Qt 5.2.0
and I am compiling using these flags:
g++ -c -pipe -gdwarf-4 -fvar-tracking-assignments -g
-Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG
EDIT:
as @ggael suggested, I tried to run the gdb directly:
(gdb) run
Starting program: /home/martin/Projects/TestGrounds/test
Traceback (most recent call last):
File "/usr/lib/debug/usr/lib/i386-linux-gnu/libstdc++.so.6.0.18-gdb.py", line 59, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
Traceback (most recent call last):
File "/usr/lib/debug/usr/lib/i386-linux-gnu/libstdc++.so.6.0.18-gdb.py", line 59, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
And then:
(gdb) print vec
Python Exception <class 'TypeError'> 'map' object is not subscriptable:
Python Exception <class 'TypeError'> 'map' object is not subscriptable:
$1 = {<Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >> = {<Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >> = {<Eigen::DenseBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >> = {<Eigen::internal::special_scalar_op_base<Eigen::Matrix<double, -1, 1, 0, -1, 1>, double, double, false>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 3>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 1>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 0>> = {<Eigen::EigenBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>},
m_storage = {m_data = 0x804e020, m_rows = 10}}, <No data fields>}
Please, could you explain what does this mean? What is libstdcxx?
This is a bug in /usr/lib/debug/usr/lib/i386-linux-gnu/libstdc++.so.6.0.18-gdb.py
. Make sure you have the lastest version of the gcc4.8 packages, it might be that this issue is already fixed in unbuntu (it is fixed in debian). See this bug entry. In the last ressort you can patch this file so that it searches in the right location.
Works for me as expected. The output looks like
vec (10 x 1), ColumnMajor Eigen::VectorXd
[0] 3.1400000000000001 double
[1] 3.1400000000000001 double
[2] 3.1400000000000001 double
[3] 3.1400000000000001 double
[4] 3.1400000000000001 double
[5] 3.1400000000000001 double
[6] 3.1400000000000001 double
[7] 3.1400000000000001 double
[8] 3.1400000000000001 double
[9] 3.1400000000000001 double
Make sure to use Qt Creator's own pretty-printing system by removing(!) the checkmark in Tools/Options/Debugger/GDB/Load system pretty printers. You also don't need the code you put into your .gdbinit in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With