From 74103219e877e4b972e9ed178448fdee6dd223a6 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 8 Jun 2015 13:35:51 +0000 Subject: [PATCH] re PR other/65366 (gdbhooks.py is incompatible with Python3) PR other/65366 * gdbhooks.py: Import sys. (intptr): New function. Replace int(...) by intptr(...). From-SVN: r224223 --- gcc/ChangeLog | 6 +++++ gcc/gdbhooks.py | 67 +++++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b84e325c716..664dc37a5e8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-06-08 Jan Kratochvil + + PR other/65366 + * gdbhooks.py: Import sys. + (intptr): New function. Replace int(...) by intptr(...). + 2015-06-08 Richard Biener * tree-vect-stmts.c (vectorizable_load): Compute the pointer diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 20842bbc940..3a62a2d8acb 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -132,6 +132,7 @@ Instead (for now) you must access m_vecdata: """ import os.path import re +import sys import gdb import gdb.printing @@ -149,6 +150,12 @@ tree_code_class_dict = gdb.types.make_enum_dict(gdb.lookup_type('enum tree_code_ tcc_type = tree_code_class_dict['tcc_type'] tcc_declaration = tree_code_class_dict['tcc_declaration'] +# Python3 has int() with arbitrary precision (bignum). Python2 int() is 32-bit +# on 32-bit hosts but remote targets may have 64-bit pointers there; Python2 +# long() is always 64-bit but Python3 no longer has anything named long. +def intptr(gdbval): + return long(gdbval) if sys.version_info.major == 2 else int(gdbval) + class Tree: """ Wrapper around a gdb.Value for a tree, with various methods @@ -158,7 +165,7 @@ class Tree: self.gdbval = gdbval def is_nonnull(self): - return int(self.gdbval) + return intptr(self.gdbval) def TREE_CODE(self): """ @@ -197,7 +204,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 int(self.gdbval) == 0: + if intptr(self.gdbval) == 0: return '' val_TREE_CODE = self.node.TREE_CODE() @@ -209,17 +216,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[int(val_TREE_CODE)] + val_code_name = val_tree_code_name[intptr(val_TREE_CODE)] #print(val_code_name.string()) - result = '<%s 0x%x' % (val_code_name.string(), int(self.gdbval)) - if int(val_tclass) == tcc_declaration: + result = '<%s 0x%x' % (val_code_name.string(), intptr(self.gdbval)) + if intptr(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 int(val_tclass) == tcc_type: + elif intptr(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 +249,8 @@ class CGraphNodePrinter: self.gdbval = gdbval def to_string (self): - result = '' - result = '' val_gimple_code = self.gdbval['code'] val_gimple_code_name = gdb.parse_and_eval('gimple_code_name') - val_code_name = val_gimple_code_name[int(val_gimple_code)] + val_code_name = val_gimple_code_name[intptr(val_gimple_code)] result = '<%s 0x%x' % (val_code_name.string(), - int(self.gdbval)) + intptr(self.gdbval)) result += '>' return result @@ -306,9 +313,9 @@ class BasicBlockPrinter: self.gdbval = gdbval def to_string (self): - result = '