Daniel Jacobowitz wrote about some Python/GDB experiences and bugs in the email: http://sourceware.org/ml/archer/2009-q4/msg00008.html This bug (and others in their own bugs) is extracted from that email to track the issue: * Calling type.fields on an array type crashes. It accesses TYPE_N_BASECLASSES; cplus_stuff isn't allocated for non-structs.
This is what I see currently in both FSF HEAD and archer-tromey-python branch: 37 return 0; /* break to inspect struct and union */ (gdb) p st $2 = { a = 3, b = 5 } (gdb) python st = gdb.history(0) (gdb) py print st { a = 3, b = 5 } (gdb) p ar $3 = {1, 2} (gdb) py ar = gdb.history (0) (gdb) py print ar {1, 2} (gdb) python fields = st.type.fields() (gdb) py print fields[0].name a (gdb) py print fields[1].name b (gdb) python fields = ar.type.fields() Segmentation fault (core dumped)
*** Bug 10827 has been marked as a duplicate of this bug. ***
A patch was submitted here: http://sourceware.org/ml/archer/2009-q4/msg00016.html Reviewed and approved here: http://sourceware.org/ml/archer/2009-q4/msg00032.html And checked in with commit id (dad6b53fe4a6df586dcd0a57e2151e7663191f18) here: http://sourceware.org/ml/archer-commits/2009-q4/msg00018.html As this is archer-tromey-python only functionality, it has not been committed to GDB upstream. There is a discussion on committing it.
Subject: Bug 10805 CVSROOT: /cvs/src Module name: src Changes by: pmuldoon@sourceware.org 2009-12-03 21:19:49 Modified files: gdb : ChangeLog gdb/doc : ChangeLog gdb.texinfo gdb/python : py-type.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.python: Makefile.in Added files: gdb/testsuite/gdb.python: py-type.c py-type.exp Log message: 2009-12-03 Richard Ward <richard.j.ward1@googlemail.com> * python/py-type.c (convert_field): New attribute "is_base_class". doc/ 2009-12-03 Richard Ward <richard.j.ward1@googlemail.com> * gdb.texinfo (Types In Python): Describe "is_base_class". testsuite/ 2009-12-03 Phil Muldoon <pmuldoon@redhat.com> PR python/10805 * gdb.python/py-type.exp: New file. * gdb.python/py-type.c: New file. * Makefile.in: Add py-type. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11128&r2=1.11129 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.978&r2=1.979 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.646&r2=1.647 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.2&r2=1.3 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2044&r2=1.2045 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-type.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-type.exp.diff?cvsroot=src&r1=NONE&r2=1.1 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/Makefile.in.diff?cvsroot=src&r1=1.2&r2=1.3