From patchwork Mon Mar 9 21:43:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 448252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AA0661400D5 for ; Tue, 10 Mar 2015 08:43:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=C7KIhIR5; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=v0yy/GPhCTybqaSOfwpAAlvaWAXh0xovYwoWuU/U4je53wNbBO GUCUnhk/KWPbDCwHcaKYwnYp/4jixiB4cYuC1AJZL0lRq1ox58Rx8hwq3+9+AWkF DbZ6fmoPSHxLXcpWmYfb+WvUibyzB9R0458xjszwL3gK7MsRaAi7DGOrA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=xitVGDPTQzTYGO4IZapirDQx5VE=; b=C7KIhIR5gu3KedAfNJou usQYTBMqoIx4ORIKT0bvorqPYb85ywhwbm/iwiD8Kk2W3YFXCwJzGz2uzTTycfLZ 1fPHAPeqtBI6TEREGp/oaGZyHNOYojYuHtWCdGUNa8YHxT/END8wDzrtrDuxfax6 E2/OQtjsFh486oMX5+ZgbQ8= Received: (qmail 2164 invoked by alias); 9 Mar 2015 21:43:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2150 invoked by uid 89); 9 Mar 2015 21:43:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 09 Mar 2015 21:43:20 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t29LhIo0016714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 9 Mar 2015 17:43:19 -0400 Received: from host1.jankratochvil.net ([10.40.204.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t29LhEr5015797 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 9 Mar 2015 17:43:17 -0400 Date: Mon, 9 Mar 2015 22:43:14 +0100 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: Phil Muldoon Subject: [patch] PR other/65366: Fix gdbhooks.py for GDB with Python3 Message-ID: <20150309214314.GA2650@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes 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 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 = '' - 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[long(val_gimple_code)] + val_code_name = val_gimple_code_name[int(val_gimple_code)] result = '<%s 0x%x' % (val_code_name.string(), - long(self.gdbval)) + int(self.gdbval)) result += '>' return result @@ -306,9 +306,9 @@ class BasicBlockPrinter: self.gdbval = gdbval def to_string (self): - result = '