I am trying to see the contents of an Eigen vector in the Locals and Expressions window of the QtCreator:
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.
The problem was probably in the debugger itself. I tried out many combinations of
.gdbinit
and none of this really mattered. Then I tried a fresh install of Ubuntu 12.04 with old GDB 7.4 and a brand new QtCreator 3.0.1 and it worked! I got the same results for gcc 4.6, gcc 4.7 and gcc 4.8.1.
Then I tried the newest GDB 7.7 on Ubuntu 13.10 and again it worked, while GDB 7.5, GDB 7.6 did not work.
Also a strange thing, std::shared_ptr
is correctly viewed only in QtCreator 3.0.1.
std::multimap
is not pretty printed in any configuration.
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <memory>
#include <eigen3/Eigen/Dense>
int main(int argc, char *argv[])
{
std::vector<int> vec(4, 3);
std::map<int, std::string> map = {{1,"one"},{2,"two"},{3,"three"}};
std::multimap<int, std::string> multi = {{1,"one"},{2,"two"},{3,"three"}};
Eigen::VectorXd vector = Eigen::VectorXd::Constant(3, 3.14);
std::shared_ptr<Eigen::VectorXd> pointer(new Eigen::VectorXd(vector));
std::cout << vector << std::endl;
return 0;
}