[英]GDB - Accessing real and imaginary parts of a complex number
When debugging a program which uses (either C or C++), gdb
displays complex numbers as _M_value = xxx + yyy*I
(with a type of complex double
). 在调试使用(C或C ++)的程序时,
gdb
复数显示为_M_value = xxx + yyy*I
(具有complex double
的类型)。
While debugging, I need to print that number multiplied by a factor. 在调试时,我需要打印该数字乘以一个因子。
The following does not work: 以下不起作用 :
print a * 8.0
I get Argument to arithmetic operation not a number or boolean
. Argument to arithmetic operation not a number or boolean
。
Also, I cannot access the real and imaginary parts so that I can write a gdb macro to do the above. 此外,我无法访问实部和虚部,以便我可以编写一个gdb宏来执行上述操作。 My current solution is to write a C function for manipulating complex values and arrays, and calling that function from gdb.
我目前的解决方案是编写一个C函数来处理复杂的值和数组,并从gdb调用该函数。 Somehow, this just doesn't feel right.
不知何故,这感觉不对。
If you use the standard C++ complex template then complex::real() and complex::imaj() should work. 如果使用标准C ++复杂模板,那么complex :: real()和complex :: imaj()应该可以工作。
my2c MY2C
Note : Was a comment ^^ 注意:是评论^^
您可以调用C库函数creal()
和cimag()
来分解数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.