Discussion:
[Bug python/18280] New: pointer values returned from pretty-printers are not printed
xdje42 at gmail dot com
2015-04-18 20:08:40 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18280

Bug ID: 18280
Summary: pointer values returned from pretty-printers are not
printed
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: xdje42 at gmail dot com

From #gdb:
https://gist.github.com/TheWug/16b47181a7907b7a7539

The pretty-printer is returning an int * value but gdb isn't printing it.

The problem seems to be in c_val_print, case TYPE_CODE_PTR
and print_address_demangle.

If we end up here:

int
print_address_demangle (const struct value_print_options *opts,
struct gdbarch *gdbarch, CORE_ADDR addr,
struct ui_file *stream, int do_demangle)
{
if (opts->addressprint)
{
fputs_filtered (paddress (gdbarch, addr), stream);
print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
}
else
{
=> return print_address_symbolic (gdbarch, addr, stream, do_demangle, "");
}
return 1;
}

nothing gets printed.
--
You are receiving this mail because:
You are on the CC list for the bug.
xdje42 at gmail dot com
2015-04-19 16:53:47 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18280

--- Comment #1 from Doug Evans <xdje42 at gmail dot com> ---
For reference sake, here's the testcase:

struct Test
{
Test() { j = 10; i = &j; }
int *i;
int j;
};

int main()
{
Test x;
++*x.i;
return 0;
}

Here's the pretty-printer:

class TestPrinter(object):
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['i']
def test_printer_hook(val):
return TestPrinter(val) if val.type.tag == 'Test' else None
for obj in gdb.objfiles():
obj.pretty_printers.append(test_printer_hook)

# (registration of the pretty-printer is overkill, but no matter)

And here's a sample session:

bash$ gdb a.out # Put pretty-printer in a.out-gdb.py
(gdb) start
(gdb) n
(gdb) n
(gdb) p x
$1 =
(gdb) p x.i
$2 = (int *) 0x7fffffffe198
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-14 23:25:50 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18280

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Regression from this thread:
https://sourceware.org/ml/gdb/2009-11/msg00105.html
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-14 23:54:27 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18280

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
This behavior seems intentional, so one good step would be to document it.

See also bug 12918. Pretty-printers have to be able to control a bit
more of gdb's built-in behavior.

Perhaps printers could wrap results in some kind of print-control object.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-14 23:55:45 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=18280

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Oops, I meant bug 10662 there.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...