void DebugInfoFinder::processType(DIType DT) { if (!addType(DT)) return; processScope(DT.getContext().resolve(TypeIdentifierMap)); if (DT.isCompositeType()) { DICompositeType DCT(DT); processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap)); if (DT.isSubroutineType()) { DITypeArray DTA = DISubroutineType(DT).getTypeArray(); for (unsigned i = 0, e = DTA.getNumElements(); i != e; ++i) processType(DTA.getElement(i).resolve(TypeIdentifierMap)); return; } DIArray DA = DCT.getElements(); for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { DIDescriptor D = DA.getElement(i); if (D.isType()) processType(DIType(D)); else if (D.isSubprogram()) processSubprogram(DISubprogram(D)); } } else if (DT.isDerivedType()) { DIDerivedType DDT(DT); processType(DDT.getTypeDerivedFrom().resolve(TypeIdentifierMap)); } }
/// addGlobalType - Add a new global type to the compile unit. /// void CompileUnit::addGlobalType(DIType Ty) { DIDescriptor Context = Ty.getContext(); if (Ty.isCompositeType() && !Ty.getName().empty() && !Ty.isForwardDecl() && (Context.isCompileUnit() || Context.isFile() || Context.isNameSpace())) if (DIEEntry *Entry = getDIEEntry(Ty)) GlobalTypes[Ty.getName()] = Entry->getEntry(); }
/// addSourceLine - Add location information to specified debug information /// entry. void CompileUnit::addSourceLine(DIE *Die, DIType Ty) { // Verify type. if (!Ty.Verify()) return; unsigned Line = Ty.getLineNumber(); if (Line == 0 || !Ty.getContext().Verify()) return; unsigned FileID = DD->GetOrCreateSourceID(Ty.getFilename(), Ty.getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); }
void DebugInfoFinder::processType(DIType DT) { if (!addType(DT)) return; processScope(DT.getContext().resolve(TypeIdentifierMap)); if (DICompositeType DCT = dyn_cast<MDCompositeTypeBase>(DT)) { processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap)); if (DISubroutineType ST = dyn_cast<MDSubroutineType>(DCT)) { for (MDTypeRef Ref : ST->getTypeArray()) processType(Ref.resolve(TypeIdentifierMap)); return; } for (Metadata *D : DCT->getElements()->operands()) { if (DIType T = dyn_cast<MDType>(D)) processType(T); else if (DISubprogram SP = dyn_cast<MDSubprogram>(D)) processSubprogram(SP); } } else if (DIDerivedType DDT = dyn_cast<MDDerivedTypeBase>(DT)) { processType(DDT.getTypeDerivedFrom().resolve(TypeIdentifierMap)); } }