7

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!

bbazso
  • 1,959
  • 6
  • 22
  • 30
  • 1
    Have you looked at the boost any source? A boost any contains a pointer to a holder, whose child type is templated on the held type, if I recall correctly. The boost any itself is not a dynamic type, it owns a dynamic type. – Yakk - Adam Nevraumont Dec 14 '12 at 20:51
  • 1
    I wonder if one could write a gdb pretty printer for `boost::any`. After all, you don't even have to know the type of the content, since the `vtable` pointer of the held type knows what the content type is. We need more gdb pretty printers! – enobayram Dec 15 '12 at 08:54

1 Answers1

1

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

(gdb) print (*((boost::any::holder<unsigned long>*)((anyInstance).content))).held
eladidan
  • 2,634
  • 2
  • 26
  • 39