#include "DwarfDebug.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/DebugInfo.h"
+#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/DebugInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCDwarf.h"
namespace llvm {
RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {}
const MCSymbol *getStart() const { return Start; }
const MCSymbol *getEnd() const { return End; }
+ void setEnd(const MCSymbol *E) { End = E; }
private:
const MCSymbol *Start, *End;
DICompileUnit CUNode;
/// Unit debug information entry.
- const OwningPtr<DIE> UnitDie;
+ const std::unique_ptr<DIE> UnitDie;
/// Offset of the UnitDie from beginning of debug info section.
unsigned DebugInfoOffset;
/// GlobalTypes - A map of globally visible types for this unit.
StringMap<const DIE *> GlobalTypes;
- /// AccelNames - A map of names for the name accelerator table.
- StringMap<std::vector<const DIE *> > AccelNames;
-
- /// AccelObjC - A map of objc spec for the objc accelerator table.
- StringMap<std::vector<const DIE *> > AccelObjC;
-
- /// AccelNamespace - A map of names for the namespace accelerator table.
- StringMap<std::vector<const DIE *> > AccelNamespace;
-
- /// AccelTypes - A map of names for the type accelerator table.
- StringMap<std::vector<std::pair<const DIE *, unsigned> > > AccelTypes;
-
/// DIEBlocks - A list of all the DIEBlocks in use.
std::vector<DIEBlock *> DIEBlocks;
virtual ~DwarfUnit();
/// Set the skeleton unit associated with this unit.
- void setSkeleton(DwarfUnit *Skel) { Skeleton = Skel; }
+ void setSkeleton(DwarfUnit &Skel) { Skeleton = &Skel; }
/// Get the skeleton unit associated with this unit.
DwarfUnit *getSkeleton() const { return Skeleton; }
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
- const StringMap<std::vector<const DIE *> > &getAccelNames() const {
- return AccelNames;
- }
- const StringMap<std::vector<const DIE *> > &getAccelObjC() const {
- return AccelObjC;
- }
- const StringMap<std::vector<const DIE *> > &getAccelNamespace() const {
- return AccelNamespace;
- }
- const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &
- getAccelTypes() const {
- return AccelTypes;
- }
-
unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
bool hasContent() const { return !UnitDie->getChildren().empty(); }
/// addRange - Add an address range to the list of ranges for this unit.
- void addRange(RangeSpan Range) { CURanges.push_back(Range); }
+ void addRange(RangeSpan Range);
/// getRanges - Get the list of ranges for this unit.
const SmallVectorImpl<RangeSpan> &getRanges() const { return CURanges; }
///
void addGlobalName(StringRef Name, DIE *Die, DIScope Context);
- /// addAccelName - Add a new name to the name accelerator table.
- void addAccelName(StringRef Name, const DIE *Die);
-
- /// addAccelObjC - Add a new name to the ObjC accelerator table.
- void addAccelObjC(StringRef Name, const DIE *Die);
-
/// addAccelNamespace - Add a new name to the namespace accelerator table.
void addAccelNamespace(StringRef Name, const DIE *Die);
- /// addAccelType - Add a new type to the type accelerator table.
- void addAccelType(StringRef Name, std::pair<const DIE *, unsigned> Die);
-
/// getDIE - Returns the debug information entry map slot for the
/// specified debug variable. We delegate the request to DwarfDebug
/// when the MDNode can be part of the type system, since DIEs for
void addLabel(DIELoc *Die, dwarf::Form Form, const MCSymbol *Label);
+ /// addLocationList - Add a Dwarf loclistptr attribute data and value.
+ void addLocationList(DIE *Die, dwarf::Attribute Attribute, unsigned Index);
+
/// addSectionLabel - Add a Dwarf section label attribute data and value.
///
void addSectionLabel(DIE *Die, dwarf::Attribute Attribute,
void addSectionDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
const MCSymbol *Lo);
+ /// addLabelDelta - Add a label delta attribute data and value.
+ void addLabelDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
+ const MCSymbol *Lo);
+
/// addDIEEntry - Add a DIE attribute data and value.
void addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIE *Entry);
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
+ /// constructSubprogramArguments - Construct function argument DIEs.
+ void constructSubprogramArguments(DIE &Buffer, DIArray Args);
+
/// Create a DIE with the given Tag, add the DIE to its parent, and
/// call insertDIE if MD is not null.
DIE *createAndAddDIE(unsigned Tag, DIE &Parent,
}
/// Emit the header for this unit, not including the initial length field.
- virtual void emitHeader(const MCSection *ASection,
- const MCSymbol *ASectionSym) const;
+ virtual void emitHeader(const MCSymbol *ASectionSym) const;
virtual DwarfCompileUnit &getCU() = 0;
/// getOrCreateStaticMemberDIE - Create new static data member DIE.
DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
+ /// Look up the source ID with the given directory and source file names. If
+ /// none currently exists, create a new ID and insert it in the line table.
+ virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
+
private:
- /// constructSubprogramArguments - Construct function argument DIEs.
- void constructSubprogramArguments(DIE &Buffer, DIArray Args);
+ /// \brief Construct a DIE for the given DbgVariable without initializing the
+ /// DbgVariable's DIE reference.
+ DIE *constructVariableDIEImpl(const DbgVariable &DV, bool isScopeAbstract);
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
/// addLabelAddress - Add a dwarf label attribute data and value using
/// either DW_FORM_addr or DW_FORM_GNU_addr_index.
- void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
+ void addLabelAddress(DIE *Die, dwarf::Attribute Attribute,
+ const MCSymbol *Label);
+
+ /// addLocalLabelAddress - Add a dwarf label attribute data and value using
+ /// DW_FORM_addr only.
+ void addLocalLabelAddress(DIE *Die, dwarf::Attribute Attribute,
+ const MCSymbol *Label);
- DwarfCompileUnit &getCU() LLVM_OVERRIDE { return *this; }
+ DwarfCompileUnit &getCU() override { return *this; }
+
+ unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
};
class DwarfTypeUnit : public DwarfUnit {
uint64_t TypeSignature;
const DIE *Ty;
DwarfCompileUnit &CU;
+ MCDwarfDwoLineTable *SplitLineTable;
public:
DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A,
- DwarfDebug *DW, DwarfFile *DWU);
+ DwarfDebug *DW, DwarfFile *DWU,
+ MCDwarfDwoLineTable *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
uint64_t getTypeSignature() const { return TypeSignature; }
void setType(const DIE *Ty) { this->Ty = Ty; }
/// Emit the header for this unit, not including the initial length field.
- void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym) const
- LLVM_OVERRIDE;
- unsigned getHeaderSize() const LLVM_OVERRIDE {
+ void emitHeader(const MCSymbol *ASectionSym) const override;
+ unsigned getHeaderSize() const override {
return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
sizeof(uint32_t); // Type DIE Offset
}
void initSection(const MCSection *Section);
- DwarfCompileUnit &getCU() LLVM_OVERRIDE { return CU; }
+ DwarfCompileUnit &getCU() override { return CU; }
+
+protected:
+ unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
};
} // end llvm namespace
#endif