On Tue, 2014-12-09 at 13:10 -0800, Aldy Hernandez wrote: > From: > Aldy Hernandez <al...@redhat.com> > To: > jason merrill <ja...@redhat.com> > Cc: > David Malcolm > <dmalc...@redhat.com>, gcc-patches > <gcc-patches@gcc.gnu.org> > Subject: > [patch] gdb python pretty printer > for DIEs > Date: > Tue, 09 Dec 2014 13:10:57 -0800 > (12/09/2014 04:10:57 PM) > > > I am tired of dumping entire DIEs just to see what type they are. > With > this patch, we get: > > (gdb) print context_die > $5 = <dw_die_ref 0x7ffff6de0230 DW_TAG_module <parent=0x7ffff6de0000 > DW_TAG_compile_unit>> > > I know it's past the end of stage1, but this debugging aid can help > in > fixing bugs in stage >= 3. > > I am committing this to the [debug-early] branch, but I am hoping I > can > also commit it to mainline and avoid dragging it along. > > OK for mainline?
> --- a/gcc/gdbhooks.py > +++ b/gcc/gdbhooks.py > @@ -253,6 +253,26 @@ class CGraphNodePrinter: > return result > > ###################################################################### > +# Dwarf DIE pretty-printers > +###################################################################### > + > +class DWDieRefPrinter: > + def __init__(self, gdbval): > + self.gdbval = gdbval > + > + def to_string (self): > + result = '<dw_die_ref 0x%x' % long(self.gdbval) A minor nit: for the NULL case, you're doing slightly more work than necessary: you start building "result" above... > + if long(self.gdbval) == 0: > + return '<dw_die_ref 0x0>' ...then discard it at the return here. You could move the "result = ..." line to after the "if ... == 0" conditional. > + result += ' %s' % self.gdbval['die_tag'] > + if long(self.gdbval['die_parent']) != 0: > + result += ' <parent=0x%x %s>' % > (long(self.gdbval['die_parent']), > + > self.gdbval['die_parent']['die_tag']) > + > + result += '>' > + return result