From: Chris Johns <chris@contemporary.net.au>
To: tromey@redhat.com
Cc: gdb@sourceware.org
Subject: Re: Python Pretty printing a struct
Date: Sun, 14 Mar 2010 23:40:00 -0000 [thread overview]
Message-ID: <4B9D73C2.9090307@contemporary.net.au> (raw)
In-Reply-To: <m363519sv0.fsf@fleche.redhat.com>
On 13/03/2010 7:40 AM, Tom Tromey wrote:
>>>>>> "Chris" == Chris Johns<chris@contemporary.net.au> writes:
>
> Chris> (gdb) p the_semaphore->Object.id
> Chris> $36 = to_string = {
> Chris> id = 436273170,
> [...]
> Chris> How do I remove the extra "to_string =" ?
>
> Presumably your printer returns it.
Yes.
> Could you post the python code?
class object_id_printer:
"""Print an object given the ID. Print using the struct display
hint and an iterator."""
class object_id_iterator:
"""Use an iterator for each field expanded from the id so GDB
output is formatted correctly."""
def __init__(self, id):
self.id = id
self.count = 0
def __iter__(self):
return self
def next(self):
self.count += 1
if self.count == 1:
return int(self.id.value())
elif self.count == 2:
return self.id.node()
elif self.count == 3:
return self.id.api()
elif self.count == 4:
return self.id._class()
elif self.count == 5:
return self.id.index()
raise StopIteration
def __init__(self, id):
self.id = rtems_object_id(id)
def to_string(self):
return 'to_string'
@staticmethod
def key(i):
if i == 0:
return 'id'
elif i == 1:
return 'node'
elif i == 2:
return 'api'
elif i == 3:
return 'class'
elif i == 4:
return 'index'
return 'bad'
def children(self):
counter = itertools.imap (self.key, itertools.count())
return itertools.izip (counter,
self.object_id_iterator(self.id))
def display_hint (self):
return 'struct'
> Chris> I have also noticed this:
> Chris> (gdb) p /x the_semaphore->Object.id
> Chris> $37 = 0x1a010012
> Chris> Is it expected the actual value is shown in hex rather than the
> Chris> numeric fields returned by the pretty print iterator ?
>
> It might be a bug, I am not sure.
>
Should I raise a bug report ?
I have also found:
(gdb) p (Object_Id) 0x1a010012
does not invoke the Object_Id pretty printer. In this RTEMS target
Object_Id is a typedef to uint32_t which is a typedef to "unsigned long"
so GDB looks for a the "unsigned long" pretty printer rather that an
Object_Id one.
Chris
next prev parent reply other threads:[~2010-03-14 23:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 23:39 Chris Johns
2010-03-12 20:40 ` Tom Tromey
2010-03-14 23:40 ` Chris Johns [this message]
2010-03-15 16:39 ` Tom Tromey
2010-03-15 22:52 ` Chris Johns
2010-03-16 2:18 ` Tom Tromey
2010-03-16 5:10 ` Chris Johns
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=4B9D73C2.9090307@contemporary.net.au \
--to=chris@contemporary.net.au \
--cc=gdb@sourceware.org \
--cc=tromey@redhat.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