From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16759 invoked by alias); 10 Oct 2012 22:48:26 -0000 Received: (qmail 16749 invoked by uid 22791); 10 Oct 2012 22:48:24 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,LOTS_OF_MONEY,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Oct 2012 22:48:18 +0000 Received: by mail-wg0-f43.google.com with SMTP id dq11so762117wgb.12 for ; Wed, 10 Oct 2012 15:48:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.200.150 with SMTP id z22mr3827004wen.97.1349909297254; Wed, 10 Oct 2012 15:48:17 -0700 (PDT) Received: by 10.216.109.201 with HTTP; Wed, 10 Oct 2012 15:48:17 -0700 (PDT) In-Reply-To: <87y5jfr1ri.fsf@gmail.com> References: <87y5jfr1ri.fsf@gmail.com> Date: Wed, 10 Oct 2012 22:48:00 -0000 Message-ID: Subject: Re: Extending GDB: Python: Wrong handling of 64-bit pointers From: Andrew Pinski To: chandan r Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00053.txt.bz2 On Tue, Oct 9, 2012 at 10:30 AM, chandan r wrote: > Hi all, > > As the following CLI interactions show, GDB's python support code seems to be > mishandling 64-bit pointers (GNU/Linux on x86-64): > > NOTE: "p" is a pointer of type "struct task_struct *" > > (gdb) python print gdb.parse_and_eval("p") > 0xffff88001f5f7600 > (gdb) python print long(gdb.parse_and_eval("p")) > -131940868983296 > (gdb) show version > show version > GNU gdb (GDB) 7.5 > Copyright (C) 2012 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "x86_64-unknown-linux-gnu". > For bug reporting instructions, please see: > . > > Is it GDB or am I messing up something here? Nothing looks wrong as -131940868983296 is the same as 0xffff88001f5f7600 in signed integer. (gdb) p/x -131940868983296 $1 = 0xffff88001f5f7600 Thanks, Andrew Pinski > > -- > Chandan