Index: lib/DebugInfo/DWARFCompileUnit.h =================================================================== --- lib/DebugInfo/DWARFCompileUnit.h +++ lib/DebugInfo/DWARFCompileUnit.h @@ -16,10 +16,10 @@ class DWARFCompileUnit : public DWARFUnit { public: - DWARFCompileUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA, + DWARFCompileUnit(UnitKind Kind, DWARFContext& Context, const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M, bool LE) - : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {} + : DWARFUnit(Kind, Context, DA, IS, RS, SS, SOS, AOS, M, LE) {} void dump(raw_ostream &OS); // VTable anchor. ~DWARFCompileUnit() override; Index: lib/DebugInfo/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARFContext.cpp +++ lib/DebugInfo/DWARFContext.cpp @@ -318,8 +318,8 @@ const DataExtractor &DIData = DataExtractor(getInfoSection().Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - std::unique_ptr CU(new DWARFCompileUnit(*this, - getDebugAbbrev(), getInfoSection().Data, getRangeSection(), + std::unique_ptr CU(new DWARFCompileUnit(DWARFUnit::UK_Compile, + *this, getDebugAbbrev(), getInfoSection().Data, getRangeSection(), getStringSection(), StringRef(), getAddrSection(), &getInfoSection().Relocs, isLittleEndian())); if (!CU->extract(DIData, &offset)) { @@ -338,7 +338,7 @@ const DataExtractor &DIData = DataExtractor(I.second.Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - std::unique_ptr TU(new DWARFTypeUnit(*this, + std::unique_ptr TU(new DWARFTypeUnit(DWARFUnit::UK_Type, *this, getDebugAbbrev(), I.second.Data, getRangeSection(), getStringSection(), StringRef(), getAddrSection(), &I.second.Relocs, isLittleEndian())); @@ -357,10 +357,11 @@ const DataExtractor &DIData = DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - std::unique_ptr DWOCU(new DWARFCompileUnit(*this, - getDebugAbbrevDWO(), getInfoDWOSection().Data, getRangeDWOSection(), - getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(), - &getInfoDWOSection().Relocs, isLittleEndian())); + std::unique_ptr DWOCU(new DWARFCompileUnit( + DWARFUnit::UK_DWOCompile, *this, getDebugAbbrevDWO(), + getInfoDWOSection().Data, getRangeDWOSection(), getStringDWOSection(), + getStringOffsetDWOSection(), getAddrSection(), &getInfoDWOSection().Relocs, + isLittleEndian())); if (!DWOCU->extract(DIData, &offset)) { break; } @@ -377,8 +378,8 @@ const DataExtractor &DIData = DataExtractor(I.second.Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - std::unique_ptr TU(new DWARFTypeUnit(*this, - getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(), + std::unique_ptr TU(new DWARFTypeUnit(DWARFUnit::UK_DWOType, + *this, getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(), getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(), &I.second.Relocs, isLittleEndian())); if (!TU->extract(DIData, &offset)) Index: lib/DebugInfo/DWARFTypeUnit.h =================================================================== --- lib/DebugInfo/DWARFTypeUnit.h +++ lib/DebugInfo/DWARFTypeUnit.h @@ -19,10 +19,10 @@ uint64_t TypeHash; uint32_t TypeOffset; public: - DWARFTypeUnit(DWARFContext &Context, const DWARFDebugAbbrev *DA, + DWARFTypeUnit(UnitKind Kind, DWARFContext &Context, const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M, bool LE) - : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {} + : DWARFUnit(Kind, Context, DA, IS, RS, SS, SOS, AOS, M, LE) {} uint32_t getHeaderSize() const override { return DWARFUnit::getHeaderSize() + 12; } Index: lib/DebugInfo/DWARFUnit.h =================================================================== --- lib/DebugInfo/DWARFUnit.h +++ lib/DebugInfo/DWARFUnit.h @@ -28,6 +28,16 @@ class raw_ostream; class DWARFUnit { +public: + enum UnitKind { + UK_Compile, + UK_DWOCompile, + UK_Type, + UK_DWOType, + }; + +private: + UnitKind Kind; DWARFContext &Context; const DWARFDebugAbbrev *Abbrev; @@ -66,12 +76,13 @@ virtual uint32_t getHeaderSize() const { return 11; } public: - DWARFUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA, StringRef IS, - StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, + DWARFUnit(UnitKind Kind, DWARFContext& Context, const DWARFDebugAbbrev *DA, + StringRef IS, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M, bool LE); virtual ~DWARFUnit(); + UnitKind getKind() const { return Kind; } DWARFContext& getContext() const { return Context; } StringRef getStringSection() const { return StringSection; } Index: lib/DebugInfo/DWARFUnit.cpp =================================================================== --- lib/DebugInfo/DWARFUnit.cpp +++ lib/DebugInfo/DWARFUnit.cpp @@ -17,10 +17,10 @@ using namespace llvm; using namespace dwarf; -DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFDebugAbbrev *DA, +DWARFUnit::DWARFUnit(UnitKind Kind, DWARFContext &DC, const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M, bool LE) - : Context(DC), Abbrev(DA), InfoSection(IS), RangeSection(RS), + : Kind(Kind), Context(DC), Abbrev(DA), InfoSection(IS), RangeSection(RS), StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS), RelocMap(M), isLittleEndian(LE) { clear();