Is there some \"default function\" to print an object like a string on the GDB when we are debugging C++ applications? Something like: toString();
Or my class have t
You can call any member functions from Standard Library or your own data type during debug session. This is sometimes the easiest way to output object state in gdb. For std::string
you could call it's c_str()
member which returns const char*
:
(gdb) p str.c_str()
$1 = "Hello, World!"
Though this will work only for debugging live process, but not for core dump debugging.