Commit 5cb7bd51 authored by hjk's avatar hjk

Debugger: Fix Eigen dumpers, again

This time with autotests.

Task-number: QTCREATORBUG-12193
Change-Id: Id91eecd38eb4ac76c68be8e9969651407a68ebf4
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 0c4b9455
......@@ -119,21 +119,26 @@ def qdump____m256i(d, value):
# return "Transposed"
def qdump__Eigen__Matrix(d, value):
listType = d.directBaseClass(value.type)
d.putItem(value.cast(listType))
d.putBetterType(value.type)
def qdump__Eigen__PlainObjectBase(d, value):
matrixType = d.templateArgument(value.type, 0)
innerType = d.templateArgument(matrixType, 0)
options = d.numericTemplateArgument(matrixType, 3)
innerType = d.templateArgument(value.type, 0)
options = d.numericTemplateArgument(value.type, 3)
rowMajor = (int(options) & 0x1)
argRow = d.numericTemplateArgument(matrixType, 1)
argCol = d.numericTemplateArgument(matrixType, 2)
storage = value["m_storage"]
nrows = toInteger(storage["m_rows"] if argRow == -1 else argRow)
ncols = toInteger(storage["m_cols"] if argCol == -1 else argCol)
p = d.createPointerValue(d.addressOf(value), innerType)
argRow = d.numericTemplateArgument(value.type, 1)
argCol = d.numericTemplateArgument(value.type, 2)
# The magic dimension value is -1 in Eigen3, but 10000 in Eigen2.
# 10000 x 10000 matrices are rare, vectors of dim 10000 less so.
# So "fix" only the matrix case:
if argCol == 10000 and argRow == 10000:
argCol = -1
argRow = -1
if argCol != -1 and argRow != -1:
nrows = argRow
ncols = argCol
p = d.createPointerValue(d.addressOf(value), innerType)
else:
storage = value["m_storage"]
nrows = toInteger(storage["m_rows"]) if argRow == -1 else argRow
ncols = toInteger(storage["m_cols"]) if argCol == -1 else argCol
p = d.createValue(d.addressOf(value), innerType.pointer())
d.putValue("(%s x %s), %s" % (nrows, ncols, ["ColumnMajor", "RowMajor"][rowMajor]))
d.putField("keeporder", "1")
d.putNumChild(nrows * ncols)
......
......@@ -618,8 +618,23 @@ public:
const Data &operator+(const EigenProfile &) const
{
profileExtra +=
"INCLUDEPATH += /usr/include/eigen2\n"
"INCLUDEPATH += /usr/include/eigen3\n";
"exists(/usr/include/eigen3/Eigen/Core) {\n"
" DEFINES += HAS_EIGEN3\n"
" INCLUDEPATH += /usr/include/eigen3\n"
"}\n"
"exists(/usr/local/include/eigen3/Eigen/Core) {\n"
" DEFINES += HAS_EIGEN3\n"
" INCLUDEPATH += /usr/local/include/eigen3\n"
"}\n"
"\n"
"exists(/usr/include/eigen2/Eigen/Core) {\n"
" DEFINES += HAS_EIGEN2\n"
" INCLUDEPATH += /usr/include/eigen2\n"
"}\n"
"exists(/usr/local/include/eigen2/Eigen/Core) {\n"
" DEFINES += HAS_EIGEN2\n"
" INCLUDEPATH += /usr/local/include/eigen2\n"
"}\n";
return *this;
}
......@@ -4966,33 +4981,50 @@ GdbEngine
// + Check("ptr2.type KRBase::TYPE_B (1) KRBase::Type");
#if 0
#ifndef Q_OS_WIN
QTest::newRow("Eigen")
<< Data("#include <Eigen/Core>",
"using namespace Eigen;\n"
"Vector3d test = Vector3d::Zero();\n"
"Matrix3d myMatrix = Matrix3d::Constant(5);\n"
"MatrixXd myDynamicMatrix(30, 10);\n"
"myDynamicMatrix(0, 0) = 0;\n"
"myDynamicMatrix(1, 0) = 1;\n"
"myDynamicMatrix(2, 0) = 2;\n"
"Matrix<double, 12, 15, ColMajor> colMajorMatrix;\n"
"Matrix<double, 12, 15, RowMajor> rowMajorMatrix;\n"
"int k = 0;\n"
"for (int i = 0; i != 12; ++i) {\n"
" for (int j = 0; j != 15; ++j) {\n"
" colMajorMatrix(i, j) = k;\n"
" rowMajorMatrix(i, j) = k;\n"
" ++k;\n"
" }\n"
"}\n")
"Vector3d zero = Vector3d::Zero();\n"
"Matrix3d constant = Matrix3d::Constant(5);\n"
"MatrixXd dynamicMatrix(5, 2);\n"
"dynamicMatrix << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;\n"
"Matrix<double, 2, 5, ColMajor> colMajorMatrix;\n"
"colMajorMatrix << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;\n"
"Matrix<double, 2, 5, RowMajor> rowMajorMatrix;\n"
"rowMajorMatrix << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;\n"
"VectorXd vector(3);\n"
"vector << 1, 2, 3;\n")
+ EigenProfile()
+ CheckType("myMatrix", "Eigen::Matrix3d");
#endif
+ Check("colMajorMatrix", "(2 x 5), ColumnMajor",
"Eigen::Matrix<double, 2, 5, 0, 2, 5>")
+ Check("colMajorMatrix.[1,0]", "6", "double")
+ Check("colMajorMatrix.[1,1]", "7", "double")
+ Check("rowMajorMatrix", "(2 x 5), RowMajor",
"Eigen::Matrix<double, 2, 5, 1, 2, 5>")
+ Check("rowMajorMatrix.[1,0]", "6", "double")
+ Check("rowMajorMatrix.[1,1]", "7", "double")
+ Check("dynamicMatrix", "(5 x 2), ColumnMajor", "Eigen::MatrixXd")
+ Check("dynamicMatrix.[2,0]", "5", "double")
+ Check("dynamicMatrix.[2,1]", "6", "double")
+ Check("constant", "(3 x 3), ColumnMajor", "Eigen::Matrix3d")
+ Check("constant.[0,0]", "5", "double")
+ Check("zero", "(3 x 1), ColumnMajor", "Eigen::Vector3d")
+ Check("zero.1", "[1]", "0", "double")
+ Check("vector", "(3 x 1), ColumnMajor", "Eigen::VectorXd")
+ Check("vector.1", "[1]", "2", "double");
#endif
// https://bugreports.qt-project.org/browse/QTCREATORBUG-3611
QTest::newRow("Bug3611")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment