Bug 10805 - GDB Type.fields() crashes on non-struct/class types
Summary: GDB Type.fields() crashes on non-struct/class types
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: archer
: P1 normal
Target Milestone: 7.1
Assignee: Phil Muldoon
URL:
Keywords:
: 10827 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-19 10:23 UTC by Phil Muldoon
Modified: 2009-11-09 08:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Muldoon 2009-10-19 10:23:13 UTC
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.
Comment 1 Phil Muldoon 2009-10-20 10:12:17 UTC
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)
Comment 2 Andre' 2009-10-22 09:01:19 UTC
*** Bug 10827 has been marked as a duplicate of this bug. ***
Comment 3 Phil Muldoon 2009-11-09 08:24:04 UTC
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.

Comment 4 Sourceware Commits 2009-12-03 21:20:17 UTC
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