This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Fix a thinko in TYPE_IS_OPAQUE


The logic in TYPE_IS_OPAQUE has evolved, probably recently, to be
incorrect.  It's checking that opaque types have no fields or methods,
but the method check is "HAVE_CPLUS_STRUCT (thistype) &&
(TYPE_NFN_FIELDS (thistype) == 0)".  An opaque type will never have
had its C++-specific data allocated, so HAVE_CPLUS_STRUCT will be
false.

Things (in this case, gdb.base/opaque.exp) continued to work by luck.
If TYPE_STUB is set, but ! TYPE_IS_OPAQUE, then check_typedef calls
lookup_symbol to find the struct.  This is wrong because there's
nothing stopping us from finding the stub again.  For reasons I don't
understand, when the test is built with GCC we get lucky and find the
definition.  When it's built with RealView, we get unlucky and find
the stub again.

I've tested this fix on arm-none-eabi and committed it to trunk.
Does anyone have an opinion as to whether this goes on the branch
too?

-- 
Daniel Jacobowitz
CodeSourcery

2010-03-14  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdbtypes.h (TYPE_IS_OPAQUE): Correct HAVE_CPLUS_STRUCT check.

---
 gdb/gdbtypes.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: gdb-mainline/gdb/gdbtypes.h
===================================================================
--- gdb-mainline.orig/gdb/gdbtypes.h	2010-03-02 00:34:01.000000000 -0800
+++ gdb-mainline/gdb/gdbtypes.h	2010-03-14 13:48:33.000000000 -0700
@@ -1045,7 +1045,8 @@ extern void allocate_gnat_aux_type (stru
 #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) ||        \
                                    (TYPE_CODE (thistype) == TYPE_CODE_UNION))        && \
                                   (TYPE_NFIELDS (thistype) == 0)                     && \
-                                  (HAVE_CPLUS_STRUCT (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)) && \
+                                  (!HAVE_CPLUS_STRUCT (thistype)			\
+				   || TYPE_NFN_FIELDS (thistype) == 0) &&		\
                                   (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
 
 struct builtin_type


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]