pretty printing of smart pointers and making function calls
Vladimir
volo.zyko@gmail.com
Wed Jan 25 13:20:00 GMT 2012
Hi All,
I have a couple of question related to Python pretty printers. I tried to search
for the answer on the web but had no luck.
1. For example, I want to implement a pretty printer for variable a of type
std::auto_ptr<std::string>. It's rather straight forward so I will not add here
my implementation of such printer. Then I use it as follows:
(gdb) print a
$1 = std::auto_ptr<std::string> 0x804d030
Now I want to take a look at what is the value inside that pointer.
(gdb) print *a
Could not find operator*.
How can I implement a printer for the second case?
2) Another question is about how to call from pretty printer a function from my
currently debugged process. For example, I have an unsigned int variable which
contains a hash of a string and there is a function that can map the hash to the
original string. To make the unsigned int value a bit more descriptive I want to
call the function and print corresponding string. Actually I managed to make
such call but the result looks ugly:
def to_string(self):
crc = self.val
s = gdb.execute('call hash_to_string(%d)' % crc, to_string=True)
return ('crc = 0x%08X : \'%s\'' % (crc, s)))
(gdb) print crc
$1 = crc = 0x0024A837 : '$2 = "qerrrr"
'
Is there any way to obtain the result of the function call as gdb.Value?
More information about the Archer
mailing list