我正在尝试使用 Eigen 对象上的条件断点使用 GDB 进行调试。例如,我想在 vector 中的任何值不为零时中断。我会在 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
编译的。如何调试 Eigen 对象的内容?
最佳答案
根据 this question ,(有时)GDB 似乎有重载运算符的问题。您可以尝试以下替代方案之一:
if (! v.isZero())
if (! v.cwiseEqual(0).all())
而不是 if v[0] != 0
你可以尝试以下之一:
if (v.data()[0] != 0)
if (v.coeff(0) != 0)
关于c++ - 条件断点失败的 GDB Eigen 调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56364205/