This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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]

[Bug python/18280] pointer values returned from pretty-printers are not printed


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.


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