Index: llvm/trunk/include/llvm/DebugInfo/DWARFAbbreviationDeclaration.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFAbbreviationDeclaration.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFAbbreviationDeclaration.h @@ -0,0 +1,60 @@ +//===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H +#define LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/DataExtractor.h" + +namespace llvm { + +class raw_ostream; + +class DWARFAbbreviationDeclaration { + uint32_t Code; + uint32_t Tag; + bool HasChildren; + + struct AttributeSpec { + AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {} + uint16_t Attr; + uint16_t Form; + }; + typedef SmallVector AttributeSpecVector; + AttributeSpecVector AttributeSpecs; +public: + DWARFAbbreviationDeclaration(); + + uint32_t getCode() const { return Code; } + uint32_t getTag() const { return Tag; } + bool hasChildren() const { return HasChildren; } + + typedef iterator_range + attr_iterator_range; + + attr_iterator_range attributes() const { + return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); + } + + uint16_t getFormByIndex(uint32_t idx) const { + return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0; + } + + uint32_t findAttributeIndex(uint16_t attr) const; + bool extract(DataExtractor Data, uint32_t* OffsetPtr); + void dump(raw_ostream &OS) const; + +private: + void clear(); +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFAcceleratorTable.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFAcceleratorTable.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFAcceleratorTable.h @@ -0,0 +1,51 @@ +//===--- DWARFAcceleratorTable.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/DWARFRelocMap.h" + +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DWARFFormValue.h" + +#include + +namespace llvm { + +class DWARFAcceleratorTable { + + struct Header { + uint32_t Magic; + uint16_t Version; + uint16_t HashFunction; + uint32_t NumBuckets; + uint32_t NumHashes; + uint32_t HeaderDataLength; + }; + + struct HeaderData { + typedef uint16_t AtomType; + typedef uint16_t Form; + uint32_t DIEOffsetBase; + SmallVector, 3> Atoms; + }; + + struct Header Hdr; + struct HeaderData HdrData; + DataExtractor AccelSection; + DataExtractor StringSection; + const RelocAddrMap& Relocs; +public: + DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection, + const RelocAddrMap &Relocs) + : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {} + + bool extract(); + void dump(raw_ostream &OS) const; +}; + +} Index: llvm/trunk/include/llvm/DebugInfo/DWARFCompileUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFCompileUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFCompileUnit.h @@ -0,0 +1,31 @@ +//===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H +#define LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H + +#include "llvm/DebugInfo/DWARFUnit.h" + +namespace llvm { + +class DWARFCompileUnit : public DWARFUnit { +public: + DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, + StringRef SOS, StringRef AOS, bool LE, + const DWARFUnitSectionBase &UnitSection) + : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {} + void dump(raw_ostream &OS); + // VTable anchor. + ~DWARFCompileUnit() override; +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFContext.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFContext.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFContext.h @@ -0,0 +1,292 @@ +//===-- DWARFContext.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===/ + +#ifndef LLVM_LIB_DEBUGINFO_DWARFCONTEXT_H +#define LLVM_LIB_DEBUGINFO_DWARFCONTEXT_H + +#include "llvm/ADT/MapVector.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARFDebugAranges.h" +#include "llvm/DebugInfo/DWARFDebugFrame.h" +#include "llvm/DebugInfo/DWARFDebugLine.h" +#include "llvm/DebugInfo/DWARFDebugLoc.h" +#include "llvm/DebugInfo/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARFSection.h" +#include "llvm/DebugInfo/DWARFTypeUnit.h" +#include "llvm/DebugInfo/DIContext.h" +#include + +namespace llvm { + +/// DWARFContext +/// This data structure is the top level entity that deals with dwarf debug +/// information parsing. The actual data is supplied through pure virtual +/// methods that a concrete implementation provides. +class DWARFContext : public DIContext { + + DWARFUnitSection CUs; + std::vector> TUs; + std::unique_ptr Abbrev; + std::unique_ptr Loc; + std::unique_ptr Aranges; + std::unique_ptr Line; + std::unique_ptr DebugFrame; + + DWARFUnitSection DWOCUs; + std::vector> DWOTUs; + std::unique_ptr AbbrevDWO; + std::unique_ptr LocDWO; + + DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION; + DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION; + + /// Read compile units from the debug_info section (if necessary) + /// and store them in CUs. + void parseCompileUnits(); + + /// Read type units from the debug_types sections (if necessary) + /// and store them in TUs. + void parseTypeUnits(); + + /// Read compile units from the debug_info.dwo section (if necessary) + /// and store them in DWOCUs. + void parseDWOCompileUnits(); + + /// Read type units from the debug_types.dwo section (if necessary) + /// and store them in DWOTUs. + void parseDWOTypeUnits(); + +public: + DWARFContext() : DIContext(CK_DWARF) {} + + static bool classof(const DIContext *DICtx) { + return DICtx->getKind() == CK_DWARF; + } + + void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override; + + typedef DWARFUnitSection::iterator_range cu_iterator_range; + typedef DWARFUnitSection::iterator_range tu_iterator_range; + typedef iterator_range>::iterator> tu_section_iterator_range; + + /// Get compile units in this context. + cu_iterator_range compile_units() { + parseCompileUnits(); + return cu_iterator_range(CUs.begin(), CUs.end()); + } + + /// Get type units in this context. + tu_section_iterator_range type_unit_sections() { + parseTypeUnits(); + return tu_section_iterator_range(TUs.begin(), TUs.end()); + } + + /// Get compile units in the DWO context. + cu_iterator_range dwo_compile_units() { + parseDWOCompileUnits(); + return cu_iterator_range(DWOCUs.begin(), DWOCUs.end()); + } + + /// Get type units in the DWO context. + tu_section_iterator_range dwo_type_unit_sections() { + parseDWOTypeUnits(); + return tu_section_iterator_range(DWOTUs.begin(), DWOTUs.end()); + } + + /// Get the number of compile units in this context. + unsigned getNumCompileUnits() { + parseCompileUnits(); + return CUs.size(); + } + + /// Get the number of compile units in this context. + unsigned getNumTypeUnits() { + parseTypeUnits(); + return TUs.size(); + } + + /// Get the number of compile units in the DWO context. + unsigned getNumDWOCompileUnits() { + parseDWOCompileUnits(); + return DWOCUs.size(); + } + + /// Get the number of compile units in the DWO context. + unsigned getNumDWOTypeUnits() { + parseDWOTypeUnits(); + return DWOTUs.size(); + } + + /// Get the compile unit at the specified index for this compile unit. + DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) { + parseCompileUnits(); + return CUs[index].get(); + } + + /// Get the compile unit at the specified index for the DWO compile units. + DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) { + parseDWOCompileUnits(); + return DWOCUs[index].get(); + } + + /// Get a pointer to the parsed DebugAbbrev object. + const DWARFDebugAbbrev *getDebugAbbrev(); + + /// Get a pointer to the parsed DebugLoc object. + const DWARFDebugLoc *getDebugLoc(); + + /// Get a pointer to the parsed dwo abbreviations object. + const DWARFDebugAbbrev *getDebugAbbrevDWO(); + + /// Get a pointer to the parsed DebugLoc object. + const DWARFDebugLocDWO *getDebugLocDWO(); + + /// Get a pointer to the parsed DebugAranges object. + const DWARFDebugAranges *getDebugAranges(); + + /// Get a pointer to the parsed frame information object. + const DWARFDebugFrame *getDebugFrame(); + + /// Get a pointer to a parsed line table corresponding to a compile unit. + const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu); + + DILineInfo getLineInfoForAddress(uint64_t Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DIInliningInfo getInliningInfoForAddress(uint64_t Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + + virtual bool isLittleEndian() const = 0; + virtual uint8_t getAddressSize() const = 0; + virtual const DWARFSection &getInfoSection() = 0; + typedef MapVector> TypeSectionMap; + virtual const TypeSectionMap &getTypesSections() = 0; + virtual StringRef getAbbrevSection() = 0; + virtual const DWARFSection &getLocSection() = 0; + virtual StringRef getARangeSection() = 0; + virtual StringRef getDebugFrameSection() = 0; + virtual const DWARFSection &getLineSection() = 0; + virtual StringRef getStringSection() = 0; + virtual StringRef getRangeSection() = 0; + virtual StringRef getPubNamesSection() = 0; + virtual StringRef getPubTypesSection() = 0; + virtual StringRef getGnuPubNamesSection() = 0; + virtual StringRef getGnuPubTypesSection() = 0; + + // Sections for DWARF5 split dwarf proposal. + virtual const DWARFSection &getInfoDWOSection() = 0; + virtual const TypeSectionMap &getTypesDWOSections() = 0; + virtual StringRef getAbbrevDWOSection() = 0; + virtual const DWARFSection &getLineDWOSection() = 0; + virtual const DWARFSection &getLocDWOSection() = 0; + virtual StringRef getStringDWOSection() = 0; + virtual StringRef getStringOffsetDWOSection() = 0; + virtual StringRef getRangeDWOSection() = 0; + virtual StringRef getAddrSection() = 0; + virtual const DWARFSection& getAppleNamesSection() = 0; + virtual const DWARFSection& getAppleTypesSection() = 0; + virtual const DWARFSection& getAppleNamespacesSection() = 0; + virtual const DWARFSection& getAppleObjCSection() = 0; + + static bool isSupportedVersion(unsigned version) { + return version == 2 || version == 3 || version == 4; + } +private: + /// Return the compile unit that includes an offset (relative to .debug_info). + DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset); + + /// Return the compile unit which contains instruction with provided + /// address. + DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address); +}; + +/// DWARFContextInMemory is the simplest possible implementation of a +/// DWARFContext. It assumes all content is available in memory and stores +/// pointers to it. +class DWARFContextInMemory : public DWARFContext { + virtual void anchor(); + bool IsLittleEndian; + uint8_t AddressSize; + DWARFSection InfoSection; + TypeSectionMap TypesSections; + StringRef AbbrevSection; + DWARFSection LocSection; + StringRef ARangeSection; + StringRef DebugFrameSection; + DWARFSection LineSection; + StringRef StringSection; + StringRef RangeSection; + StringRef PubNamesSection; + StringRef PubTypesSection; + StringRef GnuPubNamesSection; + StringRef GnuPubTypesSection; + + // Sections for DWARF5 split dwarf proposal. + DWARFSection InfoDWOSection; + TypeSectionMap TypesDWOSections; + StringRef AbbrevDWOSection; + DWARFSection LineDWOSection; + DWARFSection LocDWOSection; + StringRef StringDWOSection; + StringRef StringOffsetDWOSection; + StringRef RangeDWOSection; + StringRef AddrSection; + DWARFSection AppleNamesSection; + DWARFSection AppleTypesSection; + DWARFSection AppleNamespacesSection; + DWARFSection AppleObjCSection; + + SmallVector, 4> UncompressedSections; + +public: + DWARFContextInMemory(const object::ObjectFile &Obj); + bool isLittleEndian() const override { return IsLittleEndian; } + uint8_t getAddressSize() const override { return AddressSize; } + const DWARFSection &getInfoSection() override { return InfoSection; } + const TypeSectionMap &getTypesSections() override { return TypesSections; } + StringRef getAbbrevSection() override { return AbbrevSection; } + const DWARFSection &getLocSection() override { return LocSection; } + StringRef getARangeSection() override { return ARangeSection; } + StringRef getDebugFrameSection() override { return DebugFrameSection; } + const DWARFSection &getLineSection() override { return LineSection; } + StringRef getStringSection() override { return StringSection; } + StringRef getRangeSection() override { return RangeSection; } + StringRef getPubNamesSection() override { return PubNamesSection; } + StringRef getPubTypesSection() override { return PubTypesSection; } + StringRef getGnuPubNamesSection() override { return GnuPubNamesSection; } + StringRef getGnuPubTypesSection() override { return GnuPubTypesSection; } + const DWARFSection& getAppleNamesSection() override { return AppleNamesSection; } + const DWARFSection& getAppleTypesSection() override { return AppleTypesSection; } + const DWARFSection& getAppleNamespacesSection() override { return AppleNamespacesSection; } + const DWARFSection& getAppleObjCSection() override { return AppleObjCSection; } + + // Sections for DWARF5 split dwarf proposal. + const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; } + const TypeSectionMap &getTypesDWOSections() override { + return TypesDWOSections; + } + StringRef getAbbrevDWOSection() override { return AbbrevDWOSection; } + const DWARFSection &getLineDWOSection() override { return LineDWOSection; } + const DWARFSection &getLocDWOSection() override { return LocDWOSection; } + StringRef getStringDWOSection() override { return StringDWOSection; } + StringRef getStringOffsetDWOSection() override { + return StringOffsetDWOSection; + } + StringRef getRangeDWOSection() override { return RangeDWOSection; } + StringRef getAddrSection() override { + return AddrSection; + } +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugAbbrev.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugAbbrev.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugAbbrev.h @@ -0,0 +1,63 @@ +//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H + +#include "llvm/DebugInfo/DWARFAbbreviationDeclaration.h" +#include +#include +#include + +namespace llvm { + +class DWARFAbbreviationDeclarationSet { + uint32_t Offset; + /// Code of the first abbreviation, if all abbreviations in the set have + /// consecutive codes. UINT32_MAX otherwise. + uint32_t FirstAbbrCode; + std::vector Decls; + +public: + DWARFAbbreviationDeclarationSet(); + + uint32_t getOffset() const { return Offset; } + void dump(raw_ostream &OS) const; + bool extract(DataExtractor Data, uint32_t *OffsetPtr); + + const DWARFAbbreviationDeclaration * + getAbbreviationDeclaration(uint32_t AbbrCode) const; + +private: + void clear(); +}; + +class DWARFDebugAbbrev { + typedef std::map + DWARFAbbreviationDeclarationSetMap; + + DWARFAbbreviationDeclarationSetMap AbbrDeclSets; + mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; + +public: + DWARFDebugAbbrev(); + + const DWARFAbbreviationDeclarationSet * + getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const; + + void dump(raw_ostream &OS) const; + void extract(DataExtractor Data); + +private: + void clear(); +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugArangeSet.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugArangeSet.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugArangeSet.h @@ -0,0 +1,70 @@ +//===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H + +#include "llvm/ADT/iterator_range.h" +#include "llvm/Support/DataExtractor.h" +#include + +namespace llvm { + +class raw_ostream; + +class DWARFDebugArangeSet { +public: + struct Header { + // The total length of the entries for that set, not including the length + // field itself. + uint32_t Length; + // The offset from the beginning of the .debug_info section of the + // compilation unit entry referenced by the table. + uint32_t CuOffset; + // The DWARF version number. + uint16_t Version; + // The size in bytes of an address on the target architecture. For segmented + // addressing, this is the size of the offset portion of the address. + uint8_t AddrSize; + // The size in bytes of a segment descriptor on the target architecture. + // If the target system uses a flat address space, this value is 0. + uint8_t SegSize; + }; + + struct Descriptor { + uint64_t Address; + uint64_t Length; + uint64_t getEndAddress() const { return Address + Length; } + }; + +private: + typedef std::vector DescriptorColl; + typedef iterator_range desc_iterator_range; + + uint32_t Offset; + Header HeaderData; + DescriptorColl ArangeDescriptors; + +public: + DWARFDebugArangeSet() { clear(); } + void clear(); + bool extract(DataExtractor data, uint32_t *offset_ptr); + void dump(raw_ostream &OS) const; + + uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } + + desc_iterator_range descriptors() const { + return desc_iterator_range(ArangeDescriptors.begin(), + ArangeDescriptors.end()); + } +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugAranges.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugAranges.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugAranges.h @@ -0,0 +1,87 @@ +//===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H + +#include "llvm/ADT/DenseSet.h" +#include "llvm/Support/DataExtractor.h" +#include + +namespace llvm { + +class DWARFContext; + +class DWARFDebugAranges { +public: + void generate(DWARFContext *CTX); + uint32_t findAddress(uint64_t Address) const; + +private: + void clear(); + void extract(DataExtractor DebugArangesData); + + // Call appendRange multiple times and then call construct. + void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC); + void construct(); + + struct Range { + explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL, + uint32_t CUOffset = -1U) + : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {} + + void setHighPC(uint64_t HighPC) { + if (HighPC == -1ULL || HighPC <= LowPC) + Length = 0; + else + Length = HighPC - LowPC; + } + uint64_t HighPC() const { + if (Length) + return LowPC + Length; + return -1ULL; + } + + bool containsAddress(uint64_t Address) const { + return LowPC <= Address && Address < HighPC(); + } + bool operator<(const Range &other) const { + return LowPC < other.LowPC; + } + + uint64_t LowPC; // Start of address range. + uint32_t Length; // End of address range (not including this address). + uint32_t CUOffset; // Offset of the compile unit or die. + }; + + struct RangeEndpoint { + uint64_t Address; + uint32_t CUOffset; + bool IsRangeStart; + + RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart) + : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} + + bool operator<(const RangeEndpoint &Other) const { + return Address < Other.Address; + } + }; + + + typedef std::vector RangeColl; + typedef RangeColl::const_iterator RangeCollIterator; + + std::vector Endpoints; + RangeColl Aranges; + DenseSet ParsedCUOffsets; +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugFrame.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugFrame.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugFrame.h @@ -0,0 +1,43 @@ +//===-- DWARFDebugFrame.h - Parsing of .debug_frame -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGFRAME_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGFRAME_H + +#include "llvm/Support/DataExtractor.h" +#include "llvm/Support/raw_ostream.h" +#include +#include + +namespace llvm { + +class FrameEntry; + +/// \brief A parsed .debug_frame section +/// +class DWARFDebugFrame { +public: + DWARFDebugFrame(); + ~DWARFDebugFrame(); + + /// \brief Dump the section data into the given stream. + void dump(raw_ostream &OS) const; + + /// \brief Parse the section from raw data. + /// data is assumed to be pointing to the beginning of the section. + void parse(DataExtractor Data); + +private: + std::vector> Entries; +}; + + +} // namespace llvm + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugInfoEntry.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugInfoEntry.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugInfoEntry.h @@ -0,0 +1,160 @@ +//===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARFAbbreviationDeclaration.h" +#include "llvm/DebugInfo/DWARFDebugRangeList.h" +#include "llvm/Support/DataTypes.h" + +namespace llvm { + +class DWARFDebugAranges; +class DWARFCompileUnit; +class DWARFUnit; +class DWARFContext; +class DWARFFormValue; +struct DWARFDebugInfoEntryInlinedChain; + +/// DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data. +class DWARFDebugInfoEntryMinimal { + /// Offset within the .debug_info of the start of this entry. + uint32_t Offset; + + /// How many to add to "this" to get the sibling. + uint32_t SiblingIdx; + + const DWARFAbbreviationDeclaration *AbbrevDecl; +public: + DWARFDebugInfoEntryMinimal() + : Offset(0), SiblingIdx(0), AbbrevDecl(nullptr) {} + + void dump(raw_ostream &OS, DWARFUnit *u, unsigned recurseDepth, + unsigned indent = 0) const; + void dumpAttribute(raw_ostream &OS, DWARFUnit *u, uint32_t *offset_ptr, + uint16_t attr, uint16_t form, unsigned indent = 0) const; + + /// Extracts a debug info entry, which is a child of a given unit, + /// starting at a given offset. If DIE can't be extracted, returns false and + /// doesn't change OffsetPtr. + bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr); + + uint32_t getTag() const { return AbbrevDecl ? AbbrevDecl->getTag() : 0; } + bool isNULL() const { return AbbrevDecl == nullptr; } + + /// Returns true if DIE represents a subprogram (not inlined). + bool isSubprogramDIE() const; + /// Returns true if DIE represents a subprogram or an inlined + /// subroutine. + bool isSubroutineDIE() const; + + uint32_t getOffset() const { return Offset; } + bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); } + + // We know we are kept in a vector of contiguous entries, so we know + // our sibling will be some index after "this". + const DWARFDebugInfoEntryMinimal *getSibling() const { + return SiblingIdx > 0 ? this + SiblingIdx : nullptr; + } + + // We know we are kept in a vector of contiguous entries, so we know + // we don't need to store our child pointer, if we have a child it will + // be the next entry in the list... + const DWARFDebugInfoEntryMinimal *getFirstChild() const { + return hasChildren() ? this + 1 : nullptr; + } + + void setSibling(const DWARFDebugInfoEntryMinimal *Sibling) { + if (Sibling) { + // We know we are kept in a vector of contiguous entries, so we know + // our sibling will be some index after "this". + SiblingIdx = Sibling - this; + } else + SiblingIdx = 0; + } + + const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { + return AbbrevDecl; + } + + bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr, + DWARFFormValue &FormValue) const; + + const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr, + const char *FailValue) const; + + uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr, + uint64_t FailValue) const; + + uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U, + const uint16_t Attr, + uint64_t FailValue) const; + + uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr, + uint64_t FailValue) const; + + uint64_t getAttributeValueAsSectionOffset(const DWARFUnit *U, + const uint16_t Attr, + uint64_t FailValue) const; + + uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const; + + /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. + /// Returns true if both attributes are present. + bool getLowAndHighPC(const DWARFUnit *U, uint64_t &LowPC, + uint64_t &HighPC) const; + + DWARFAddressRangesVector getAddressRanges(const DWARFUnit *U) const; + + void collectChildrenAddressRanges(const DWARFUnit *U, + DWARFAddressRangesVector &Ranges) const; + + bool addressRangeContainsAddress(const DWARFUnit *U, + const uint64_t Address) const; + + /// If a DIE represents a subprogram (or inlined subroutine), + /// returns its mangled name (or short name, if mangled is missing). + /// This name may be fetched from specification or abstract origin + /// for this subprogram. Returns null if no name is found. + const char *getSubroutineName(const DWARFUnit *U, DINameKind Kind) const; + + /// Return the DIE name resolving DW_AT_sepcification or + /// DW_AT_abstract_origin references if necessary. + /// Returns null if no name is found. + const char *getName(const DWARFUnit *U, DINameKind Kind) const; + + /// Retrieves values of DW_AT_call_file, DW_AT_call_line and + /// DW_AT_call_column from DIE (or zeroes if they are missing). + void getCallerFrame(const DWARFUnit *U, uint32_t &CallFile, + uint32_t &CallLine, uint32_t &CallColumn) const; + + /// Get inlined chain for a given address, rooted at the current DIE. + /// Returns empty chain if address is not contained in address range + /// of current DIE. + DWARFDebugInfoEntryInlinedChain + getInlinedChainForAddress(const DWARFUnit *U, const uint64_t Address) const; +}; + +/// DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine +/// DIEs, (possibly ending with subprogram DIE), all of which are contained +/// in some concrete inlined instance tree. Address range for each DIE +/// (except the last DIE) in this chain is contained in address +/// range for next DIE in the chain. +struct DWARFDebugInfoEntryInlinedChain { + DWARFDebugInfoEntryInlinedChain() : U(nullptr) {} + SmallVector DIEs; + const DWARFUnit *U; +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugLine.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugLine.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugLine.h @@ -0,0 +1,238 @@ +//===-- DWARFDebugLine.h ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H + +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARFRelocMap.h" +#include "llvm/Support/DataExtractor.h" +#include +#include +#include + +namespace llvm { + +class raw_ostream; + +class DWARFDebugLine { +public: + DWARFDebugLine(const RelocAddrMap* LineInfoRelocMap) : RelocMap(LineInfoRelocMap) {} + struct FileNameEntry { + FileNameEntry() : Name(nullptr), DirIdx(0), ModTime(0), Length(0) {} + + const char *Name; + uint64_t DirIdx; + uint64_t ModTime; + uint64_t Length; + }; + + struct Prologue { + Prologue(); + + // The size in bytes of the statement information for this compilation unit + // (not including the total_length field itself). + uint32_t TotalLength; + // Version identifier for the statement information format. + uint16_t Version; + // The number of bytes following the prologue_length field to the beginning + // of the first byte of the statement program itself. + uint32_t PrologueLength; + // The size in bytes of the smallest target machine instruction. Statement + // program opcodes that alter the address register first multiply their + // operands by this value. + uint8_t MinInstLength; + // The maximum number of individual operations that may be encoded in an + // instruction. + uint8_t MaxOpsPerInst; + // The initial value of theis_stmtregister. + uint8_t DefaultIsStmt; + // This parameter affects the meaning of the special opcodes. See below. + int8_t LineBase; + // This parameter affects the meaning of the special opcodes. See below. + uint8_t LineRange; + // The number assigned to the first special opcode. + uint8_t OpcodeBase; + std::vector StandardOpcodeLengths; + std::vector IncludeDirectories; + std::vector FileNames; + + // Length of the prologue in bytes. + uint32_t getLength() const { + return PrologueLength + sizeof(TotalLength) + sizeof(Version) + + sizeof(PrologueLength); + } + // Length of the line table data in bytes (not including the prologue). + uint32_t getStatementTableLength() const { + return TotalLength + sizeof(TotalLength) - getLength(); + } + int32_t getMaxLineIncrementForSpecialOpcode() const { + return LineBase + (int8_t)LineRange - 1; + } + + void clear(); + void dump(raw_ostream &OS) const; + bool parse(DataExtractor debug_line_data, uint32_t *offset_ptr); + }; + + // Standard .debug_line state machine structure. + struct Row { + explicit Row(bool default_is_stmt = false); + + /// Called after a row is appended to the matrix. + void postAppend(); + void reset(bool default_is_stmt); + void dump(raw_ostream &OS) const; + + static bool orderByAddress(const Row& LHS, const Row& RHS) { + return LHS.Address < RHS.Address; + } + + // The program-counter value corresponding to a machine instruction + // generated by the compiler. + uint64_t Address; + // An unsigned integer indicating a source line number. Lines are numbered + // beginning at 1. The compiler may emit the value 0 in cases where an + // instruction cannot be attributed to any source line. + uint32_t Line; + // An unsigned integer indicating a column number within a source line. + // Columns are numbered beginning at 1. The value 0 is reserved to indicate + // that a statement begins at the 'left edge' of the line. + uint16_t Column; + // An unsigned integer indicating the identity of the source file + // corresponding to a machine instruction. + uint16_t File; + // An unsigned integer whose value encodes the applicable instruction set + // architecture for the current instruction. + uint8_t Isa; + // An unsigned integer representing the DWARF path discriminator value + // for this location. + uint32_t Discriminator; + // A boolean indicating that the current instruction is the beginning of a + // statement. + uint8_t IsStmt:1, + // A boolean indicating that the current instruction is the + // beginning of a basic block. + BasicBlock:1, + // A boolean indicating that the current address is that of the + // first byte after the end of a sequence of target machine + // instructions. + EndSequence:1, + // A boolean indicating that the current address is one (of possibly + // many) where execution should be suspended for an entry breakpoint + // of a function. + PrologueEnd:1, + // A boolean indicating that the current address is one (of possibly + // many) where execution should be suspended for an exit breakpoint + // of a function. + EpilogueBegin:1; + }; + + // Represents a series of contiguous machine instructions. Line table for each + // compilation unit may consist of multiple sequences, which are not + // guaranteed to be in the order of ascending instruction address. + struct Sequence { + // Sequence describes instructions at address range [LowPC, HighPC) + // and is described by line table rows [FirstRowIndex, LastRowIndex). + uint64_t LowPC; + uint64_t HighPC; + unsigned FirstRowIndex; + unsigned LastRowIndex; + bool Empty; + + Sequence(); + void reset(); + + static bool orderByLowPC(const Sequence& LHS, const Sequence& RHS) { + return LHS.LowPC < RHS.LowPC; + } + bool isValid() const { + return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex); + } + bool containsPC(uint64_t pc) const { + return (LowPC <= pc && pc < HighPC); + } + }; + + struct LineTable { + LineTable(); + + void appendRow(const DWARFDebugLine::Row &R) { + Rows.push_back(R); + } + void appendSequence(const DWARFDebugLine::Sequence &S) { + Sequences.push_back(S); + } + + // Returns the index of the row with file/line info for a given address, + // or -1 if there is no such row. + uint32_t lookupAddress(uint64_t address) const; + + bool lookupAddressRange(uint64_t address, uint64_t size, + std::vector &result) const; + + // Extracts filename by its index in filename table in prologue. + // Returns true on success. + bool getFileNameByIndex(uint64_t FileIndex, const char *CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + std::string &Result) const; + + // Fills the Result argument with the file and line information + // corresponding to Address. Returns true on success. + bool getFileLineInfoForAddress(uint64_t Address, const char *CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + DILineInfo &Result) const; + + void dump(raw_ostream &OS) const; + void clear(); + + /// Parse prologue and all rows. + bool parse(DataExtractor debug_line_data, const RelocAddrMap *RMap, + uint32_t *offset_ptr); + + struct Prologue Prologue; + typedef std::vector RowVector; + typedef RowVector::const_iterator RowIter; + typedef std::vector SequenceVector; + typedef SequenceVector::const_iterator SequenceIter; + RowVector Rows; + SequenceVector Sequences; + }; + + const LineTable *getLineTable(uint32_t offset) const; + const LineTable *getOrParseLineTable(DataExtractor debug_line_data, + uint32_t offset); + +private: + struct ParsingState { + ParsingState(struct LineTable *LT); + + void resetRowAndSequence(); + void appendRowToMatrix(uint32_t offset); + + // Line table we're currently parsing. + struct LineTable *LineTable; + // The row number that starts at zero for the prologue, and increases for + // each row added to the matrix. + unsigned RowNumber; + struct Row Row; + struct Sequence Sequence; + }; + + typedef std::map LineTableMapTy; + typedef LineTableMapTy::iterator LineTableIter; + typedef LineTableMapTy::const_iterator LineTableConstIter; + + const RelocAddrMap *RelocMap; + LineTableMapTy LineTableMap; +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugLoc.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugLoc.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugLoc.h @@ -0,0 +1,81 @@ +//===-- DWARFDebugLoc.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DWARFRelocMap.h" +#include "llvm/Support/DataExtractor.h" + +namespace llvm { + +class raw_ostream; + +class DWARFDebugLoc { + /// A single location within a location list. + struct Entry { + /// The beginning address of the instruction range. + uint64_t Begin; + /// The ending address of the instruction range. + uint64_t End; + /// The location of the variable within the specified range. + SmallVector Loc; + }; + + /// A list of locations that contain one variable. + struct LocationList { + /// The beginning offset where this location list is stored in the debug_loc + /// section. + unsigned Offset; + /// All the locations in which the variable is stored. + SmallVector Entries; + }; + + typedef SmallVector LocationLists; + + /// A list of all the variables in the debug_loc section, each one describing + /// the locations in which the variable is stored. + LocationLists Locations; + + /// A map used to resolve binary relocations. + const RelocAddrMap &RelocMap; + +public: + DWARFDebugLoc(const RelocAddrMap &LocRelocMap) : RelocMap(LocRelocMap) {} + /// Print the location lists found within the debug_loc section. + void dump(raw_ostream &OS) const; + /// Parse the debug_loc section accessible via the 'data' parameter using the + /// specified address size to interpret the address ranges. + void parse(DataExtractor data, unsigned AddressSize); +}; + +class DWARFDebugLocDWO { + struct Entry { + uint64_t Start; + uint32_t Length; + SmallVector Loc; + }; + + struct LocationList { + unsigned Offset; + SmallVector Entries; + }; + + typedef SmallVector LocationLists; + + LocationLists Locations; + +public: + void parse(DataExtractor data); + void dump(raw_ostream &OS) const; +}; +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFDebugRangeList.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFDebugRangeList.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFDebugRangeList.h @@ -0,0 +1,77 @@ +//===-- DWARFDebugRangeList.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H +#define LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H + +#include "llvm/Support/DataExtractor.h" +#include + +namespace llvm { + +class raw_ostream; + +/// DWARFAddressRangesVector - represents a set of absolute address ranges. +typedef std::vector> DWARFAddressRangesVector; + +class DWARFDebugRangeList { +public: + struct RangeListEntry { + // A beginning address offset. This address offset has the size of an + // address and is relative to the applicable base address of the + // compilation unit referencing this range list. It marks the beginning + // of an address range. + uint64_t StartAddress; + // An ending address offset. This address offset again has the size of + // an address and is relative to the applicable base address of the + // compilation unit referencing this range list. It marks the first + // address past the end of the address range. The ending address must + // be greater than or equal to the beginning address. + uint64_t EndAddress; + // The end of any given range list is marked by an end of list entry, + // which consists of a 0 for the beginning address offset + // and a 0 for the ending address offset. + bool isEndOfListEntry() const { + return (StartAddress == 0) && (EndAddress == 0); + } + // A base address selection entry consists of: + // 1. The value of the largest representable address offset + // (for example, 0xffffffff when the size of an address is 32 bits). + // 2. An address, which defines the appropriate base address for + // use in interpreting the beginning and ending address offsets of + // subsequent entries of the location list. + bool isBaseAddressSelectionEntry(uint8_t AddressSize) const { + assert(AddressSize == 4 || AddressSize == 8); + if (AddressSize == 4) + return StartAddress == -1U; + else + return StartAddress == -1ULL; + } + }; + +private: + // Offset in .debug_ranges section. + uint32_t Offset; + uint8_t AddressSize; + std::vector Entries; + +public: + DWARFDebugRangeList() { clear(); } + void clear(); + void dump(raw_ostream &OS) const; + bool extract(DataExtractor data, uint32_t *offset_ptr); + /// getAbsoluteRanges - Returns absolute address ranges defined by this range + /// list. Has to be passed base address of the compile unit referencing this + /// range list. + DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const; +}; + +} // namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H Index: llvm/trunk/include/llvm/DebugInfo/DWARFRelocMap.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFRelocMap.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFRelocMap.h @@ -0,0 +1,22 @@ +//===-- DWARFRelocMap.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFRELOCMAP_H +#define LLVM_LIB_DEBUGINFO_DWARFRELOCMAP_H + +#include "llvm/ADT/DenseMap.h" + +namespace llvm { + +typedef DenseMap > RelocAddrMap; + +} // namespace llvm + +#endif + Index: llvm/trunk/include/llvm/DebugInfo/DWARFSection.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFSection.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFSection.h @@ -0,0 +1,24 @@ +//===-- DWARFSection.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFSECTION_H +#define LLVM_LIB_DEBUGINFO_DWARFSECTION_H + +#include "llvm/DebugInfo/DWARFRelocMap.h" + +namespace llvm { + +struct DWARFSection { + StringRef Data; + RelocAddrMap Relocs; +}; + +} + +#endif Index: llvm/trunk/include/llvm/DebugInfo/DWARFTypeUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFTypeUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFTypeUnit.h @@ -0,0 +1,38 @@ +//===-- DWARFTypeUnit.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFTYPEUNIT_H +#define LLVM_LIB_DEBUGINFO_DWARFTYPEUNIT_H + +#include "llvm/DebugInfo/DWARFUnit.h" + +namespace llvm { + +class DWARFTypeUnit : public DWARFUnit { +private: + uint64_t TypeHash; + uint32_t TypeOffset; +public: + DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, + StringRef SOS, StringRef AOS, bool LE, + const DWARFUnitSectionBase &UnitSection) + : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {} + uint32_t getHeaderSize() const override { + return DWARFUnit::getHeaderSize() + 12; + } + void dump(raw_ostream &OS); +protected: + bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) override; +}; + +} + +#endif + Index: llvm/trunk/include/llvm/DebugInfo/DWARFUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARFUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARFUnit.h @@ -0,0 +1,245 @@ +//===-- DWARFUnit.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DEBUGINFO_DWARFUNIT_H +#define LLVM_LIB_DEBUGINFO_DWARFUNIT_H + +#include "llvm/DebugInfo/DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARFDebugInfoEntry.h" +#include "llvm/DebugInfo/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARFRelocMap.h" +#include "llvm/DebugInfo/DWARFSection.h" +#include + +namespace llvm { + +namespace object { +class ObjectFile; +} + +class DWARFContext; +class DWARFDebugAbbrev; +class DWARFUnit; +class StringRef; +class raw_ostream; + +/// Base class for all DWARFUnitSection classes. This provides the +/// functionality common to all unit types. +class DWARFUnitSectionBase { +public: + /// Returns the Unit that contains the given section offset in the + /// same section this Unit originated from. + virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0; + + void parse(DWARFContext &C, const DWARFSection &Section); + void parseDWO(DWARFContext &C, const DWARFSection &DWOSection); + +protected: + virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, + const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, + StringRef SOS, StringRef AOS, bool isLittleEndian) = 0; + + ~DWARFUnitSectionBase() {} +}; + +/// Concrete instance of DWARFUnitSection, specialized for one Unit type. +template +class DWARFUnitSection final : public SmallVector, 1>, + public DWARFUnitSectionBase { + + struct UnitOffsetComparator { + bool operator()(uint32_t LHS, + const std::unique_ptr &RHS) const { + return LHS < RHS->getNextUnitOffset(); + } + }; + + bool Parsed; + +public: + DWARFUnitSection() : Parsed(false) {} + DWARFUnitSection(DWARFUnitSection &&DUS) : + SmallVector, 1>(std::move(DUS)), Parsed(DUS.Parsed) {} + + typedef llvm::SmallVectorImpl> UnitVector; + typedef typename UnitVector::iterator iterator; + typedef llvm::iterator_range iterator_range; + + UnitType *getUnitForOffset(uint32_t Offset) const override { + auto *CU = std::upper_bound(this->begin(), this->end(), Offset, + UnitOffsetComparator()); + if (CU != this->end()) + return CU->get(); + return nullptr; + } + +private: + void parseImpl(DWARFContext &Context, const DWARFSection &Section, + const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, + StringRef SOS, StringRef AOS, bool LE) override { + if (Parsed) + return; + DataExtractor Data(Section.Data, LE, 0); + uint32_t Offset = 0; + while (Data.isValidOffset(Offset)) { + auto U = llvm::make_unique(Context, Section, DA, RS, SS, SOS, + AOS, LE, *this); + if (!U->extract(Data, &Offset)) + break; + this->push_back(std::move(U)); + Offset = this->back()->getNextUnitOffset(); + } + Parsed = true; + } +}; + +class DWARFUnit { + DWARFContext &Context; + // Section containing this DWARFUnit. + const DWARFSection &InfoSection; + + const DWARFDebugAbbrev *Abbrev; + StringRef RangeSection; + uint32_t RangeSectionBase; + StringRef StringSection; + StringRef StringOffsetSection; + StringRef AddrOffsetSection; + uint32_t AddrOffsetSectionBase; + bool isLittleEndian; + const DWARFUnitSectionBase &UnitSection; + + uint32_t Offset; + uint32_t Length; + uint16_t Version; + const DWARFAbbreviationDeclarationSet *Abbrevs; + uint8_t AddrSize; + uint64_t BaseAddr; + // The compile unit debug information entry items. + std::vector DieArray; + + class DWOHolder { + object::OwningBinary DWOFile; + std::unique_ptr DWOContext; + DWARFUnit *DWOU; + public: + DWOHolder(StringRef DWOPath); + DWARFUnit *getUnit() const { return DWOU; } + }; + std::unique_ptr DWO; + +protected: + virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr); + /// Size in bytes of the unit header. + virtual uint32_t getHeaderSize() const { return 11; } + +public: + DWARFUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, + StringRef SOS, StringRef AOS, bool LE, + const DWARFUnitSectionBase &UnitSection); + + virtual ~DWARFUnit(); + + DWARFContext& getContext() const { return Context; } + + StringRef getStringSection() const { return StringSection; } + StringRef getStringOffsetSection() const { return StringOffsetSection; } + void setAddrOffsetSection(StringRef AOS, uint32_t Base) { + AddrOffsetSection = AOS; + AddrOffsetSectionBase = Base; + } + void setRangesSection(StringRef RS, uint32_t Base) { + RangeSection = RS; + RangeSectionBase = Base; + } + + bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const; + // FIXME: Result should be uint64_t in DWARF64. + bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const; + + DataExtractor getDebugInfoExtractor() const { + return DataExtractor(InfoSection.Data, isLittleEndian, AddrSize); + } + DataExtractor getStringExtractor() const { + return DataExtractor(StringSection, false, 0); + } + + const RelocAddrMap *getRelocMap() const { return &InfoSection.Relocs; } + + bool extract(DataExtractor debug_info, uint32_t* offset_ptr); + + /// extractRangeList - extracts the range list referenced by this compile + /// unit from .debug_ranges section. Returns true on success. + /// Requires that compile unit is already extracted. + bool extractRangeList(uint32_t RangeListOffset, + DWARFDebugRangeList &RangeList) const; + void clear(); + uint32_t getOffset() const { return Offset; } + uint32_t getNextUnitOffset() const { return Offset + Length + 4; } + uint32_t getLength() const { return Length; } + uint16_t getVersion() const { return Version; } + const DWARFAbbreviationDeclarationSet *getAbbreviations() const { + return Abbrevs; + } + uint8_t getAddressByteSize() const { return AddrSize; } + uint64_t getBaseAddress() const { return BaseAddr; } + + void setBaseAddress(uint64_t base_addr) { + BaseAddr = base_addr; + } + + const DWARFDebugInfoEntryMinimal * + getCompileUnitDIE(bool extract_cu_die_only = true) { + extractDIEsIfNeeded(extract_cu_die_only); + return DieArray.empty() ? nullptr : &DieArray[0]; + } + + const char *getCompilationDir(); + uint64_t getDWOId(); + + void collectAddressRanges(DWARFAddressRangesVector &CURanges); + + /// getInlinedChainForAddress - fetches inlined chain for a given address. + /// Returns empty chain if there is no subprogram containing address. The + /// chain is valid as long as parsed compile unit DIEs are not cleared. + DWARFDebugInfoEntryInlinedChain getInlinedChainForAddress(uint64_t Address); + + /// getUnitSection - Return the DWARFUnitSection containing this unit. + const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; } + +private: + /// Size in bytes of the .debug_info data associated with this compile unit. + size_t getDebugInfoSize() const { return Length + 4 - getHeaderSize(); } + + /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it + /// hasn't already been done. Returns the number of DIEs parsed at this call. + size_t extractDIEsIfNeeded(bool CUDieOnly); + /// extractDIEsToVector - Appends all parsed DIEs to a vector. + void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs, + std::vector &DIEs) const; + /// setDIERelations - We read in all of the DIE entries into our flat list + /// of DIE entries and now we need to go back through all of them and set the + /// parent, sibling and child pointers for quick DIE navigation. + void setDIERelations(); + /// clearDIEs - Clear parsed DIEs to keep memory usage low. + void clearDIEs(bool KeepCUDie); + + /// parseDWO - Parses .dwo file for current compile unit. Returns true if + /// it was actually constructed. + bool parseDWO(); + + /// getSubprogramForAddress - Returns subprogram DIE with address range + /// encompassing the provided address. The pointer is alive as long as parsed + /// compile unit DIEs are not cleared. + const DWARFDebugInfoEntryMinimal *getSubprogramForAddress(uint64_t Address); +}; + +} + +#endif Index: llvm/trunk/lib/DebugInfo/DIContext.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DIContext.cpp +++ llvm/trunk/lib/DebugInfo/DIContext.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DIContext.h" -#include "DWARFContext.h" +#include "llvm/DebugInfo/DWARFContext.h" using namespace llvm; DIContext::~DIContext() {} Index: llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h +++ llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.h @@ -1,60 +0,0 @@ -//===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H -#define LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/DataExtractor.h" - -namespace llvm { - -class raw_ostream; - -class DWARFAbbreviationDeclaration { - uint32_t Code; - uint32_t Tag; - bool HasChildren; - - struct AttributeSpec { - AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {} - uint16_t Attr; - uint16_t Form; - }; - typedef SmallVector AttributeSpecVector; - AttributeSpecVector AttributeSpecs; -public: - DWARFAbbreviationDeclaration(); - - uint32_t getCode() const { return Code; } - uint32_t getTag() const { return Tag; } - bool hasChildren() const { return HasChildren; } - - typedef iterator_range - attr_iterator_range; - - attr_iterator_range attributes() const { - return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); - } - - uint16_t getFormByIndex(uint32_t idx) const { - return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0; - } - - uint32_t findAttributeIndex(uint16_t attr) const; - bool extract(DataExtractor Data, uint32_t* OffsetPtr); - void dump(raw_ostream &OS) const; - -private: - void clear(); -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp +++ llvm/trunk/lib/DebugInfo/DWARFAbbreviationDeclaration.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFAbbreviationDeclaration.h" +#include "llvm/DebugInfo/DWARFAbbreviationDeclaration.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" Index: llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h +++ llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h @@ -1,51 +0,0 @@ -//===--- DWARFAcceleratorTable.h --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "DWARFRelocMap.h" - -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/DWARFFormValue.h" - -#include - -namespace llvm { - -class DWARFAcceleratorTable { - - struct Header { - uint32_t Magic; - uint16_t Version; - uint16_t HashFunction; - uint32_t NumBuckets; - uint32_t NumHashes; - uint32_t HeaderDataLength; - }; - - struct HeaderData { - typedef uint16_t AtomType; - typedef uint16_t Form; - uint32_t DIEOffsetBase; - SmallVector, 3> Atoms; - }; - - struct Header Hdr; - struct HeaderData HdrData; - DataExtractor AccelSection; - DataExtractor StringSection; - const RelocAddrMap& Relocs; -public: - DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection, - const RelocAddrMap &Relocs) - : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {} - - bool extract(); - void dump(raw_ostream &OS) const; -}; - -} Index: llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp +++ llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFAcceleratorTable.h" +#include "llvm/DebugInfo/DWARFAcceleratorTable.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" Index: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h +++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h @@ -1,31 +0,0 @@ -//===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H -#define LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H - -#include "DWARFUnit.h" - -namespace llvm { - -class DWARFCompileUnit : public DWARFUnit { -public: - DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, bool LE, - const DWARFUnitSectionBase &UnitSection) - : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {} - void dump(raw_ostream &OS); - // VTable anchor. - ~DWARFCompileUnit() override; -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARFCompileUnit.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" Index: llvm/trunk/lib/DebugInfo/DWARFContext.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFContext.h +++ llvm/trunk/lib/DebugInfo/DWARFContext.h @@ -1,292 +0,0 @@ -//===-- DWARFContext.h ------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===/ - -#ifndef LLVM_LIB_DEBUGINFO_DWARFCONTEXT_H -#define LLVM_LIB_DEBUGINFO_DWARFCONTEXT_H - -#include "DWARFCompileUnit.h" -#include "DWARFDebugAranges.h" -#include "DWARFDebugFrame.h" -#include "DWARFDebugLine.h" -#include "DWARFDebugLoc.h" -#include "DWARFDebugRangeList.h" -#include "DWARFSection.h" -#include "DWARFTypeUnit.h" -#include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/DIContext.h" -#include - -namespace llvm { - -/// DWARFContext -/// This data structure is the top level entity that deals with dwarf debug -/// information parsing. The actual data is supplied through pure virtual -/// methods that a concrete implementation provides. -class DWARFContext : public DIContext { - - DWARFUnitSection CUs; - std::vector> TUs; - std::unique_ptr Abbrev; - std::unique_ptr Loc; - std::unique_ptr Aranges; - std::unique_ptr Line; - std::unique_ptr DebugFrame; - - DWARFUnitSection DWOCUs; - std::vector> DWOTUs; - std::unique_ptr AbbrevDWO; - std::unique_ptr LocDWO; - - DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION; - DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION; - - /// Read compile units from the debug_info section (if necessary) - /// and store them in CUs. - void parseCompileUnits(); - - /// Read type units from the debug_types sections (if necessary) - /// and store them in TUs. - void parseTypeUnits(); - - /// Read compile units from the debug_info.dwo section (if necessary) - /// and store them in DWOCUs. - void parseDWOCompileUnits(); - - /// Read type units from the debug_types.dwo section (if necessary) - /// and store them in DWOTUs. - void parseDWOTypeUnits(); - -public: - DWARFContext() : DIContext(CK_DWARF) {} - - static bool classof(const DIContext *DICtx) { - return DICtx->getKind() == CK_DWARF; - } - - void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override; - - typedef DWARFUnitSection::iterator_range cu_iterator_range; - typedef DWARFUnitSection::iterator_range tu_iterator_range; - typedef iterator_range>::iterator> tu_section_iterator_range; - - /// Get compile units in this context. - cu_iterator_range compile_units() { - parseCompileUnits(); - return cu_iterator_range(CUs.begin(), CUs.end()); - } - - /// Get type units in this context. - tu_section_iterator_range type_unit_sections() { - parseTypeUnits(); - return tu_section_iterator_range(TUs.begin(), TUs.end()); - } - - /// Get compile units in the DWO context. - cu_iterator_range dwo_compile_units() { - parseDWOCompileUnits(); - return cu_iterator_range(DWOCUs.begin(), DWOCUs.end()); - } - - /// Get type units in the DWO context. - tu_section_iterator_range dwo_type_unit_sections() { - parseDWOTypeUnits(); - return tu_section_iterator_range(DWOTUs.begin(), DWOTUs.end()); - } - - /// Get the number of compile units in this context. - unsigned getNumCompileUnits() { - parseCompileUnits(); - return CUs.size(); - } - - /// Get the number of compile units in this context. - unsigned getNumTypeUnits() { - parseTypeUnits(); - return TUs.size(); - } - - /// Get the number of compile units in the DWO context. - unsigned getNumDWOCompileUnits() { - parseDWOCompileUnits(); - return DWOCUs.size(); - } - - /// Get the number of compile units in the DWO context. - unsigned getNumDWOTypeUnits() { - parseDWOTypeUnits(); - return DWOTUs.size(); - } - - /// Get the compile unit at the specified index for this compile unit. - DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) { - parseCompileUnits(); - return CUs[index].get(); - } - - /// Get the compile unit at the specified index for the DWO compile units. - DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) { - parseDWOCompileUnits(); - return DWOCUs[index].get(); - } - - /// Get a pointer to the parsed DebugAbbrev object. - const DWARFDebugAbbrev *getDebugAbbrev(); - - /// Get a pointer to the parsed DebugLoc object. - const DWARFDebugLoc *getDebugLoc(); - - /// Get a pointer to the parsed dwo abbreviations object. - const DWARFDebugAbbrev *getDebugAbbrevDWO(); - - /// Get a pointer to the parsed DebugLoc object. - const DWARFDebugLocDWO *getDebugLocDWO(); - - /// Get a pointer to the parsed DebugAranges object. - const DWARFDebugAranges *getDebugAranges(); - - /// Get a pointer to the parsed frame information object. - const DWARFDebugFrame *getDebugFrame(); - - /// Get a pointer to a parsed line table corresponding to a compile unit. - const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu); - - DILineInfo getLineInfoForAddress(uint64_t Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DIInliningInfo getInliningInfoForAddress(uint64_t Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - - virtual bool isLittleEndian() const = 0; - virtual uint8_t getAddressSize() const = 0; - virtual const DWARFSection &getInfoSection() = 0; - typedef MapVector> TypeSectionMap; - virtual const TypeSectionMap &getTypesSections() = 0; - virtual StringRef getAbbrevSection() = 0; - virtual const DWARFSection &getLocSection() = 0; - virtual StringRef getARangeSection() = 0; - virtual StringRef getDebugFrameSection() = 0; - virtual const DWARFSection &getLineSection() = 0; - virtual StringRef getStringSection() = 0; - virtual StringRef getRangeSection() = 0; - virtual StringRef getPubNamesSection() = 0; - virtual StringRef getPubTypesSection() = 0; - virtual StringRef getGnuPubNamesSection() = 0; - virtual StringRef getGnuPubTypesSection() = 0; - - // Sections for DWARF5 split dwarf proposal. - virtual const DWARFSection &getInfoDWOSection() = 0; - virtual const TypeSectionMap &getTypesDWOSections() = 0; - virtual StringRef getAbbrevDWOSection() = 0; - virtual const DWARFSection &getLineDWOSection() = 0; - virtual const DWARFSection &getLocDWOSection() = 0; - virtual StringRef getStringDWOSection() = 0; - virtual StringRef getStringOffsetDWOSection() = 0; - virtual StringRef getRangeDWOSection() = 0; - virtual StringRef getAddrSection() = 0; - virtual const DWARFSection& getAppleNamesSection() = 0; - virtual const DWARFSection& getAppleTypesSection() = 0; - virtual const DWARFSection& getAppleNamespacesSection() = 0; - virtual const DWARFSection& getAppleObjCSection() = 0; - - static bool isSupportedVersion(unsigned version) { - return version == 2 || version == 3 || version == 4; - } -private: - /// Return the compile unit that includes an offset (relative to .debug_info). - DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset); - - /// Return the compile unit which contains instruction with provided - /// address. - DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address); -}; - -/// DWARFContextInMemory is the simplest possible implementation of a -/// DWARFContext. It assumes all content is available in memory and stores -/// pointers to it. -class DWARFContextInMemory : public DWARFContext { - virtual void anchor(); - bool IsLittleEndian; - uint8_t AddressSize; - DWARFSection InfoSection; - TypeSectionMap TypesSections; - StringRef AbbrevSection; - DWARFSection LocSection; - StringRef ARangeSection; - StringRef DebugFrameSection; - DWARFSection LineSection; - StringRef StringSection; - StringRef RangeSection; - StringRef PubNamesSection; - StringRef PubTypesSection; - StringRef GnuPubNamesSection; - StringRef GnuPubTypesSection; - - // Sections for DWARF5 split dwarf proposal. - DWARFSection InfoDWOSection; - TypeSectionMap TypesDWOSections; - StringRef AbbrevDWOSection; - DWARFSection LineDWOSection; - DWARFSection LocDWOSection; - StringRef StringDWOSection; - StringRef StringOffsetDWOSection; - StringRef RangeDWOSection; - StringRef AddrSection; - DWARFSection AppleNamesSection; - DWARFSection AppleTypesSection; - DWARFSection AppleNamespacesSection; - DWARFSection AppleObjCSection; - - SmallVector, 4> UncompressedSections; - -public: - DWARFContextInMemory(const object::ObjectFile &Obj); - bool isLittleEndian() const override { return IsLittleEndian; } - uint8_t getAddressSize() const override { return AddressSize; } - const DWARFSection &getInfoSection() override { return InfoSection; } - const TypeSectionMap &getTypesSections() override { return TypesSections; } - StringRef getAbbrevSection() override { return AbbrevSection; } - const DWARFSection &getLocSection() override { return LocSection; } - StringRef getARangeSection() override { return ARangeSection; } - StringRef getDebugFrameSection() override { return DebugFrameSection; } - const DWARFSection &getLineSection() override { return LineSection; } - StringRef getStringSection() override { return StringSection; } - StringRef getRangeSection() override { return RangeSection; } - StringRef getPubNamesSection() override { return PubNamesSection; } - StringRef getPubTypesSection() override { return PubTypesSection; } - StringRef getGnuPubNamesSection() override { return GnuPubNamesSection; } - StringRef getGnuPubTypesSection() override { return GnuPubTypesSection; } - const DWARFSection& getAppleNamesSection() override { return AppleNamesSection; } - const DWARFSection& getAppleTypesSection() override { return AppleTypesSection; } - const DWARFSection& getAppleNamespacesSection() override { return AppleNamespacesSection; } - const DWARFSection& getAppleObjCSection() override { return AppleObjCSection; } - - // Sections for DWARF5 split dwarf proposal. - const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; } - const TypeSectionMap &getTypesDWOSections() override { - return TypesDWOSections; - } - StringRef getAbbrevDWOSection() override { return AbbrevDWOSection; } - const DWARFSection &getLineDWOSection() override { return LineDWOSection; } - const DWARFSection &getLocDWOSection() override { return LocDWOSection; } - StringRef getStringDWOSection() override { return StringDWOSection; } - StringRef getStringOffsetDWOSection() override { - return StringOffsetDWOSection; - } - StringRef getRangeDWOSection() override { return RangeDWOSection; } - StringRef getAddrSection() override { - return AddrSection; - } -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFContext.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "DWARFContext.h" -#include "DWARFDebugArangeSet.h" -#include "DWARFAcceleratorTable.h" +#include "llvm/DebugInfo/DWARFContext.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/DebugInfo/DWARFDebugArangeSet.h" +#include "llvm/DebugInfo/DWARFAcceleratorTable.h" #include "llvm/Support/Compression.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" Index: llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.h @@ -1,63 +0,0 @@ -//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H - -#include "DWARFAbbreviationDeclaration.h" -#include -#include -#include - -namespace llvm { - -class DWARFAbbreviationDeclarationSet { - uint32_t Offset; - /// Code of the first abbreviation, if all abbreviations in the set have - /// consecutive codes. UINT32_MAX otherwise. - uint32_t FirstAbbrCode; - std::vector Decls; - -public: - DWARFAbbreviationDeclarationSet(); - - uint32_t getOffset() const { return Offset; } - void dump(raw_ostream &OS) const; - bool extract(DataExtractor Data, uint32_t *OffsetPtr); - - const DWARFAbbreviationDeclaration * - getAbbreviationDeclaration(uint32_t AbbrCode) const; - -private: - void clear(); -}; - -class DWARFDebugAbbrev { - typedef std::map - DWARFAbbreviationDeclarationSetMap; - - DWARFAbbreviationDeclarationSetMap AbbrDeclSets; - mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; - -public: - DWARFDebugAbbrev(); - - const DWARFAbbreviationDeclarationSet * - getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const; - - void dump(raw_ostream &OS) const; - void extract(DataExtractor Data); - -private: - void clear(); -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugAbbrev.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARFDebugAbbrev.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; Index: llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.h @@ -1,70 +0,0 @@ -//===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H - -#include "llvm/ADT/iterator_range.h" -#include "llvm/Support/DataExtractor.h" -#include - -namespace llvm { - -class raw_ostream; - -class DWARFDebugArangeSet { -public: - struct Header { - // The total length of the entries for that set, not including the length - // field itself. - uint32_t Length; - // The offset from the beginning of the .debug_info section of the - // compilation unit entry referenced by the table. - uint32_t CuOffset; - // The DWARF version number. - uint16_t Version; - // The size in bytes of an address on the target architecture. For segmented - // addressing, this is the size of the offset portion of the address. - uint8_t AddrSize; - // The size in bytes of a segment descriptor on the target architecture. - // If the target system uses a flat address space, this value is 0. - uint8_t SegSize; - }; - - struct Descriptor { - uint64_t Address; - uint64_t Length; - uint64_t getEndAddress() const { return Address + Length; } - }; - -private: - typedef std::vector DescriptorColl; - typedef iterator_range desc_iterator_range; - - uint32_t Offset; - Header HeaderData; - DescriptorColl ArangeDescriptors; - -public: - DWARFDebugArangeSet() { clear(); } - void clear(); - bool extract(DataExtractor data, uint32_t *offset_ptr); - void dump(raw_ostream &OS) const; - - uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } - - desc_iterator_range descriptors() const { - return desc_iterator_range(ArangeDescriptors.begin(), - ArangeDescriptors.end()); - } -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugArangeSet.h" +#include "llvm/DebugInfo/DWARFDebugArangeSet.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" #include Index: llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h @@ -1,87 +0,0 @@ -//===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H - -#include "llvm/ADT/DenseSet.h" -#include "llvm/Support/DataExtractor.h" -#include - -namespace llvm { - -class DWARFContext; - -class DWARFDebugAranges { -public: - void generate(DWARFContext *CTX); - uint32_t findAddress(uint64_t Address) const; - -private: - void clear(); - void extract(DataExtractor DebugArangesData); - - // Call appendRange multiple times and then call construct. - void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC); - void construct(); - - struct Range { - explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL, - uint32_t CUOffset = -1U) - : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {} - - void setHighPC(uint64_t HighPC) { - if (HighPC == -1ULL || HighPC <= LowPC) - Length = 0; - else - Length = HighPC - LowPC; - } - uint64_t HighPC() const { - if (Length) - return LowPC + Length; - return -1ULL; - } - - bool containsAddress(uint64_t Address) const { - return LowPC <= Address && Address < HighPC(); - } - bool operator<(const Range &other) const { - return LowPC < other.LowPC; - } - - uint64_t LowPC; // Start of address range. - uint32_t Length; // End of address range (not including this address). - uint32_t CUOffset; // Offset of the compile unit or die. - }; - - struct RangeEndpoint { - uint64_t Address; - uint32_t CUOffset; - bool IsRangeStart; - - RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart) - : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} - - bool operator<(const RangeEndpoint &Other) const { - return Address < Other.Address; - } - }; - - - typedef std::vector RangeColl; - typedef RangeColl::const_iterator RangeCollIterator; - - std::vector Endpoints; - RangeColl Aranges; - DenseSet ParsedCUOffsets; -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugAranges.h" -#include "DWARFCompileUnit.h" -#include "DWARFContext.h" -#include "DWARFDebugArangeSet.h" +#include "llvm/DebugInfo/DWARFDebugAranges.h" +#include "llvm/DebugInfo/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARFContext.h" +#include "llvm/DebugInfo/DWARFDebugArangeSet.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" #include Index: llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugFrame.h @@ -1,43 +0,0 @@ -//===-- DWARFDebugFrame.h - Parsing of .debug_frame -------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGFRAME_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGFRAME_H - -#include "llvm/Support/DataExtractor.h" -#include "llvm/Support/raw_ostream.h" -#include -#include - -namespace llvm { - -class FrameEntry; - -/// \brief A parsed .debug_frame section -/// -class DWARFDebugFrame { -public: - DWARFDebugFrame(); - ~DWARFDebugFrame(); - - /// \brief Dump the section data into the given stream. - void dump(raw_ostream &OS) const; - - /// \brief Parse the section from raw data. - /// data is assumed to be pointing to the beginning of the section. - void parse(DataExtractor Data); - -private: - std::vector> Entries; -}; - - -} // namespace llvm - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugFrame.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugFrame.h" +#include "llvm/DebugInfo/DWARFDebugFrame.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Dwarf.h" Index: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h @@ -1,160 +0,0 @@ -//===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H - -#include "DWARFAbbreviationDeclaration.h" -#include "DWARFDebugRangeList.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/Support/DataTypes.h" - -namespace llvm { - -class DWARFDebugAranges; -class DWARFCompileUnit; -class DWARFUnit; -class DWARFContext; -class DWARFFormValue; -struct DWARFDebugInfoEntryInlinedChain; - -/// DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data. -class DWARFDebugInfoEntryMinimal { - /// Offset within the .debug_info of the start of this entry. - uint32_t Offset; - - /// How many to add to "this" to get the sibling. - uint32_t SiblingIdx; - - const DWARFAbbreviationDeclaration *AbbrevDecl; -public: - DWARFDebugInfoEntryMinimal() - : Offset(0), SiblingIdx(0), AbbrevDecl(nullptr) {} - - void dump(raw_ostream &OS, DWARFUnit *u, unsigned recurseDepth, - unsigned indent = 0) const; - void dumpAttribute(raw_ostream &OS, DWARFUnit *u, uint32_t *offset_ptr, - uint16_t attr, uint16_t form, unsigned indent = 0) const; - - /// Extracts a debug info entry, which is a child of a given unit, - /// starting at a given offset. If DIE can't be extracted, returns false and - /// doesn't change OffsetPtr. - bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr); - - uint32_t getTag() const { return AbbrevDecl ? AbbrevDecl->getTag() : 0; } - bool isNULL() const { return AbbrevDecl == nullptr; } - - /// Returns true if DIE represents a subprogram (not inlined). - bool isSubprogramDIE() const; - /// Returns true if DIE represents a subprogram or an inlined - /// subroutine. - bool isSubroutineDIE() const; - - uint32_t getOffset() const { return Offset; } - bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); } - - // We know we are kept in a vector of contiguous entries, so we know - // our sibling will be some index after "this". - const DWARFDebugInfoEntryMinimal *getSibling() const { - return SiblingIdx > 0 ? this + SiblingIdx : nullptr; - } - - // We know we are kept in a vector of contiguous entries, so we know - // we don't need to store our child pointer, if we have a child it will - // be the next entry in the list... - const DWARFDebugInfoEntryMinimal *getFirstChild() const { - return hasChildren() ? this + 1 : nullptr; - } - - void setSibling(const DWARFDebugInfoEntryMinimal *Sibling) { - if (Sibling) { - // We know we are kept in a vector of contiguous entries, so we know - // our sibling will be some index after "this". - SiblingIdx = Sibling - this; - } else - SiblingIdx = 0; - } - - const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { - return AbbrevDecl; - } - - bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr, - DWARFFormValue &FormValue) const; - - const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr, - const char *FailValue) const; - - uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr, - uint64_t FailValue) const; - - uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U, - const uint16_t Attr, - uint64_t FailValue) const; - - uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr, - uint64_t FailValue) const; - - uint64_t getAttributeValueAsSectionOffset(const DWARFUnit *U, - const uint16_t Attr, - uint64_t FailValue) const; - - uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const; - - /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. - /// Returns true if both attributes are present. - bool getLowAndHighPC(const DWARFUnit *U, uint64_t &LowPC, - uint64_t &HighPC) const; - - DWARFAddressRangesVector getAddressRanges(const DWARFUnit *U) const; - - void collectChildrenAddressRanges(const DWARFUnit *U, - DWARFAddressRangesVector &Ranges) const; - - bool addressRangeContainsAddress(const DWARFUnit *U, - const uint64_t Address) const; - - /// If a DIE represents a subprogram (or inlined subroutine), - /// returns its mangled name (or short name, if mangled is missing). - /// This name may be fetched from specification or abstract origin - /// for this subprogram. Returns null if no name is found. - const char *getSubroutineName(const DWARFUnit *U, DINameKind Kind) const; - - /// Return the DIE name resolving DW_AT_sepcification or - /// DW_AT_abstract_origin references if necessary. - /// Returns null if no name is found. - const char *getName(const DWARFUnit *U, DINameKind Kind) const; - - /// Retrieves values of DW_AT_call_file, DW_AT_call_line and - /// DW_AT_call_column from DIE (or zeroes if they are missing). - void getCallerFrame(const DWARFUnit *U, uint32_t &CallFile, - uint32_t &CallLine, uint32_t &CallColumn) const; - - /// Get inlined chain for a given address, rooted at the current DIE. - /// Returns empty chain if address is not contained in address range - /// of current DIE. - DWARFDebugInfoEntryInlinedChain - getInlinedChainForAddress(const DWARFUnit *U, const uint64_t Address) const; -}; - -/// DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine -/// DIEs, (possibly ending with subprogram DIE), all of which are contained -/// in some concrete inlined instance tree. Address range for each DIE -/// (except the last DIE) in this chain is contained in address -/// range for next DIE in the chain. -struct DWARFDebugInfoEntryInlinedChain { - DWARFDebugInfoEntryInlinedChain() : U(nullptr) {} - SmallVector DIEs; - const DWARFUnit *U; -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugInfoEntry.h" -#include "DWARFCompileUnit.h" -#include "DWARFContext.h" -#include "DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARFDebugInfoEntry.h" +#include "llvm/DebugInfo/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARFContext.h" +#include "llvm/DebugInfo/DWARFDebugAbbrev.h" #include "llvm/DebugInfo/DWARFFormValue.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Debug.h" Index: llvm/trunk/lib/DebugInfo/DWARFDebugLine.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugLine.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.h @@ -1,238 +0,0 @@ -//===-- DWARFDebugLine.h ----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H - -#include "DWARFRelocMap.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/Support/DataExtractor.h" -#include -#include -#include - -namespace llvm { - -class raw_ostream; - -class DWARFDebugLine { -public: - DWARFDebugLine(const RelocAddrMap* LineInfoRelocMap) : RelocMap(LineInfoRelocMap) {} - struct FileNameEntry { - FileNameEntry() : Name(nullptr), DirIdx(0), ModTime(0), Length(0) {} - - const char *Name; - uint64_t DirIdx; - uint64_t ModTime; - uint64_t Length; - }; - - struct Prologue { - Prologue(); - - // The size in bytes of the statement information for this compilation unit - // (not including the total_length field itself). - uint32_t TotalLength; - // Version identifier for the statement information format. - uint16_t Version; - // The number of bytes following the prologue_length field to the beginning - // of the first byte of the statement program itself. - uint32_t PrologueLength; - // The size in bytes of the smallest target machine instruction. Statement - // program opcodes that alter the address register first multiply their - // operands by this value. - uint8_t MinInstLength; - // The maximum number of individual operations that may be encoded in an - // instruction. - uint8_t MaxOpsPerInst; - // The initial value of theis_stmtregister. - uint8_t DefaultIsStmt; - // This parameter affects the meaning of the special opcodes. See below. - int8_t LineBase; - // This parameter affects the meaning of the special opcodes. See below. - uint8_t LineRange; - // The number assigned to the first special opcode. - uint8_t OpcodeBase; - std::vector StandardOpcodeLengths; - std::vector IncludeDirectories; - std::vector FileNames; - - // Length of the prologue in bytes. - uint32_t getLength() const { - return PrologueLength + sizeof(TotalLength) + sizeof(Version) + - sizeof(PrologueLength); - } - // Length of the line table data in bytes (not including the prologue). - uint32_t getStatementTableLength() const { - return TotalLength + sizeof(TotalLength) - getLength(); - } - int32_t getMaxLineIncrementForSpecialOpcode() const { - return LineBase + (int8_t)LineRange - 1; - } - - void clear(); - void dump(raw_ostream &OS) const; - bool parse(DataExtractor debug_line_data, uint32_t *offset_ptr); - }; - - // Standard .debug_line state machine structure. - struct Row { - explicit Row(bool default_is_stmt = false); - - /// Called after a row is appended to the matrix. - void postAppend(); - void reset(bool default_is_stmt); - void dump(raw_ostream &OS) const; - - static bool orderByAddress(const Row& LHS, const Row& RHS) { - return LHS.Address < RHS.Address; - } - - // The program-counter value corresponding to a machine instruction - // generated by the compiler. - uint64_t Address; - // An unsigned integer indicating a source line number. Lines are numbered - // beginning at 1. The compiler may emit the value 0 in cases where an - // instruction cannot be attributed to any source line. - uint32_t Line; - // An unsigned integer indicating a column number within a source line. - // Columns are numbered beginning at 1. The value 0 is reserved to indicate - // that a statement begins at the 'left edge' of the line. - uint16_t Column; - // An unsigned integer indicating the identity of the source file - // corresponding to a machine instruction. - uint16_t File; - // An unsigned integer whose value encodes the applicable instruction set - // architecture for the current instruction. - uint8_t Isa; - // An unsigned integer representing the DWARF path discriminator value - // for this location. - uint32_t Discriminator; - // A boolean indicating that the current instruction is the beginning of a - // statement. - uint8_t IsStmt:1, - // A boolean indicating that the current instruction is the - // beginning of a basic block. - BasicBlock:1, - // A boolean indicating that the current address is that of the - // first byte after the end of a sequence of target machine - // instructions. - EndSequence:1, - // A boolean indicating that the current address is one (of possibly - // many) where execution should be suspended for an entry breakpoint - // of a function. - PrologueEnd:1, - // A boolean indicating that the current address is one (of possibly - // many) where execution should be suspended for an exit breakpoint - // of a function. - EpilogueBegin:1; - }; - - // Represents a series of contiguous machine instructions. Line table for each - // compilation unit may consist of multiple sequences, which are not - // guaranteed to be in the order of ascending instruction address. - struct Sequence { - // Sequence describes instructions at address range [LowPC, HighPC) - // and is described by line table rows [FirstRowIndex, LastRowIndex). - uint64_t LowPC; - uint64_t HighPC; - unsigned FirstRowIndex; - unsigned LastRowIndex; - bool Empty; - - Sequence(); - void reset(); - - static bool orderByLowPC(const Sequence& LHS, const Sequence& RHS) { - return LHS.LowPC < RHS.LowPC; - } - bool isValid() const { - return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex); - } - bool containsPC(uint64_t pc) const { - return (LowPC <= pc && pc < HighPC); - } - }; - - struct LineTable { - LineTable(); - - void appendRow(const DWARFDebugLine::Row &R) { - Rows.push_back(R); - } - void appendSequence(const DWARFDebugLine::Sequence &S) { - Sequences.push_back(S); - } - - // Returns the index of the row with file/line info for a given address, - // or -1 if there is no such row. - uint32_t lookupAddress(uint64_t address) const; - - bool lookupAddressRange(uint64_t address, uint64_t size, - std::vector &result) const; - - // Extracts filename by its index in filename table in prologue. - // Returns true on success. - bool getFileNameByIndex(uint64_t FileIndex, const char *CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - std::string &Result) const; - - // Fills the Result argument with the file and line information - // corresponding to Address. Returns true on success. - bool getFileLineInfoForAddress(uint64_t Address, const char *CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - DILineInfo &Result) const; - - void dump(raw_ostream &OS) const; - void clear(); - - /// Parse prologue and all rows. - bool parse(DataExtractor debug_line_data, const RelocAddrMap *RMap, - uint32_t *offset_ptr); - - struct Prologue Prologue; - typedef std::vector RowVector; - typedef RowVector::const_iterator RowIter; - typedef std::vector SequenceVector; - typedef SequenceVector::const_iterator SequenceIter; - RowVector Rows; - SequenceVector Sequences; - }; - - const LineTable *getLineTable(uint32_t offset) const; - const LineTable *getOrParseLineTable(DataExtractor debug_line_data, - uint32_t offset); - -private: - struct ParsingState { - ParsingState(struct LineTable *LT); - - void resetRowAndSequence(); - void appendRowToMatrix(uint32_t offset); - - // Line table we're currently parsing. - struct LineTable *LineTable; - // The row number that starts at zero for the prologue, and increases for - // each row added to the matrix. - unsigned RowNumber; - struct Row Row; - struct Sequence Sequence; - }; - - typedef std::map LineTableMapTy; - typedef LineTableMapTy::iterator LineTableIter; - typedef LineTableMapTy::const_iterator LineTableConstIter; - - const RelocAddrMap *RelocMap; - LineTableMapTy LineTableMap; -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugLine.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugLine.h" +#include "llvm/DebugInfo/DWARFDebugLine.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" #include "llvm/Support/Path.h" Index: llvm/trunk/lib/DebugInfo/DWARFDebugLoc.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugLoc.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugLoc.h @@ -1,81 +0,0 @@ -//===-- DWARFDebugLoc.h -----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H - -#include "DWARFRelocMap.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/DataExtractor.h" - -namespace llvm { - -class raw_ostream; - -class DWARFDebugLoc { - /// A single location within a location list. - struct Entry { - /// The beginning address of the instruction range. - uint64_t Begin; - /// The ending address of the instruction range. - uint64_t End; - /// The location of the variable within the specified range. - SmallVector Loc; - }; - - /// A list of locations that contain one variable. - struct LocationList { - /// The beginning offset where this location list is stored in the debug_loc - /// section. - unsigned Offset; - /// All the locations in which the variable is stored. - SmallVector Entries; - }; - - typedef SmallVector LocationLists; - - /// A list of all the variables in the debug_loc section, each one describing - /// the locations in which the variable is stored. - LocationLists Locations; - - /// A map used to resolve binary relocations. - const RelocAddrMap &RelocMap; - -public: - DWARFDebugLoc(const RelocAddrMap &LocRelocMap) : RelocMap(LocRelocMap) {} - /// Print the location lists found within the debug_loc section. - void dump(raw_ostream &OS) const; - /// Parse the debug_loc section accessible via the 'data' parameter using the - /// specified address size to interpret the address ranges. - void parse(DataExtractor data, unsigned AddressSize); -}; - -class DWARFDebugLocDWO { - struct Entry { - uint64_t Start; - uint32_t Length; - SmallVector Loc; - }; - - struct LocationList { - unsigned Offset; - SmallVector Entries; - }; - - typedef SmallVector LocationLists; - - LocationLists Locations; - -public: - void parse(DataExtractor data); - void dump(raw_ostream &OS) const; -}; -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugLoc.h" +#include "llvm/DebugInfo/DWARFDebugLoc.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" Index: llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.h +++ llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.h @@ -1,77 +0,0 @@ -//===-- DWARFDebugRangeList.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H -#define LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H - -#include "llvm/Support/DataExtractor.h" -#include - -namespace llvm { - -class raw_ostream; - -/// DWARFAddressRangesVector - represents a set of absolute address ranges. -typedef std::vector> DWARFAddressRangesVector; - -class DWARFDebugRangeList { -public: - struct RangeListEntry { - // A beginning address offset. This address offset has the size of an - // address and is relative to the applicable base address of the - // compilation unit referencing this range list. It marks the beginning - // of an address range. - uint64_t StartAddress; - // An ending address offset. This address offset again has the size of - // an address and is relative to the applicable base address of the - // compilation unit referencing this range list. It marks the first - // address past the end of the address range. The ending address must - // be greater than or equal to the beginning address. - uint64_t EndAddress; - // The end of any given range list is marked by an end of list entry, - // which consists of a 0 for the beginning address offset - // and a 0 for the ending address offset. - bool isEndOfListEntry() const { - return (StartAddress == 0) && (EndAddress == 0); - } - // A base address selection entry consists of: - // 1. The value of the largest representable address offset - // (for example, 0xffffffff when the size of an address is 32 bits). - // 2. An address, which defines the appropriate base address for - // use in interpreting the beginning and ending address offsets of - // subsequent entries of the location list. - bool isBaseAddressSelectionEntry(uint8_t AddressSize) const { - assert(AddressSize == 4 || AddressSize == 8); - if (AddressSize == 4) - return StartAddress == -1U; - else - return StartAddress == -1ULL; - } - }; - -private: - // Offset in .debug_ranges section. - uint32_t Offset; - uint8_t AddressSize; - std::vector Entries; - -public: - DWARFDebugRangeList() { clear(); } - void clear(); - void dump(raw_ostream &OS) const; - bool extract(DataExtractor data, uint32_t *offset_ptr); - /// getAbsoluteRanges - Returns absolute address ranges defined by this range - /// list. Has to be passed base address of the compile unit referencing this - /// range list. - DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const; -}; - -} // namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H Index: llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp +++ llvm/trunk/lib/DebugInfo/DWARFDebugRangeList.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARFDebugRangeList.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" Index: llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp +++ llvm/trunk/lib/DebugInfo/DWARFFormValue.cpp @@ -8,10 +8,10 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARFFormValue.h" -#include "DWARFCompileUnit.h" -#include "DWARFContext.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARFContext.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" Index: llvm/trunk/lib/DebugInfo/DWARFRelocMap.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFRelocMap.h +++ llvm/trunk/lib/DebugInfo/DWARFRelocMap.h @@ -1,22 +0,0 @@ -//===-- DWARFRelocMap.h -----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFRELOCMAP_H -#define LLVM_LIB_DEBUGINFO_DWARFRELOCMAP_H - -#include "llvm/ADT/DenseMap.h" - -namespace llvm { - -typedef DenseMap > RelocAddrMap; - -} // namespace llvm - -#endif - Index: llvm/trunk/lib/DebugInfo/DWARFSection.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFSection.h +++ llvm/trunk/lib/DebugInfo/DWARFSection.h @@ -1,24 +0,0 @@ -//===-- DWARFSection.h ------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFSECTION_H -#define LLVM_LIB_DEBUGINFO_DWARFSECTION_H - -#include "DWARFRelocMap.h" - -namespace llvm { - -struct DWARFSection { - StringRef Data; - RelocAddrMap Relocs; -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h +++ llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h @@ -1,38 +0,0 @@ -//===-- DWARFTypeUnit.h -----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFTYPEUNIT_H -#define LLVM_LIB_DEBUGINFO_DWARFTYPEUNIT_H - -#include "DWARFUnit.h" - -namespace llvm { - -class DWARFTypeUnit : public DWARFUnit { -private: - uint64_t TypeHash; - uint32_t TypeOffset; -public: - DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, bool LE, - const DWARFUnitSectionBase &UnitSection) - : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {} - uint32_t getHeaderSize() const override { - return DWARFUnit::getHeaderSize() + 12; - } - void dump(raw_ostream &OS); -protected: - bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) override; -}; - -} - -#endif - Index: llvm/trunk/lib/DebugInfo/DWARFTypeUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFTypeUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARFTypeUnit.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DWARFTypeUnit.h" +#include "llvm/DebugInfo/DWARFTypeUnit.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" Index: llvm/trunk/lib/DebugInfo/DWARFUnit.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFUnit.h +++ llvm/trunk/lib/DebugInfo/DWARFUnit.h @@ -1,245 +0,0 @@ -//===-- DWARFUnit.h ---------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_DEBUGINFO_DWARFUNIT_H -#define LLVM_LIB_DEBUGINFO_DWARFUNIT_H - -#include "DWARFDebugAbbrev.h" -#include "DWARFDebugInfoEntry.h" -#include "DWARFDebugRangeList.h" -#include "DWARFRelocMap.h" -#include "DWARFSection.h" -#include - -namespace llvm { - -namespace object { -class ObjectFile; -} - -class DWARFContext; -class DWARFDebugAbbrev; -class DWARFUnit; -class StringRef; -class raw_ostream; - -/// Base class for all DWARFUnitSection classes. This provides the -/// functionality common to all unit types. -class DWARFUnitSectionBase { -public: - /// Returns the Unit that contains the given section offset in the - /// same section this Unit originated from. - virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0; - - void parse(DWARFContext &C, const DWARFSection &Section); - void parseDWO(DWARFContext &C, const DWARFSection &DWOSection); - -protected: - virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, bool isLittleEndian) = 0; - - ~DWARFUnitSectionBase() {} -}; - -/// Concrete instance of DWARFUnitSection, specialized for one Unit type. -template -class DWARFUnitSection final : public SmallVector, 1>, - public DWARFUnitSectionBase { - - struct UnitOffsetComparator { - bool operator()(uint32_t LHS, - const std::unique_ptr &RHS) const { - return LHS < RHS->getNextUnitOffset(); - } - }; - - bool Parsed; - -public: - DWARFUnitSection() : Parsed(false) {} - DWARFUnitSection(DWARFUnitSection &&DUS) : - SmallVector, 1>(std::move(DUS)), Parsed(DUS.Parsed) {} - - typedef llvm::SmallVectorImpl> UnitVector; - typedef typename UnitVector::iterator iterator; - typedef llvm::iterator_range iterator_range; - - UnitType *getUnitForOffset(uint32_t Offset) const override { - auto *CU = std::upper_bound(this->begin(), this->end(), Offset, - UnitOffsetComparator()); - if (CU != this->end()) - return CU->get(); - return nullptr; - } - -private: - void parseImpl(DWARFContext &Context, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, bool LE) override { - if (Parsed) - return; - DataExtractor Data(Section.Data, LE, 0); - uint32_t Offset = 0; - while (Data.isValidOffset(Offset)) { - auto U = llvm::make_unique(Context, Section, DA, RS, SS, SOS, - AOS, LE, *this); - if (!U->extract(Data, &Offset)) - break; - this->push_back(std::move(U)); - Offset = this->back()->getNextUnitOffset(); - } - Parsed = true; - } -}; - -class DWARFUnit { - DWARFContext &Context; - // Section containing this DWARFUnit. - const DWARFSection &InfoSection; - - const DWARFDebugAbbrev *Abbrev; - StringRef RangeSection; - uint32_t RangeSectionBase; - StringRef StringSection; - StringRef StringOffsetSection; - StringRef AddrOffsetSection; - uint32_t AddrOffsetSectionBase; - bool isLittleEndian; - const DWARFUnitSectionBase &UnitSection; - - uint32_t Offset; - uint32_t Length; - uint16_t Version; - const DWARFAbbreviationDeclarationSet *Abbrevs; - uint8_t AddrSize; - uint64_t BaseAddr; - // The compile unit debug information entry items. - std::vector DieArray; - - class DWOHolder { - object::OwningBinary DWOFile; - std::unique_ptr DWOContext; - DWARFUnit *DWOU; - public: - DWOHolder(StringRef DWOPath); - DWARFUnit *getUnit() const { return DWOU; } - }; - std::unique_ptr DWO; - -protected: - virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr); - /// Size in bytes of the unit header. - virtual uint32_t getHeaderSize() const { return 11; } - -public: - DWARFUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, bool LE, - const DWARFUnitSectionBase &UnitSection); - - virtual ~DWARFUnit(); - - DWARFContext& getContext() const { return Context; } - - StringRef getStringSection() const { return StringSection; } - StringRef getStringOffsetSection() const { return StringOffsetSection; } - void setAddrOffsetSection(StringRef AOS, uint32_t Base) { - AddrOffsetSection = AOS; - AddrOffsetSectionBase = Base; - } - void setRangesSection(StringRef RS, uint32_t Base) { - RangeSection = RS; - RangeSectionBase = Base; - } - - bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const; - // FIXME: Result should be uint64_t in DWARF64. - bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const; - - DataExtractor getDebugInfoExtractor() const { - return DataExtractor(InfoSection.Data, isLittleEndian, AddrSize); - } - DataExtractor getStringExtractor() const { - return DataExtractor(StringSection, false, 0); - } - - const RelocAddrMap *getRelocMap() const { return &InfoSection.Relocs; } - - bool extract(DataExtractor debug_info, uint32_t* offset_ptr); - - /// extractRangeList - extracts the range list referenced by this compile - /// unit from .debug_ranges section. Returns true on success. - /// Requires that compile unit is already extracted. - bool extractRangeList(uint32_t RangeListOffset, - DWARFDebugRangeList &RangeList) const; - void clear(); - uint32_t getOffset() const { return Offset; } - uint32_t getNextUnitOffset() const { return Offset + Length + 4; } - uint32_t getLength() const { return Length; } - uint16_t getVersion() const { return Version; } - const DWARFAbbreviationDeclarationSet *getAbbreviations() const { - return Abbrevs; - } - uint8_t getAddressByteSize() const { return AddrSize; } - uint64_t getBaseAddress() const { return BaseAddr; } - - void setBaseAddress(uint64_t base_addr) { - BaseAddr = base_addr; - } - - const DWARFDebugInfoEntryMinimal * - getCompileUnitDIE(bool extract_cu_die_only = true) { - extractDIEsIfNeeded(extract_cu_die_only); - return DieArray.empty() ? nullptr : &DieArray[0]; - } - - const char *getCompilationDir(); - uint64_t getDWOId(); - - void collectAddressRanges(DWARFAddressRangesVector &CURanges); - - /// getInlinedChainForAddress - fetches inlined chain for a given address. - /// Returns empty chain if there is no subprogram containing address. The - /// chain is valid as long as parsed compile unit DIEs are not cleared. - DWARFDebugInfoEntryInlinedChain getInlinedChainForAddress(uint64_t Address); - - /// getUnitSection - Return the DWARFUnitSection containing this unit. - const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; } - -private: - /// Size in bytes of the .debug_info data associated with this compile unit. - size_t getDebugInfoSize() const { return Length + 4 - getHeaderSize(); } - - /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it - /// hasn't already been done. Returns the number of DIEs parsed at this call. - size_t extractDIEsIfNeeded(bool CUDieOnly); - /// extractDIEsToVector - Appends all parsed DIEs to a vector. - void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs, - std::vector &DIEs) const; - /// setDIERelations - We read in all of the DIE entries into our flat list - /// of DIE entries and now we need to go back through all of them and set the - /// parent, sibling and child pointers for quick DIE navigation. - void setDIERelations(); - /// clearDIEs - Clear parsed DIEs to keep memory usage low. - void clearDIEs(bool KeepCUDie); - - /// parseDWO - Parses .dwo file for current compile unit. Returns true if - /// it was actually constructed. - bool parseDWO(); - - /// getSubprogramForAddress - Returns subprogram DIE with address range - /// encompassing the provided address. The pointer is alive as long as parsed - /// compile unit DIEs are not cleared. - const DWARFDebugInfoEntryMinimal *getSubprogramForAddress(uint64_t Address); -}; - -} - -#endif Index: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "DWARFUnit.h" -#include "DWARFContext.h" +#include "llvm/DebugInfo/DWARFUnit.h" +#include "llvm/DebugInfo/DWARFContext.h" #include "llvm/DebugInfo/DWARFFormValue.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Path.h"