[python] Pretty-printers and addressprint
Paul Pluzhnikov
ppluzhnikov@google.com
Tue Nov 10 10:22:00 GMT 2009
On Mon, Nov 9, 2009 at 11:25 PM, Elmenthaler, Jens
<jens.elmenthaler@verigy.com> wrote:
> The gdb.Value class has a string() method, you could try this in your to_string method:
> return self.val['whybother']['contents'].string()
That doesn't quite do what I want, but this almost does:
return '"' + self.val['whybother']['contents'].string() + '"'
However, consider a modification of the original test:
- string x = make_string ("this is x");
+ string x = make_string ("this is x\201\202\203\204");
With the original pretty-printer, this produces:
$4 = 0x4007e0 "this is x\201\202\203\204"
which is exactly what I want, if only it didn't have the address. With
proposed patch, it produces exactly what I want:
$4 = "this is x\201\202\203\204"
But this value can't be converted to a python string in ASCII charset:
the modified printer produces this:
$4 = Traceback (most recent call last):
File "../../../src/gdb/testsuite/gdb.python/py-prettyprint.py",
line 27, in to_string
return self.val['whybother']['contents'].string()
UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position
9: ordinal not in range(128)
Unfortunately I frequently deal with non-ascii strings, and the
problem just wouldn't go away :-(
Previous threads on this subject, e.g.
http://sourceware.org/ml/archer/2008-q4/msg00180.html didn't appear to
have reached a satisfactory conclusion.
Thanks,
--
Paul Pluzhnikov
More information about the Gdb
mailing list