Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 437
oo_miguel Avatar asked Nov 07 '15 18:11

oo_miguel


1 Answers

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
like image 150
oo_miguel Avatar answered Sep 28 '22 06:09

oo_miguel