clEnumVal(Disable, "Disabled"), clEnumValEnd),
cl::init(Default));
-static cl::opt<DefaultOnOff>
-DarwinGDBCompat("darwin-gdb-compat", cl::Hidden,
- cl::desc("Compatibility with Darwin gdb."),
- cl::values(clEnumVal(Default, "Default for platform"),
- clEnumVal(Enable, "Enabled"),
- clEnumVal(Disable, "Disabled"), clEnumValEnd),
- cl::init(Default));
-
static cl::opt<DefaultOnOff>
SplitDwarf("split-dwarf", cl::Hidden,
cl::desc("Output prototype dwarf split debug info."),
DIType subType = Ty;
uint16_t tag = Ty.getTag();
- if (tag == dwarf::DW_TAG_pointer_type) {
- DIDerivedType DTy = DIDerivedType(Ty);
- subType = DTy.getTypeDerivedFrom();
- }
-
- DICompositeType blockStruct = DICompositeType(subType);
- DIArray Elements = blockStruct.getTypeArray();
+ if (tag == dwarf::DW_TAG_pointer_type)
+ subType = DIDerivedType(Ty).getTypeDerivedFrom();
+ DIArray Elements = DICompositeType(subType).getTypeArray();
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
- DIDescriptor Element = Elements.getElement(i);
- DIDerivedType DT = DIDerivedType(Element);
+ DIDerivedType DT = DIDerivedType(Elements.getElement(i));
if (getName() == DT.getName())
return (DT.getTypeDerivedFrom());
}
/// Return Dwarf Version by checking module flags.
static unsigned getDwarfVersionFromModule(const Module *M) {
Value *Val = M->getModuleFlag("Dwarf Version");
- // If we don't have a value in the module go ahead and use the default in
- // dwarf::DWARF_VERSION.
- // FIXME: Apple ld has a problem parsing compilation units that specify a
- // dwarf version of greater than 3.
if (!Val)
- return Triple(M->getTargetTriple()).isOSDarwin() ? 3 : dwarf::DWARF_VERSION;
+ return dwarf::DWARF_VERSION;
return cast<ConstantInt>(Val)->getZExtValue();
}
// and handle split dwarf.
bool IsDarwin = Triple(A->getTargetTriple()).isOSDarwin();
- if (DarwinGDBCompat == Default)
- IsDarwinGDBCompat = IsDarwin;
- else
- IsDarwinGDBCompat = DarwinGDBCompat == Enable;
-
if (DwarfAccelTables == Default)
HasDwarfAccelTables = IsDarwin;
else
}
}
+/// isSubprogramContext - Return true if Context is either a subprogram
+/// or another context nested inside a subprogram.
+bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
+ if (!Context)
+ return false;
+ DIDescriptor D(Context);
+ if (D.isSubprogram())
+ return true;
+ if (D.isType())
+ return isSubprogramContext(resolve(DIType(Context).getContext()));
+ return false;
+}
+
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
// and DW_AT_high_pc attributes. If there are global variables in this
// scope then create and insert DIEs for these variables.
// Add to context owner.
TheCU->addToContextOwner(SubprogramDie, SP.getContext());
- // Expose as global, if requested.
- if (HasDwarfPubSections)
- TheCU->addGlobalName(SP.getName(), SubprogramDie);
+ // Expose as a global name.
+ TheCU->addGlobalName(SP.getName(), SubprogramDie);
}
void DwarfDebug::constructImportedEntityDIE(CompileUnit *TheCU,
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
if (!CU_Nodes)
return;
+ TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
// Emit initial sections so we can reference labels later.
emitSectionLabels();
// Emit the pubnames and pubtypes sections if requested.
if (HasDwarfPubSections) {
- emitDebugPubnames();
+ emitDebugPubNames();
emitDebugPubTypes();
}
DwarfLineSectionSym =
emitSectionSym(Asm, TLOF.getDwarfLineSection(), "section_line");
emitSectionSym(Asm, TLOF.getDwarfLocSection());
- if (HasDwarfPubSections)
+ if (HasDwarfPubSections) {
emitSectionSym(Asm, TLOF.getDwarfPubNamesSection());
- if (useDarwinGDBCompat() || HasDwarfPubSections)
emitSectionSym(Asm, TLOF.getDwarfPubTypesSection());
+ }
DwarfStrSectionSym =
emitSectionSym(Asm, TLOF.getDwarfStrSection(), "info_string");
if (useSplitDwarf()) {
// Emit visible names into a hashed accelerator table section.
void DwarfDebug::emitAccelNames() {
- DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
+ DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
// Emit objective C classes and categories into a hashed accelerator table
// section.
void DwarfDebug::emitAccelObjC() {
- DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
+ DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
// Emit namespace dies into a hashed accelerator table.
void DwarfDebug::emitAccelNamespaces() {
- DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
+ DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
// Emit type dies into a hashed accelerator table.
void DwarfDebug::emitAccelTypes() {
std::vector<DwarfAccelTable::Atom> Atoms;
- Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
+ Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
- Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeTag,
+ Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag,
dwarf::DW_FORM_data2));
- Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeTypeFlags,
+ Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags,
dwarf::DW_FORM_data1));
DwarfAccelTable AT(Atoms);
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
AT.Emit(Asm, SectionBegin, &InfoHolder);
}
-/// emitDebugPubnames - Emit visible names into a debug pubnames section.
+/// emitDebugPubNames - Emit visible names into a debug pubnames section.
///
-void DwarfDebug::emitDebugPubnames() {
+void DwarfDebug::emitDebugPubNames() {
const MCSection *ISec = Asm->getObjFileLowering().getDwarfInfoSection();
typedef DenseMap<const MDNode*, CompileUnit*> CUMapType;