public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/11381] New: pretty print display hint struct format problems
@ 2010-03-16 5:08 chrisj at rtems dot org
2010-03-31 13:05 ` [Bug python/11381] " pmuldoon at redhat dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: chrisj at rtems dot org @ 2010-03-16 5:08 UTC (permalink / raw)
To: gdb-prs
A pretty print iterator with a display hint of 'struct' prints the result of the
'to_string' call when it should not or is not needed. The problem can be shown
with a pretty print iterator for the Object_Id type in RTEMS. Stripping this
type reduces it to an "unsigned long" that is a series of bit fields. The pretty
print iterator displays the bit fields in a struct format so GDB formats the
output correctly. For example:
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'
The output is:
(gdb) p the_semaphore->Object.id
$36 = to_string = {
id = 436273170,
node = 1,
api = classic,
class = semaphores,
index = 18
}
Note the "to_string = " after the $36 should not be there.
Removing the "to_string" function from the class results in:
(gdb) p the_semaphore->Object.id
$4 = AttributeError: object_id_printer instance has no attribute 'to_string'
= {
id = 436273170,
node = 1,
api = classic,
class = semaphores,
index = 18
}
Removing this function or returning None should be allowed and result in no
related output.
--
Summary: pretty print display hint struct format problems
Product: gdb
Version: 7.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: python
AssignedTo: unassigned at sourceware dot org
ReportedBy: chrisj at rtems dot org
CC: gdb-prs at sourceware dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
@ 2010-03-31 13:05 ` pmuldoon at redhat dot com
2010-04-01 0:00 ` chrisj at rtems dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-03-31 13:05 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pmuldoon at redhat dot com 2010-03-31 13:05 -------
What happens if you write this in your printer:
def to_string(self):
return ""
Does the output format ok then?
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at sourceware dot|pmuldoon at redhat dot com
|org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
2010-03-31 13:05 ` [Bug python/11381] " pmuldoon at redhat dot com
@ 2010-04-01 0:00 ` chrisj at rtems dot org
2010-04-01 12:51 ` pmuldoon at redhat dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: chrisj at rtems dot org @ 2010-04-01 0:00 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From chrisj at rtems dot org 2010-04-01 00:00 -------
No. The output is:
(gdb) p the_semaphore->Object.id
$36 = = {
id = 436273170,
node = 1,
api = classic,
class = semaphores,
index = 18
}
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
2010-03-31 13:05 ` [Bug python/11381] " pmuldoon at redhat dot com
2010-04-01 0:00 ` chrisj at rtems dot org
@ 2010-04-01 12:51 ` pmuldoon at redhat dot com
2010-04-01 16:28 ` pmuldoon at redhat dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-04-01 12:51 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pmuldoon at redhat dot com 2010-04-01 12:51 -------
Right so if to_string() returns None, we can omit the preceding "=" then? Would
that work?
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
` (2 preceding siblings ...)
2010-04-01 12:51 ` pmuldoon at redhat dot com
@ 2010-04-01 16:28 ` pmuldoon at redhat dot com
2010-04-01 16:29 ` pmuldoon at redhat dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-04-01 16:28 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pmuldoon at redhat dot com 2010-04-01 16:28 -------
I'm attaching a draft patch that will allow the user to return None in to_string
and the output should be formatted correctly. This is an example of a vector
that returns None for to_string, and a deque that returns some text:
(gdb) p v
$1 = {0x409922 "one"}
(gdb) p ddd
$2 = std::deque with 3 elements {18, 23, 7}
If this is what you want, I'll update/clean-up/add testcases to the patch and
submit it to FSF GDB.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
` (3 preceding siblings ...)
2010-04-01 16:28 ` pmuldoon at redhat dot com
@ 2010-04-01 16:29 ` pmuldoon at redhat dot com
2010-04-07 17:21 ` tromey at redhat dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-04-01 16:29 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pmuldoon at redhat dot com 2010-04-01 16:29 -------
Created an attachment (id=4698)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=4698&action=view)
No leading string patch
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
` (4 preceding siblings ...)
2010-04-01 16:29 ` pmuldoon at redhat dot com
@ 2010-04-07 17:21 ` tromey at redhat dot com
2010-04-07 17:27 ` pmuldoon at redhat dot com
2010-04-14 12:38 ` pmuldoon at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2010-04-07 17:21 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-04-07 17:21 -------
$1 = {0x409922 "one"}
A little nit -- there are two spaces between the "=" and "{" here,
but I think there should only be one.
Also the patch introduces a new global... I'm sure there is another way.
I think the idea is good though.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
` (5 preceding siblings ...)
2010-04-07 17:21 ` tromey at redhat dot com
@ 2010-04-07 17:27 ` pmuldoon at redhat dot com
2010-04-14 12:38 ` pmuldoon at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-04-07 17:27 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pmuldoon at redhat dot com 2010-04-07 17:27 -------
I've a rewritten patch that passes parameters around and has done away with the
global. Patch to follow
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug python/11381] pretty print display hint struct format problems
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
` (6 preceding siblings ...)
2010-04-07 17:27 ` pmuldoon at redhat dot com
@ 2010-04-14 12:38 ` pmuldoon at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: pmuldoon at redhat dot com @ 2010-04-14 12:38 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2010-04-14 12:03 -------
Subject: Bug 11381
CVSROOT: /cvs/src
Module name: src
Changes by: pmuldoon@sourceware.org 2010-04-14 12:02:46
Modified files:
gdb : ChangeLog
gdb/doc : ChangeLog gdb.texinfo
gdb/python : py-prettyprint.c
gdb/testsuite : ChangeLog
gdb/testsuite/gdb.python: py-mi.exp py-prettyprint.c
py-prettyprint.exp py-prettyprint.py
Log message:
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
PR python/11381
* python/py-prettyprint.c (pretty_print_one_value): Test for
Py_None.
(print_string_repr): Test for Py_None. Set flags accordingly.
Return value depending on return type.
(print_children): Take a value indicating whether data was printed
before this function was called. Alter output accordingly.
(apply_val_pretty_printer): Capture return value from
print_string_repr and pass to print_children.
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-prettyprint.py (NoStringContainerPrinter): New printer.
* gdb.python/py-prettyprint.c: Add justchildren struct, typedefs.
* gdb.python/py-prettyprint.exp: New test for to_string returning None.
* gdb.python/py-mi.exp: New test for to_string returning None.
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Pretty Printing): Document behaviour when to_string
returns None.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11612&r2=1.11613
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1045&r2=1.1046
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.703&r2=1.704
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-prettyprint.c.diff?cvsroot=src&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2231&r2=1.2232
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-mi.exp.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-prettyprint.c.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-prettyprint.exp.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-prettyprint.py.diff?cvsroot=src&r1=1.5&r2=1.6
------- Additional Comments From pmuldoon at redhat dot com 2010-04-14 12:38 -------
Fixed as show in comment #8
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|7.1 |7.2
http://sourceware.org/bugzilla/show_bug.cgi?id=11381
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-04-14 12:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-16 5:08 [Bug python/11381] New: pretty print display hint struct format problems chrisj at rtems dot org
2010-03-31 13:05 ` [Bug python/11381] " pmuldoon at redhat dot com
2010-04-01 0:00 ` chrisj at rtems dot org
2010-04-01 12:51 ` pmuldoon at redhat dot com
2010-04-01 16:28 ` pmuldoon at redhat dot com
2010-04-01 16:29 ` pmuldoon at redhat dot com
2010-04-07 17:21 ` tromey at redhat dot com
2010-04-07 17:27 ` pmuldoon at redhat dot com
2010-04-14 12:38 ` pmuldoon at redhat dot com
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).