c++ - 条件断点失败的 GDB Eigen 调试

标签 c++ gdb eigen

我正在尝试使用 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/

相关文章:

c++ - 使用多线程服务器进行结构化异常处理

visual studio 2012中委派构造函数的C++11新特性

c - gdb错误: not in executable format: file not recognized

c++ - 特征矩阵切片和数据()

c++ - 使用 Eigen 时的奇怪行为

c++ - 分割 std::vector of 2D points

c++ - 断点陷阱是否总是意味着程序是从调试器运行的?

c++ - 在 Debug模式下运行的 CGI 程序

c - 确定传递给函数的参数

c++ - Eigen::vector ;在函数中使用 Eigen::Matrix3f 的值初始化 vector ,大于 4 个条目