Debugging C++11 rvalue references with gdb
I just noticed that I can not debug rvalue references with gdb-7.7.1
properly.
void simple(int &&i) {}
When I enter this minimalistic function I can not obtain any meaningful information about i
. It's type and value are unknown to gdb
.
simple(int&&) (i=<unknown type in /tmp/test, CU 0x0, DIE 0xcd78>) at test.cpp:10
(gdb) p i
$2 = <unknown type in /tmp/test, CU 0x0, DIE 0xcd78>
Am I doing something wrong? Are there any sensible workarounds? Will upgrading to gdb-7.10
solve this issue?
Unfortunatelly this is caused by a GDB Bug : 14441 - Need to support DW_TAG_rvalue_reference_type
This was fixed in GDB 8.0 .
Reference: https://sourceware.org/bugzilla/show_bug.cgi?id=14441
Workaround
Until it is fixed the value of i
in the above example can be obtained by explicit casting like that:
(gdb) p *(int*)i
$3 = 69
链接地址: http://www.djcxy.com/p/88812.html
上一篇: 有什么方法可以在Go中使用MySQL Temp Tables?
下一篇: 使用gdb调试C ++ 11右值引用