> If a field in a record is at a variable offset from
> the start of the record, then DebugInfo::getOrCreateType
> crashes at this line
>           MemberDesc->setOffset(int_bit_position(Member));
> since the bit-offset is not an integer constant.  Fixed
> by using 0 for the offset in this case - which is a cop
> out, but doing anything else seems hard.  This is what
> gcc does too.

After thinking about this some more, I reckon it's better
not to emit debug info for such fields at all.  What's the
point of be able to access a field if it's accessing the
wrong memory (which is what you get by using offset 0)?
My experience with gcc is that it's just confusing when,
in gdb, you print the contents of a struct and see a
bunch of fields with bogus values.  The attached patch
simply skips over fields at a variable offset.

Ciao,

Duncan.
Index: gcc.llvm.master/gcc/llvm-debug.cpp
===================================================================
--- gcc.llvm.master.orig/gcc/llvm-debug.cpp	2007-04-12 10:46:59.000000000 +0200
+++ gcc.llvm.master/gcc/llvm-debug.cpp	2007-04-12 10:47:15.000000000 +0200
@@ -674,6 +674,10 @@
                                    NULL;
 
         if (TREE_CODE(Member) == FIELD_DECL) {
+          if (TREE_CODE(DECL_FIELD_OFFSET(Member)) != INTEGER_CST)
+            // FIXME: field with variable position, skip it for now.
+            continue;
+
           DerivedTypeDesc *MemberDesc = new DerivedTypeDesc(DW_TAG_member);
           // Field type is the declared type of the field.
           tree FieldNodeType = FieldType(Member);
_______________________________________________
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to