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.
Testing a patch.
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
Fixed.