Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see a value of boost::any if I know the type with gdb

I have a core dump and I am looking at the core dump with gdb.

I was wondering if there is a way to be able to examine the value of a boost::any value in gdb?

In the core, I had the address to the boost any and so I tried casting it to a placeholder to see if I could examine the value, but I fell short. I know that the type of the boost any is unsigned long so is there a way to view the any value knowing the type?

(gdb) print ('boost::any::placeholder')(*(('boost::any'*)0x00007f263fa27730).content)
warning: can't find linker symbol for virtual table for `boost::any::placeholder' value
warning:   found `boost::any::holder<bool>::~holder()' instead
$129 = warning: can't find linker symbol for virtual table for `boost::any::placeholder' value
warning:   found `boost::any::holder<bool>::~holder()' instead
warning: can't find linker symbol for virtual table for `boost::any::placeholder' value
warning:   found `boost::any::holder<bool>::~holder()' instead
{
  _vptr.placeholder = 0x7f2a9a662560
}

Any help with this matter would be much appreciated. Thanks!

like image 255
bbazso Avatar asked Dec 14 '12 20:12

bbazso


1 Answers

boost::any has an internal class placeholder which holds the data content. Try using:

(gdb) print (*((boost::any::holder<unsigned long>*)((anyInstance).content))).held
like image 103
eladidan Avatar answered Nov 17 '22 19:11

eladidan