return &NDie;
}
+DIE *DwarfUnit::getOrCreateModule(const DIModule *M) {
+ // Construct the context before querying for the existence of the DIE in case
+ // such construction creates the DIE.
+ DIE *ContextDIE = getOrCreateContextDIE(M->getScope());
+
+ if (DIE *MDie = getDIE(M))
+ return MDie;
+ DIE &MDie = createAndAddDIE(dwarf::DW_TAG_module, *ContextDIE, M);
+
+ if (!M->getName().empty()) {
+ addString(MDie, dwarf::DW_AT_name, M->getName());
+ addGlobalName(M->getName(), MDie, M->getScope());
+ }
+ if (!M->getConfigurationMacros().empty())
+ addString(MDie, dwarf::DW_AT_LLVM_config_macros,
+ M->getConfigurationMacros());
+ if (!M->getIncludePath().empty())
+ addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
+ if (!M->getISysRoot().empty())
+ addString(MDie, dwarf::DW_AT_LLVM_isysroot, M->getISysRoot());
+
+ return &MDie;
+}
+
DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE (as is the case for member function
// | ... |b1|b2|b3|b4|
// +-----------+-----*-----+-----*-----+--
// | | |<-- Size ->| |
- // |<---- Offset --->| | |<--->|
- // | | | | \_ DW_AT_bit_offset (little endian)
- // | |<--->| |
- // |<--big-e.->| \_ StartBitOffset = DW_AT_bit_offset (big endian)
- // | ^ | = DW_AT_data_bit_offset (biendian)
- // | OffsetInBytes |
- // | v |
- // |<----little-endian---->|
+ // |<---- Offset --->| |<--->|
+ // | | | \_ DW_AT_bit_offset (little endian)
+ // | |<--->|
+ // |<--------->| \_ StartBitOffset = DW_AT_bit_offset (big endian)
+ // \ = DW_AT_data_bit_offset (biendian)
+ // \_ OffsetInBytes
uint64_t Offset = DT->getOffsetInBits();
uint64_t Align = DT->getAlignInBits() ? DT->getAlignInBits() : FieldSize;
uint64_t AlignMask = ~(Align - 1);
// The bits from the start of the storage unit to the start of the field.
uint64_t StartBitOffset = Offset - (Offset & AlignMask);
- // OffsetInBytes is the byte offset of the field's aligned storage unit
- // inside the struct.
- uint64_t DwarfBitOffset;
- if (Asm->getDataLayout().isLittleEndian()) {
- DwarfBitOffset = OffsetToAlignment(Offset + Size, Align);
- OffsetInBytes = ((Offset + Size) & AlignMask) / 8;
- } else {
- DwarfBitOffset = StartBitOffset;
- OffsetInBytes = (Offset - StartBitOffset) / 8;
- }
+ // The endian-dependent DWARF 2 offset.
+ uint64_t DwarfBitOffset = Asm->getDataLayout().isLittleEndian()
+ ? OffsetToAlignment(Offset + Size, Align)
+ : StartBitOffset;
+
+ // The byte offset of the field's aligned storage unit inside the struct.
+ OffsetInBytes = (Offset - StartBitOffset) / 8;
addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, DwarfBitOffset);
} else
// This is not a bitfield.