DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
int FrameIndex;
+ DwarfDebug *DD;
public:
// AbsVar may be NULL.
- DbgVariable(DIVariable V, DbgVariable *AV)
+ DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
: Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
- FrameIndex(~0) {}
+ FrameIndex(~0), DD(DD) {}
// Accessors.
DIVariable getVariable() const { return Var; }
return Var.getAddrElement(i);
}
DIType getType() const;
+
+private:
+ /// resolve - Look in the DwarfDebug map for the MDNode that
+ /// corresponds to the reference.
+ template <typename T> T resolve(DIRef<T> Ref) const;
};
/// \brief Collects and handles information specific to a particular
/// \brief Returns the address pool.
AddrPool *getAddrPool() { return &AddressPool; }
-
- /// \brief for a given compile unit DIE, returns offset from beginning of
- /// debug info.
- unsigned getCUOffset(DIE *Die);
};
/// \brief Helper used to pair up a symbol and it's DWARF compile unit.
struct SymbolCU {
+ SymbolCU(CompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
const MCSymbol *Sym;
CompileUnit *CU;
};
// Maps subprogram MDNode with its corresponding CompileUnit.
DenseMap <const MDNode *, CompileUnit *> SPMap;
- /// Maps type MDNode with its corresponding DIE. These DIEs can be
- /// shared across CUs, that is why we keep the map here instead
- /// of in CompileUnit.
- DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
- /// Maps subprogram MDNode with its corresponding DIE.
- DenseMap<const MDNode *, DIE *> MDSPNodeToDieMap;
- /// Maps static member MDNode with its corresponding DIE.
- DenseMap<const MDNode *, DIE *> MDStaticMemberNodeToDieMap;
-
- /// Specifies a worklist item. Sometimes, when we try to add an attribute to
- /// a DIE, the DIE is not yet added to its owner yet, so we don't know whether
- /// we should use ref_addr or ref4. We create a worklist that will be
- /// processed during finalization to add attributes with the correct form
- /// (ref_addr or ref4).
- struct DIEEntryWorkItem {
- DIE *Die;
- uint16_t Attribute;
- DIEEntry *Entry;
- DIEEntryWorkItem(DIE *D, uint16_t A, DIEEntry *E) :
- Die(D), Attribute(A), Entry(E) {
- }
- };
- SmallVector<DIEEntryWorkItem, 64> DIEEntryWorklist;
-
// Used to uniquely define abbreviations.
FoldingSet<DIEAbbrev> AbbreviationsSet;
// separated by a zero byte, mapped to a unique id.
StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
- // List of all labels used in the output.
- std::vector<SymbolCU> Labels;
+ // List of all labels used in aranges generation.
+ std::vector<SymbolCU> ArangeLabels;
// Size of each symbol emitted (for those symbols that have a specific size).
DenseMap <const MCSymbol *, uint64_t> SymSize;
// Holders for the various debug information flags that we might need to
// have exposed. See accessor functions below for description.
- // Whether or not we're emitting info for older versions of gdb on darwin.
- bool IsDarwinGDBCompat;
-
// Holder for imported entities.
typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
ImportedEntityMap;
// Main entry points.
//
DwarfDebug(AsmPrinter *A, Module *M);
- ~DwarfDebug();
-
- void insertTypeDIE(const MDNode *TypeMD, DIE *Die) {
- MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
- }
- DIE *getTypeDIE(const MDNode *TypeMD) {
- return MDTypeNodeToDieMap.lookup(TypeMD);
- }
- void insertSPDIE(const MDNode *SPMD, DIE *Die) {
- MDSPNodeToDieMap.insert(std::make_pair(SPMD, Die));
- }
- DIE *getSPDIE(const MDNode *SPMD) {
- return MDSPNodeToDieMap.lookup(SPMD);
- }
- void insertStaticMemberDIE(const MDNode *StaticMD, DIE *Die) {
- MDStaticMemberNodeToDieMap.insert(std::make_pair(StaticMD, Die));
- }
- DIE *getStaticMemberDIE(const MDNode *StaticMD) {
- return MDStaticMemberNodeToDieMap.lookup(StaticMD);
- }
- void insertDIEEntryWorklist(DIE *Die, uint16_t Attribute, DIEEntry *Entry) {
- DIEEntryWorklist.push_back(DIEEntryWorkItem(Die, Attribute, Entry));
- }
/// \brief Emit all Dwarf sections that should come prior to the
/// content.
void addTypeUnitType(DIE *Die) { TypeUnits.push_back(Die); }
/// \brief Add a label so that arange data can be generated for it.
- void addLabel(SymbolCU SCU) { Labels.push_back(SCU); }
+ void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
/// \brief For symbols that have a size designated (e.g. common symbols),
/// this tracks that size.
/// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
- /// \brief Returns whether or not to limit some of our debug
- /// output to the limitations of darwin gdb.
- bool useDarwinGDBCompat() { return IsDarwinGDBCompat; }
-
// Experimental DWARF5 features.
/// \brief Returns whether or not to emit tables that dwarf consumers can
/// Returns the Dwarf Version.
unsigned getDwarfVersion() const { return DwarfVersion; }
- /// Find the MDNode for the given scope reference.
- template <typename T>
- T resolve(DIRef<T> Ref) const {
+ /// Find the MDNode for the given reference.
+ template <typename T> T resolve(DIRef<T> Ref) const {
return Ref.resolve(TypeIdentifierMap);
}
- /// When we don't know whether the correct form is ref4 or ref_addr, we create
- /// a worklist item and insert it to DIEEntryWorklist.
- void addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t Form,
- DIEEntry *Entry);
-
/// isSubprogramContext - Return true if Context is either a subprogram
/// or another context nested inside a subprogram.
bool isSubprogramContext(const MDNode *Context);