Debugging C++11 rvalue references with gdb

倖福魔咒の 提交于 2019-12-10 01:57:20

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/33586045/debugging-c11-rvalue-references-with-gdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!