public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: chandan r <chandanrmail@gmail.com>
To: "Andrew Pinski" <pinskia@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: Extending GDB: Python: Wrong handling of 64-bit pointers
Date: Fri, 12 Oct 2012 02:07:00 -0000	[thread overview]
Message-ID: <87mwzs8m30.fsf@gmail.com> (raw)
In-Reply-To: <CA+=Sn1kWinnaPa7rkXagzq1FAyB8Dj31RsYbSFtRtaaegWQ5Hw@mail.gmail.com>


Andrew Pinski <pinskia@gmail.com> writes:

> On Tue, Oct 9, 2012 at 10:30 AM, chandan r <chandanrmail@gmail.com> 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 <http://gnu.org/licenses/gpl.html>
>> 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:
>> <http://www.gnu.org/software/gdb/bugs/>.
>>
>> 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

But shouldn't pointer values be read/printed without interpretting the sign
bit?.

Right now I have to do 'long(str(gdb.parse_and_eval('p')), 16)' to obtain the
correct value.

--
chandan

  reply	other threads:[~2012-10-12  2:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 17:15 chandan r
2012-10-10 22:48 ` Andrew Pinski
2012-10-12  2:07   ` chandan r [this message]
2012-10-12  5:52     ` Bjoern Doebel
2012-10-12  5:59     ` Andrew Pinski
2012-10-12 13:08       ` chandan r

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwzs8m30.fsf@gmail.com \
    --to=chandanrmail@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).