public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/11777] New: Strange behaviour of gdb.Type.fields
@ 2010-07-01 7:20 andre dot poenitz at nokia dot com
2010-07-01 7:35 ` [Bug python/11777] " andre dot poenitz at nokia dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-01 7:20 UTC (permalink / raw)
To: gdb-prs
I sometimes cannot get a proper list of members from structures that do have
members:
This accesses a "real" QRegionPrivate object in a 'QRegion region;':
python print
gdb.parse_and_eval(\"region\")[\"d\"].dereference()[\"qt_rgn\"].dereference().type
-> struct myns::QRegionPrivate
python print
gdb.parse_and_eval(\"region\")[\"d\"].dereference()[\"qt_rgn\"].dereference().type.fields()
-> []
If I "create" the type manually I get:
python print gdb.parse_and_eval(\"('myns::QRegionPrivate'*)0\").dereference().type
-> myns::QRegionPrivate
python print gdb.parse_and_eval(\"('myns::QRegionPrivate'*)0
\").dereference().type.fields()
-> [<gdb.Field object at 0xb7764ac0>, <gdb.Field object at 0xb7764af0>,
<gdb.Field object at 0xb7764b20>, <gdb.Field object at 0xb7764b50>, <gdb.Field
object at 0xb7764b80>]
Note the extra "struct " in the 'type' output in the first case.
The problem also disappears when I use type = gdb.lookup_type(str(type))
before accessing fields().
--
Summary: Strange behaviour of gdb.Type.fields
Product: gdb
Version: 7.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: python
AssignedTo: unassigned at sourceware dot org
ReportedBy: andre dot poenitz at nokia dot com
CC: gdb-prs at sourceware dot org
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11777
------- 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] 5+ messages in thread
* [Bug python/11777] Strange behaviour of gdb.Type.fields
2010-07-01 7:20 [Bug python/11777] New: Strange behaviour of gdb.Type.fields andre dot poenitz at nokia dot com
@ 2010-07-01 7:35 ` andre dot poenitz at nokia dot com
2010-07-01 9:13 ` andre dot poenitz at nokia dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-01 7:35 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From andre dot poenitz at nokia dot com 2010-07-01 07:35 -------
To reproduce:
mkdir x && cd x
echo -e "#include <QRegion>\nint main() { QRegion r; }" > 1.cpp
qmake -project && qmake && make
gdb -ex "b main" -ex "run" -ex "python import gdb" -ex 'python print
gdb.parse_and_eval("r")["d"].dereference()["qt_rgn"].dereference().type.fields()' -ex
'python print
gdb.lookup_type(str(gdb.parse_and_eval("r")["d"].dereference()["qt_rgn"].dereference().type)).fields()'
./x
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11777
------- 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] 5+ messages in thread
* [Bug python/11777] Strange behaviour of gdb.Type.fields
2010-07-01 7:20 [Bug python/11777] New: Strange behaviour of gdb.Type.fields andre dot poenitz at nokia dot com
2010-07-01 7:35 ` [Bug python/11777] " andre dot poenitz at nokia dot com
@ 2010-07-01 9:13 ` andre dot poenitz at nokia dot com
2010-07-06 19:52 ` tromey at redhat dot com
2010-08-20 18:27 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-01 9:13 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From andre dot poenitz at nokia dot com 2010-07-01 09:13 -------
To reproduce without Qt:
------------------------- snip ------------------------
mkdir x && cd x
echo -e "struct P { P(); int a, b, c, d; }; " > p.h
echo -e "#include \"p.h\"\n P::P() {} " > p.cpp
echo -e "class P; struct X { X(); P *p; };" > x.h
echo -e " #include \"x.h\"\n X::X() {} " > x.cpp
echo -e "#include \"x.h\"\n int main() { X x; }" > main.cpp
g++ -g -shared -o libxp.so x.cpp p.cpp
g++ -g -o x -L. -lxp main.cpp -Wl,-rpath,`pwd`
gdb -ex "b main" -ex "run" -ex "python import gdb" \
-ex 'set confirm off' \
-ex 'python print gdb.parse_and_eval("x")["p"].dereference().type.fields()' \
-ex 'python print
gdb.lookup_type(str(gdb.parse_and_eval("x")["p"].dereference().type)).fields()' \
-ex q \
./x
------------------------- snip ------------------------
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11777
------- 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] 5+ messages in thread
* [Bug python/11777] Strange behaviour of gdb.Type.fields
2010-07-01 7:20 [Bug python/11777] New: Strange behaviour of gdb.Type.fields andre dot poenitz at nokia dot com
2010-07-01 7:35 ` [Bug python/11777] " andre dot poenitz at nokia dot com
2010-07-01 9:13 ` andre dot poenitz at nokia dot com
@ 2010-07-06 19:52 ` tromey at redhat dot com
2010-08-20 18:27 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-07-06 19:52 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-07-06 19:52 -------
(In reply to comment #2)
> -ex 'python print gdb.parse_and_eval("x")["p"].dereference().type.fields()' \
I can make this work by adding a call to strip_typedefs:
(gdb) python print gdb.parse_and_eval ('x')['p'].dereference().type.fields()
[]
(gdb) python print gdb.parse_and_eval
('x')['p'].dereference().type.strip_typedefs().fields()
[<gdb.Field object at 0xb7dbc220>, <gdb.Field object at 0xb7dbc250>, <gdb.Field
object at 0xb7dbc280>, <gdb.Field object at 0xb7dbc2b0>]
Arguably the Python API should be doing this for you.
It seems useless to get the fields of a stub type.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11777
------- 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] 5+ messages in thread
* [Bug python/11777] Strange behaviour of gdb.Type.fields
2010-07-01 7:20 [Bug python/11777] New: Strange behaviour of gdb.Type.fields andre dot poenitz at nokia dot com
` (2 preceding siblings ...)
2010-07-06 19:52 ` tromey at redhat dot com
@ 2010-08-20 18:27 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-08-20 18:27 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-08-20 18:27 -------
*** This bug has been marked as a duplicate of 10953 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://sourceware.org/bugzilla/show_bug.cgi?id=11777
------- 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] 5+ messages in thread
end of thread, other threads:[~2010-08-20 18:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-01 7:20 [Bug python/11777] New: Strange behaviour of gdb.Type.fields andre dot poenitz at nokia dot com
2010-07-01 7:35 ` [Bug python/11777] " andre dot poenitz at nokia dot com
2010-07-01 9:13 ` andre dot poenitz at nokia dot com
2010-07-06 19:52 ` tromey at redhat dot com
2010-08-20 18:27 ` tromey 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).