This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python] Pretty-printers and addressprint

On Mon, Nov 9, 2009 at 11:25 PM, Elmenthaler, Jens
<> 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/",
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. didn't appear to
have reached a satisfactory conclusion.

Paul Pluzhnikov

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]