我正在尝试使用Eigen对象上的条件断点使用GDB进行调试。例如,当向量中的任何值都不为零时,我想中断。我会在GDB中这样做:
break cpp/File.cpp:143 if (v != 0).any()
但是,这不起作用。 GDB给出了这一点:
Could not find operator!=
即使这是完全有效的语法。而且,条件断点如
break cpp/File.cpp:143 if v[0] != 0
在GDB中出现此错误:
Error in testing breakpoint condition:
Couldn't get registers: No such process.
An error occurred while in a function called from GDB.
Evaluation of the expression containing the function
(Eigen::DenseCoeffsBase<Eigen::Array<int, 3, 1, 0, 3, 1>, 1>::operator[](long)) will be abandoned.
When the function is done executing, GDB will silently stop.
该代码是使用-O0 -g -fno-inline
编译的。如何调试本征对象的内容?
答案 0 :(得分:0)
According to this question, (sometimes) GDB seems to have problems with overloaded operators. You could try one of these alternatives:
if (! v.isZero())
if (! v.cwiseEqual(0).all())
And instead of if v[0] != 0
you could try one of these:
if (v.data()[0] != 0)
if (v.coeff(0) != 0)