On 24/02/11 22:34, Jason Kim wrote:> On Thu, Feb 24, 2011 at 1:29 PM, Devang Patel<dpatel at apple.com> wrote: >> Hi All, >> DIFactory interface, part of DebugInfo.h, is used to emit LLVM IR constructs >> to encode debugging information. We are replacing this interface with new >> simple interface, DIBuilder. >> Here is one example that demonstrates differences between two interfaces. To >> create debug information entries to encode volatile type one would use >> following call in a language front end, >> CreateDerivedType(DW_TAG_volatile_type, Context, StringRef(), File, >> 0 /*line no*/, type_size_in_bits, >> type_align_in_bits, >> 0 /* offset */, 0 /* flags */, OriginalType); >> using DIFactory interface. Now, DIBuilder allows you to do the same using >> following call. >> createQualifiedType(DW_TAG_volatile_type, OriginalType); >> DIBuilder interface was introduced in Nov/Dec last year. Now, clang has >> fully adopted this new interface. So we are going to remove DIFactory from >> llvm sources soon. Our plan is to move DIFactory interface in dragonegg (and >> llvm-gcc) for now until the front-ends adopt DIBuilder. >> If you have any concerns about this plan, please speak up now. > > Assuming it has no impact on the actual dwarf tags, smaller code is better! > -jasonIt does make me wonder how you are supposed to represent types which cannot be properly represented by LLVM types, for example structs with fields at variable offsets from the start and/or of variable size; or structs with fields that may or may not be present depending on the value of other fields. Such types occur in Ada for example. Ciao, Duncan.
On Feb 25, 2011, at 2:28 AM, Duncan Sands wrote:> It does make me wonder how you are supposed to represent types which cannot > be properly represented by LLVM types, for example structs with fields at > variable offsets from the start and/or of variable size; or structs with > fields that may or may not be present depending on the value of other fields. > Such types occur in Ada for example.The metadata constructs used to encode debugging information do not use (or refer) LLVM types directly. Here is the interface to emit debug info for a member. /// createMemberType - Create debugging information entry for a member. /// @param Name Member name. /// @param File File where this member is defined. /// @param LineNo Line number. /// @param SizeInBits Member size. /// @param AlignInBits Member alignment. /// @param OffsetInBits Member offset. /// @param Flags Flags to encode member attribute, e.g. private /// @param Ty Parent type. DIType createMemberType(StringRef Name, DIFile File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty); Of course, the FE needs to know the offset, size, alignment etc... for each field as per source language. The Parent type here is also debug info entry for the enclosing structure/class. Regarding variable size fields, I am not sure how they are encoded in DWARF. - Devang
Hi Devang,>> It does make me wonder how you are supposed to represent types which cannot >> be properly represented by LLVM types, for example structs with fields at >> variable offsets from the start and/or of variable size; or structs with >> fields that may or may not be present depending on the value of other fields. >> Such types occur in Ada for example. > > The metadata constructs used to encode debugging information do not use (or refer) LLVM types directly. Here is the interface to emit debug info for a member.thanks for the explanation.> > /// createMemberType - Create debugging information entry for a member. > /// @param Name Member name. > /// @param File File where this member is defined. > /// @param LineNo Line number. > /// @param SizeInBits Member size.For Ada this needs to be a Value* since it is dynamic. But presumably this interface is a direct mapping to the Dwarf specification, i.e. Dwarf itself has no way of encoding a variable size here?> /// @param AlignInBits Member alignment. > /// @param OffsetInBits Member offset.This is likewise dynamic in general.> /// @param Flags Flags to encode member attribute, e.g. private > /// @param Ty Parent type. > DIType createMemberType(StringRef Name, DIFile File, > unsigned LineNo, uint64_t SizeInBits, > uint64_t AlignInBits, uint64_t OffsetInBits, > unsigned Flags, DIType Ty); > > > Of course, the FE needs to know the offset, size, alignment etc... for each field as per source language. The Parent type here is also debug info entry for the enclosing structure/class. Regarding variable size fields, I am not sure how they are encoded in DWARF.GCC outputs some language specific Dwarf tags for Ada, perhaps to handle these kinds of mad types. Ciao, Duncan.