From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: [PATCH] Minor fixes to .gdbinit Date: Sat, 10 Feb 2018 09:51:54 -0700 Message-ID: <20180210165154.22393-1-tom@tromey.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1518281427 32660 195.159.176.226 (10 Feb 2018 16:50:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Feb 2018 16:50:27 +0000 (UTC) Cc: Tom Tromey To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 10 17:50:22 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekYLu-0007aF-9n for ged-emacs-devel@m.gmane.org; Sat, 10 Feb 2018 17:50:14 +0100 Original-Received: from localhost ([::1]:35719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekYNt-0005sL-Tg for ged-emacs-devel@m.gmane.org; Sat, 10 Feb 2018 11:52:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekYNe-0005rB-0n for emacs-devel@gnu.org; Sat, 10 Feb 2018 11:52:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekYNb-0002Yf-1g for emacs-devel@gnu.org; Sat, 10 Feb 2018 11:52:02 -0500 Original-Received: from gateway23.websitewelcome.com ([192.185.48.71]:22167) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekYNa-0002Xf-OZ for emacs-devel@gnu.org; Sat, 10 Feb 2018 11:51:58 -0500 Original-Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 6670F4F67 for ; Sat, 10 Feb 2018 10:51:57 -0600 (CST) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id kYNZe8PdqcGlpkYNZe7nJo; Sat, 10 Feb 2018 10:51:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=heT+BC3/Ec0Jxr1zC8k2dwc8kGoRpbHcraXsYKVHUFc=; b=Th6epOOnCjqzjPrwn14xj2AHg2 QL/fjYzOP1P43tNJi+J4AqzdTVXd+qxJ7CLrs1nYr6PdtjQR9y1/yWi2r5vbAnKrdE2Zt+Lx9Xz7v hOIfOkIAUHeTOituu+MEzC7+m; Original-Received: from 174-29-33-254.hlrn.qwest.net ([174.29.33.254]:36612 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ekYNZ-000vwx-3w; Sat, 10 Feb 2018 10:51:57 -0600 X-Mailer: git-send-email 2.13.6 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.29.33.254 X-Source-L: No X-Exim-ID: 1ekYNZ-000vwx-3w X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-29-33-254.hlrn.qwest.net (bapiya.Home) [174.29.33.254]:36612 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.48.71 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222650 Archived-At: I noticed a couple of small problems in .gdbinit while debugging Emacs recently. First, "xcompiled" doesn't emit a trailing newline. Second, in some cases, when gdb uses Python 2, casting a pointer to a Python 'int' will fail. The solution is to cast to 'long' instead -- but because Python 3 does not have 'long', this requires a small compatibility shim. This patch fixes both of these problems. Let me know what you think. * src/.gdbinit (xcompiled): Emit a final newline. (python): Define "long" if not already defined. Use casts to long, not int. --- src/.gdbinit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/.gdbinit b/src/.gdbinit index a5411e66d5..9fdcaf8661 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -819,6 +819,7 @@ define xcompiled xgetptr $ print (struct Lisp_Vector *) $ptr output ($->contents[0])@($->header.size & 0xff) + echo \n end document xcompiled Print $ as a compiled function pointer. @@ -1270,6 +1271,12 @@ end python +# Python 3 compatibility. +try: + long +except: + long = int + # Omit pretty-printing in older (pre-7.3) GDBs that lack it. if hasattr(gdb, 'printing'): @@ -1306,13 +1313,13 @@ if hasattr(gdb, 'printing'): # symbol table, guess reasonable defaults. sym = gdb.lookup_symbol ("EMACS_INT_WIDTH")[0] if sym: - EMACS_INT_WIDTH = int (sym.value ()) + EMACS_INT_WIDTH = long (sym.value ()) else: sym = gdb.lookup_symbol ("EMACS_INT")[0] EMACS_INT_WIDTH = 8 * sym.type.sizeof sym = gdb.lookup_symbol ("USE_LSB_TAG")[0] if sym: - USE_LSB_TAG = int (sym.value ()) + USE_LSB_TAG = long (sym.value ()) else: USE_LSB_TAG = 1 @@ -1334,7 +1341,7 @@ if hasattr(gdb, 'printing'): # integer. Also, val.cast (gdb.lookup.type ("EMACS_UINT")) # would have problems with GDB 7.12.1; see # . - ival = int (val) + ival = long (val) # For nil, yield "XIL(0)", which is easier to read than "XIL(0x0)". if not ival: -- 2.13.6