#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/UniqueVector.h"
#include <string>
class DbgConcreteScope;
class MachineFrameInfo;
class MachineModuleInfo;
-class TargetAsmInfo;
+class MCAsmInfo;
class Timer;
//===----------------------------------------------------------------------===//
///
SmallVector<CompileUnit *, 8> CompileUnits;
- /// MainCU - Some platform prefers one compile unit per .o file. In such
- /// cases, all dies are inserted in MainCU.
- CompileUnit *MainCU;
+ /// ModuleCU - All DIEs are inserted in ModuleCU.
+ CompileUnit *ModuleCU;
/// AbbreviationsSet - Used to uniquely define abbreviations.
///
/// SectionMap - Provides a unique id per text section.
///
- UniqueVector<const Section*> SectionMap;
+ UniqueVector<const MCSection*> SectionMap;
/// SectionSourceLines - Tracks line numbers per text section.
///
DbgScope *FunctionDbgScope;
/// DbgScopeMap - Tracks the scopes in the current function.
- DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap;
+ DenseMap<MDNode *, DbgScope *> DbgScopeMap;
/// DbgAbstractScopeMap - Tracks abstract instance scopes in the current
/// function.
- DenseMap<GlobalVariable *, DbgScope *> DbgAbstractScopeMap;
+ DenseMap<MDNode *, DbgScope *> DbgAbstractScopeMap;
/// DbgConcreteScopeMap - Tracks concrete instance scopes in the current
/// function.
- DenseMap<GlobalVariable *,
+ DenseMap<MDNode *,
SmallVector<DbgScope *, 8> > DbgConcreteScopeMap;
/// InlineInfo - Keep track of inlined functions and their location. This
/// information is used to populate debug_inlined section.
- DenseMap<GlobalVariable *, SmallVector<unsigned, 4> > InlineInfo;
-
- /// InlinedVariableScopes - Scopes information for the inlined subroutine
- /// variables.
- DenseMap<const MachineInstr *, DbgScope *> InlinedVariableScopes;
+ DenseMap<MDNode *, SmallVector<unsigned, 4> > InlineInfo;
/// AbstractInstanceRootMap - Map of abstract instance roots of inlined
/// functions. These are subroutine entries that contain a DW_AT_inline
/// attribute.
- DenseMap<const GlobalVariable *, DbgScope *> AbstractInstanceRootMap;
+ DenseMap<const MDNode *, DbgScope *> AbstractInstanceRootMap;
/// AbstractInstanceRootList - List of abstract instance roots of inlined
/// functions. These are subroutine entries that contain a DW_AT_inline
///
void AssignAbbrevNumber(DIEAbbrev &Abbrev);
- /// NewString - Add a string to the constant pool and returns a label.
- ///
- DWLabel NewString(const std::string &String) {
- unsigned StringID = StringPool.insert(String);
- return DWLabel("string", StringID);
- }
-
- /// NewDIEEntry - Creates a new DIEEntry to be a proxy for a debug information
- /// entry.
- DIEEntry *NewDIEEntry(DIE *Entry = NULL);
+ /// CreateDIEEntry - Creates a new DIEEntry to be a proxy for a debug
+ /// information entry.
+ DIEEntry *CreateDIEEntry(DIE *Entry = NULL);
/// SetDIEEntry - Set a DIEEntry once the debug information entry is defined.
///
/// AddDIEEntry - Add a DIE attribute data and value.
///
void AddDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry) {
- Die->AddValue(Attribute, Form, NewDIEEntry(Entry));
+ Die->AddValue(Attribute, Form, CreateDIEEntry(Entry));
}
/// AddBlock - Add block data.
/// AddSourceLine - Add location information to specified debug information
/// entry.
void AddSourceLine(DIE *Die, const DIVariable *V);
-
- /// AddSourceLine - Add location information to specified debug information
- /// entry.
void AddSourceLine(DIE *Die, const DIGlobal *G);
-
+ void AddSourceLine(DIE *Die, const DISubprogram *SP);
void AddSourceLine(DIE *Die, const DIType *Ty);
/// AddAddress - Add an address attribute to a die based on the location
void AddAddress(DIE *Die, unsigned Attribute,
const MachineLocation &Location);
+ /// AddBlockByrefAddress - Start with the address based on the location
+ /// provided, and generate the DWARF information necessary to find the
+ /// actual Block variable (navigating the Block struct) based on the
+ /// starting location. Add the DWARF information to the die.
+ ///
+ void AddBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
+ const MachineLocation &Location);
+
/// AddType - Add a new type attribute to the specified entity.
void AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty);
/// CreateSubprogramDIE - Create new DIE using SP.
DIE *CreateSubprogramDIE(CompileUnit *DW_Unit,
const DISubprogram &SP,
- bool IsConstructor = false);
+ bool IsConstructor = false,
+ bool IsInlined = false);
/// FindCompileUnit - Get the compile unit for the given descriptor.
///
CompileUnit &FindCompileUnit(DICompileUnit Unit) const;
- /// NewDbgScopeVariable - Create a new scope variable.
+ /// CreateDbgScopeVariable - Create a new scope variable.
///
- DIE *NewDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit);
+ DIE *CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit);
/// getOrCreateScope - Returns the scope associated with the given descriptor.
///
- DbgScope *getOrCreateScope(GlobalVariable *V);
+ DbgScope *getOrCreateScope(MDNode *N);
/// ConstructDbgScope - Construct the components of a scope.
///
/// ConstructFunctionDbgScope - Construct the scope for the subprogram.
///
- void ConstructFunctionDbgScope(DbgScope *RootScope);
-
- /// ConstructFunctionDbgScope - Construct the scope for the abstract debug
- /// scope.
- ///
- void ConstructAbstractDbgScope(DbgScope *AbsScope);
+ void ConstructFunctionDbgScope(DbgScope *RootScope,
+ bool AbstractScope = false);
/// ConstructDefaultDbgScope - Construct a default scope for the subprogram.
///
unsigned GetOrCreateSourceID(const std::string &DirName,
const std::string &FileName);
- void ConstructCompileUnit(GlobalVariable *GV);
+ void ConstructCompileUnit(MDNode *N);
- /// ConstructCompileUnits - Create a compile unit DIEs.
- void ConstructCompileUnits();
+ void ConstructGlobalVariableDIE(MDNode *N);
- bool ConstructGlobalVariableDIE(GlobalVariable *GV);
+ void ConstructSubprogram(MDNode *N);
- /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally
- /// visible global variables. Return true if at least one global DIE is
- /// created.
- bool ConstructGlobalVariableDIEs();
-
- bool ConstructSubprogram(GlobalVariable *GV);
+ /// Find the type the programmer originally declared the variable to be
+ /// and return that type.
+ ///
+ DIType GetBlockByrefType(DIType Ty, std::string Name);
- /// ConstructSubprograms - Create DIEs for each of the externally visible
- /// subprograms. Return true if at least one subprogram DIE is created.
- bool ConstructSubprograms();
public:
//===--------------------------------------------------------------------===//
// Main entry points.
//
- DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
+ DwarfDebug(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T);
virtual ~DwarfDebug();
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
/// be emitted.
bool ShouldEmitDwarfDebug() const { return shouldEmit; }
- /// SetDebugInfo - Create global DIEs and emit initial debug info sections.
- /// This is inovked by the target AsmPrinter.
- void SetDebugInfo(MachineModuleInfo *mmi);
-
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// content.
- void BeginModule(Module *M) {
- this->M = M;
- }
+ void BeginModule(Module *M, MachineModuleInfo *MMI);
/// EndModule - Emit all Dwarf sections that should come after the content.
///
const std::string &FileName);
/// RecordRegionStart - Indicate the start of a region.
- unsigned RecordRegionStart(GlobalVariable *V);
+ unsigned RecordRegionStart(MDNode *N);
/// RecordRegionEnd - Indicate the end of a region.
- unsigned RecordRegionEnd(GlobalVariable *V);
+ unsigned RecordRegionEnd(MDNode *N);
/// RecordVariable - Indicate the declaration of a local variable.
- void RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
- const MachineInstr *MI);
+ void RecordVariable(MDNode *N, unsigned FrameIndex);
//// RecordInlinedFnStart - Indicate the start of inlined subroutine.
unsigned RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
/// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
unsigned RecordInlinedFnEnd(DISubprogram &SP);
- /// RecordVariableScope - Record scope for the variable declared by
- /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes
- /// for only inlined subroutine variables. Other variables's scopes are
- /// determined during RecordVariable().
- void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
};
} // End of namespace llvm