On Wed, 2020-04-15 at 14:52 +0200, Richard Biener wrote:
> This adds the SSA name version to the gdb pretty-printing of SSA
> names.
> 
> (gdb) p (tree)$1
> $5 = <ssa_name 0x7ffff68435a0 323>
> 
> Tested (see above...).
> 
> OK?

> Thanks,
> Richard.
> 
> 2020-04-15  Richard Biener  <rguent...@suse.de>
> 
>       * gdbhooks.py (TreePrinter): Print SSA_NAME_VERSION of SSA_NAME
>       nodes.
> ---
>  gcc/gdbhooks.py | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
> index e9acc373126..f6aef9ceae8 100644
> --- a/gcc/gdbhooks.py
> +++ b/gcc/gdbhooks.py
> @@ -154,6 +154,7 @@ tree_code_dict =
> gdb.types.make_enum_dict(gdb.lookup_type('enum tree_code'))
>  # ...and look up specific values for use later:
>  IDENTIFIER_NODE = tree_code_dict['IDENTIFIER_NODE']
>  TYPE_DECL = tree_code_dict['TYPE_DECL']
> +SSA_NAME = tree_code_dict['SSA_NAME']
>  
>  # Similarly for "enum tree_code_class" (tree.h):
>  tree_code_class_dict =
> gdb.types.make_enum_dict(gdb.lookup_type('enum tree_code_class'))
> @@ -252,6 +253,8 @@ class TreePrinter:
>                          result += ' %s' %
> tree_TYPE_NAME.DECL_NAME().IDENTIFIER_POINTER()
>          if self.node.TREE_CODE() == IDENTIFIER_NODE:
>              result += ' %s' % self.node.IDENTIFIER_POINTER()
> +     if self.node.TREE_CODE() == SSA_NAME:
> +         result += ' %u' % self.gdbval['base']['u']['version']

Make it an "elif" rather than a plain "if" as the TREE_CODEs are
mutually exclusive (and the language doesn't have switch statements).

Is something up with the indentation?  The "if" ("elif") for SSA_NAME
should have the same indentation as the "if" for IDENTIFIER_NODE.  Is
there a stray tab or similar?

Otherwise, LGTM.


>          # etc
>          result += '>'
>          return result

Reply via email to