public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] gdb python pretty printer for DIEs
@ 2014-12-09 21:11 Aldy Hernandez
  2014-12-09 23:04 ` Jeff Law
  2014-12-10 14:26 ` David Malcolm
  0 siblings, 2 replies; 4+ messages in thread
From: Aldy Hernandez @ 2014-12-09 21:11 UTC (permalink / raw)
  To: jason merrill; +Cc: David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

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?

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1804 bytes --]

commit e20f40f92eeba51f9a1ffb078e060366e7beb471
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Dec 9 13:04:46 2014 -0800

    	* gdbhooks.py (class DWDieRefPrinter): New class.
    	(build_pretty_printer): Register dw_die_ref's.

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index a74e712..26affd9 100644
--- 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)
+        if long(self.gdbval) == 0:
+            return '<dw_die_ref 0x0>'
+        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
+
+######################################################################
 
 class GimplePrinter:
     def __init__(self, gdbval):
@@ -455,6 +475,8 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
+    pp.add_printer_for_types(['dw_die_ref'],
+                             'dw_die_ref', DWDieRefPrinter)
     pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
 
                               # Keep this in the same order as gimple.def:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] gdb python pretty printer for DIEs
  2014-12-09 21:11 [patch] gdb python pretty printer for DIEs Aldy Hernandez
@ 2014-12-09 23:04 ` Jeff Law
  2014-12-10 14:26 ` David Malcolm
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2014-12-09 23:04 UTC (permalink / raw)
  To: Aldy Hernandez, jason merrill; +Cc: David Malcolm, gcc-patches

On 12/09/14 14:10, Aldy Hernandez wrote:
> 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?
OK.

BTW, you might want to familiarize yourself with Petr's dwgrep as 
another tool for poking at things.


Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] gdb python pretty printer for DIEs
  2014-12-09 21:11 [patch] gdb python pretty printer for DIEs Aldy Hernandez
  2014-12-09 23:04 ` Jeff Law
@ 2014-12-10 14:26 ` David Malcolm
  2014-12-10 23:29   ` Aldy Hernandez
  1 sibling, 1 reply; 4+ messages in thread
From: David Malcolm @ 2014-12-10 14:26 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: jason merrill, gcc-patches

On Tue, 2014-12-09 at 13:10 -0800, Aldy Hernandez wrote:
>                              From: 
> Aldy Hernandez <aldyh@redhat.com>
>                                To: 
> jason merrill <jason@redhat.com>
>                                Cc: 
> David Malcolm
> <dmalcolm@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] gdb python pretty printer for DIEs
  2014-12-10 14:26 ` David Malcolm
@ 2014-12-10 23:29   ` Aldy Hernandez
  0 siblings, 0 replies; 4+ messages in thread
From: Aldy Hernandez @ 2014-12-10 23:29 UTC (permalink / raw)
  To: David Malcolm; +Cc: jason merrill, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]

On 12/10/14 06:21, David Malcolm wrote:
> On Tue, 2014-12-09 at 13:10 -0800, Aldy Hernandez wrote:
>>                               From:
>> Aldy Hernandez <aldyh@redhat.com>
>>                                 To:
>> jason merrill <jason@redhat.com>
>>                                 Cc:
>> David Malcolm
>> <dmalcolm@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...

Thanks.  Tom also pointed the same thing.  Ooops.

I'm committing the attached patch.

Aldy


[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1804 bytes --]

commit d3f07cb1cbae79b10dc01affb863302e3f5e444d
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Dec 9 13:04:46 2014 -0800

    	* gdbhooks.py (class DWDieRefPrinter): New class.
    	(build_pretty_printer): Register dw_die_ref's.

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index a74e712..6d9e41e 100644
--- 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):
+        if long(self.gdbval) == 0:
+            return '<dw_die_ref 0x0>'
+        result = '<dw_die_ref 0x%x' % long(self.gdbval)
+        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
+
+######################################################################
 
 class GimplePrinter:
     def __init__(self, gdbval):
@@ -455,6 +475,8 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
+    pp.add_printer_for_types(['dw_die_ref'],
+                             'dw_die_ref', DWDieRefPrinter)
     pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
 
                               # Keep this in the same order as gimple.def:

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-10 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-09 21:11 [patch] gdb python pretty printer for DIEs Aldy Hernandez
2014-12-09 23:04 ` Jeff Law
2014-12-10 14:26 ` David Malcolm
2014-12-10 23:29   ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).