【问题标题】:GDB Eigen Debugging with Conditional Breakpoints Failing条件断点失败的 GDB Eigen 调试
【发布时间】:2019-05-31 19:37:18
【问题描述】:

我正在尝试使用 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 编译的。如何调试 Eigen 对象的内容?

【问题讨论】:

  • 谢谢。我正在使用 Eigen 源进行编译,而不是使用库。
  • @JesperJuhl 只是为了澄清:Eigen 仅是标题,即不单独编译。 Eric:你能提供一个minimal reproducible example吗?

标签: c++ gdb eigen


【解决方案1】:

根据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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多