I'm trying to debug with GDB using conditional breakpoints on an Eigen object. For instance, I'd like to break when any values in my vector are nonzero. I would do this in GDB:
break cpp/File.cpp:143 if (v != 0).any()
However, this doesn't work. GDB gives this:
Could not find operator!=
even though this is perfectly valid syntax. Moreover, a conditional breakpoint like
break cpp/File.cpp:143 if v[0] != 0
gives this error in 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.
The code was compiled with -O0 -g -fno-inline
. How do I debug the contents of an Eigen object?
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.