Bug 12070 - gdb.Field object attributes not visible from "dir"
Summary: gdb.Field object attributes not visible from "dir"
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 7.5
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-28 16:15 UTC by dje
Modified: 2012-02-17 19:26 UTC (History)
2 users (show)

See Also:
Host: amd64-linux
Target:
Build:
Last reconfirmed: 2012-02-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2010-09-28 16:15:50 UTC
The python "dir" command prints the list of attributes of an object, but it 
doesn't work completely for gdb.Field objects.

foo.cc:
enum myenum { FOO = 42 };
int main() { return FOO; }

(gdb) py myenum = gdb.lookup_type("myenum")
(gdb) py print dir(myenum.fields()[0])
-->
['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', 
'__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
'__str__']

Note that "name", etc. are missing.
Comment 1 Tom Tromey 2012-02-17 17:54:46 UTC
Testing a patch.
Comment 2 Sourceware Commits 2012-02-17 19:24:30 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2012-02-17 19:24:27

Modified files:
	gdb            : ChangeLog 
	gdb/python     : py-event.c py-type.c py-utils.c 
	                 python-internal.h 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.python: py-events.exp py-events.py py-type.exp 

Log message:
	PR python/12070:
	* python/py-event.c (event_object_getset): New global.
	(event_object_type): Reference it.
	* python/py-type.c (field_object_getset): New global.
	(field_object_type): Reference it.
	* python/python-internal.h (gdb_py_generic_dict): Declare.
	* python/py-utils.c (gdb_py_generic_dict): New function.
	testsuite/gdb
	* gdb.python/py-events.py (exit_handler): Add test for 'dir'.
	* gdb.python/py-events.exp: Check 'dir' output.
	* gdb.python/py-type.exp (test_fields): Add test for 'dir'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13841&r2=1.13842
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-event.c.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-utils.c.diff?cvsroot=src&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/python-internal.h.diff?cvsroot=src&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3077&r2=1.3078
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-events.exp.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-events.py.diff?cvsroot=src&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-type.exp.diff?cvsroot=src&r1=1.20&r2=1.21
Comment 3 Tom Tromey 2012-02-17 19:26:14 UTC
Fixed.