This is the mail archive of the
mailing list for the Archer project.
[python] Pretty-printers and addressprint
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: gdb at sourceware dot org, archer at sourceware dot org
- Cc: dje at google dot com, ppluzhnikov at google dot com
- Date: Mon, 9 Nov 2009 18:11:58 -0800 (PST)
- Subject: [python] Pretty-printers and addressprint
Consider the gdb.python/py-prettyprint.exp test case.
typedef struct string_repr
const char *contents;
and a prettyprinter for it:
# Test returning a Value from a printer.
def __init__(self, val):
self.val = val
Which currently produces:
$4 = 0x4007e0 "this is x"^M
The issue I am having is there is no apparent way to get rid of the
address from python side (address is not printed when the printer
returns a python string instead of a value), whereas if the
printer really wants to print the address, it can trivally add
it back by returning appropriate python string.
Printing addresses inside of a container seems to be especially
Should the decision to print addresses be deferred to the
pretty-printer? Is the patch below reasonable?
2009-11-09 Paul Pluzhnikov <firstname.lastname@example.org>
* gdb/python/py-prettyprint.c (print_string_repr): Don't
print value address.
--- gdb/python/py-prettyprint.c#1 2009-11-09 17:58:39.000000000 -0800
+++ gdb/python/py-prettyprint.c 2009-11-09 16:51:16.862840000 -0800
@@ -209,7 +209,12 @@ print_string_repr (PyObject *printer, co
else if (replacement)
- common_val_print (replacement, stream, recurse, options, language);
+ struct value_print_options opts = *options;
+ opts.addressprint = 0;
+ common_val_print (replacement, stream, recurse, &opts, language);