Hi guys,
since version 7.0 of the gnu debugger it is possible to write pretty-printers.
They are useful to avoid a string to look like this:
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x804a014 "foo-string"}}
but instead make it look like this:
foo-string
I'm currently following the example shown in the gdb documentation which you can find over here:
http://sourceware.org/gdb/onlinedocs/gdb.pdf.gz
I have two problems with the example shown on page 303 (section 23.2.2.6 Selecting Pretty-Printers)
1: I think the to_string methods is missing a string() call. The return should look like this to output anything useful:
return self.val[’_M_dataplus’][’_M_p’].string()
2: The regex "regex = re.compile("^std::basic_string<char,.*>$")" does not seem to match when trying to output a std::string and I have no idea why...
Did anybody already solve the problem to write a pretty-printer and has a demo project for me that I can try run?
Any other hints?
Thanks in advance and have a nice weekend.