[cfe-commits] r128776 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CGDebugInfo.cpp CGRTTI.cpp CGVTables.cpp CGVTables.h

Ken Dyck kd at kendyck.com
Thu Apr 7 05:52:45 PDT 2011


On Mon, Apr 4, 2011 at 4:39 PM, Devang Patel <dpatel at apple.com> wrote:
> This little series of patches are breaking debug info. In attached test case, base offset for class D -> C is now wrong. It used to be
>
> 0x00000c82:     TAG_class_type [27] *
>                 AT_sibling( {0x00000cca} )
>                 AT_name( "D" )
>                 AT_byte_size( 0x28 )
>                 AT_decl_file( "/private/tmp/i.cc" )
>                 AT_decl_line( 164 )
>
> 0x00000c8c:         TAG_inheritance [29]
>                     AT_type( {0x00000bcc} ( B ) )
>                     AT_data_member_location( +0 )
>                     AT_accessibility( DW_ACCESS_public )
>
> 0x00000c95:         TAG_inheritance [29]
>                     AT_type( {0x00000c27} ( C ) )
>                     AT_data_member_location( +16 )  <---- Now this is +2 after your patches.
>                     AT_accessibility( DW_ACCESS_public )
>
> Now, the debug info claims that C is at +2 offset.

The breakage was a result of this change to lib/CodeGen/CGDebugInfo.cpp:

@@ -816,10 +816,11 @@
    if (BI->isVirtual()) {
      // virtual base offset offset is -ve. The code generator emits dwarf
      // expression where it expects +ve number.
-      BaseOffset = 0 - CGM.getVTables().getVirtualBaseOffsetOffset(RD, Base);
+      BaseOffset = CharUnits::Zero() -
+        CGM.getVTables().getVirtualBaseOffsetOffset(RD, Base);
      BFlags = llvm::DIDescriptor::FlagVirtual;
    } else
-      BaseOffset = RL.getBaseClassOffsetInBits(Base);
+      BaseOffset = RL.getBaseClassOffset(Base);

I had failed to notice that the units for BaseOffset are inconsistent.
When the class is virtual, the offset is in bytes. Otherwise the
offset is in bits. Is that intended?

-Ken




More information about the cfe-commits mailing list