On Mon, Mar 9, 2015 at 10:43 PM, Jan Kratochvil
wrote:
> Hi,
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65366
>
> GDB Python support upstream has always been compatible with Python3.
> Fedora since F-22 builds GDB with Python3 by default (<=F-21 GDB used
> Python2).
>
> gdbhooks.py in GCC trunk is compatible with Python2 but not Python3.
>
> gdb-7.9-10.fc23.x86_64
> (gdb) source /home/jkratoch/redhat/gcchead/gcc/c/../gdbhooks.py
> File "/home/jkratoch/redhat/gcchead/gcc/c/../gdbhooks.py", line 372
> print format_[i]
> ^
> SyntaxError: Missing parentheses in call to 'print'
>
> Additionally after fixing the 'print' incompatibility one gets randomly:
>
> dependence_info = {clique = 257, Python Exception name
> 'long' is not defined:
> base = 1}}}, type = },
>
> OK for check-in?
>
> The long()->int() change I have followed from:
>
> https://stackoverflow.com/questions/14904814/nameerror-global-name-long-is-not-defined/14904834
I think this change causes
(gdb) p *$2
$3 = {type = undef_vec_info_type, live = false, Python Exception
Cannot convert value to int.:
in_pattern_p = false, stmt = ,
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
loop_vinfo = 0x2272e70, vectype = , vectorized_stmt = ,
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
data_ref_info = 0x226bdd0, dr_base_address = , dr_init = , dr_offset = ,
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
Python Exception Cannot convert value to int.:
...
and makes the pretty-printers compeltely unusable for me.
gdb 7.9, python 2.7.6
Richard.
>
> Thanks,
> Jan
>
> 2015-03-09 Jan Kratochvil
>
> PR other/65366
> * gdbhooks.py: Use int(...) instead of long(...). Use print(...)
> instead of print ... .
>
> Index: gcc/gdbhooks.py
> ===
> --- gcc/gdbhooks.py (revision 221277)
> +++ gcc/gdbhooks.py (working copy)
> @@ -158,7 +158,7 @@ class Tree:
> self.gdbval = gdbval
>
> def is_nonnull(self):
> -return long(self.gdbval)
> +return int(self.gdbval)
>
> def TREE_CODE(self):
> """
> @@ -197,7 +197,7 @@ class TreePrinter:
> # like gcc/print-tree.c:print_node_brief
> # #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
> # tree_code_name[(int) TREE_CODE (node)])
> -if long(self.gdbval) == 0:
> +if int(self.gdbval) == 0:
> return ''
>
> val_TREE_CODE = self.node.TREE_CODE()
> @@ -209,17 +209,17 @@ class TreePrinter:
> val_tclass = val_tree_code_type[val_TREE_CODE]
>
> val_tree_code_name = gdb.parse_and_eval('tree_code_name')
> -val_code_name = val_tree_code_name[long(val_TREE_CODE)]
> -#print val_code_name.string()
> +val_code_name = val_tree_code_name[int(val_TREE_CODE)]
> +#print(val_code_name.string())
>
> -result = '<%s 0x%x' % (val_code_name.string(), long(self.gdbval))
> -if long(val_tclass) == tcc_declaration:
> +result = '<%s 0x%x' % (val_code_name.string(), int(self.gdbval))
> +if int(val_tclass) == tcc_declaration:
> tree_DECL_NAME = self.node.DECL_NAME()
> if tree_DECL_NAME.is_nonnull():
> result += ' %s' % tree_DECL_NAME.IDENTIFIER_POINTER()
> else:
> pass # TODO: labels etc
> -elif long(val_tclass) == tcc_type:
> +elif int(val_tclass) == tcc_type:
> tree_TYPE_NAME = Tree(self.gdbval['type_common']['name'])
> if tree_TYPE_NAME.is_nonnull():
> if tree_TYPE_NAME.TREE_CODE() == IDENTIFIER_NODE:
> @@ -242,8 +242,8 @@ class CGraphNodePrinter:
> self.gdbval = gdbval
>
> def to_string (self):
> -result = ' -if long(self.gdbval):
> +result = ' +if int(self.gdbval):
> # symtab_node::name calls lang_hooks.decl_printable_name
> # default implementation (lhd_decl_printable_name) is:
> #return IDENTIFIER_POINTER (DECL_NAME (decl));
> @@ -261,12 +261,12 @@ class DWDieRefPrinter:
> self.gdbval = gdbval
>
> def to_string (self):
> -if long(self.gdbval) == 0:
> +if int(self.gdbval) == 0:
> return ''
> -result = ' +result = ' result += ' %s' % self.gdbval['die_tag']
> -if long(self.gdbval['die_parent']) != 0:
> -result += ' ' % (long(self.gdbval['die_parent']),
> +if int(self.gdbval['die_parent']) != 0:
> +result += ' ' % (int(self.gdbval['die_parent']),
>
> self.gdbval['die_parent']['die_tag'])
>
> result += '>'
>