2009-05-15 17:23:25 +08:00
|
|
|
//===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains support for writing dwarf debug info into asm files.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef CODEGEN_ASMPRINTER_DWARFDEBUG_H__
|
|
|
|
#define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2010-04-05 14:12:01 +08:00
|
|
|
#include "DIE.h"
|
2010-01-19 14:19:05 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
2010-04-05 13:24:55 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/UniqueVector.h"
|
2010-04-05 13:24:55 +08:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class CompileUnit;
|
|
|
|
class DbgConcreteScope;
|
2009-11-17 17:17:08 +08:00
|
|
|
class DbgScope;
|
|
|
|
class DbgVariable;
|
2009-05-15 17:23:25 +08:00
|
|
|
class MachineFrameInfo;
|
2010-04-05 13:24:55 +08:00
|
|
|
class MachineLocation;
|
2009-05-15 17:23:25 +08:00
|
|
|
class MachineModuleInfo;
|
2010-04-28 09:03:09 +08:00
|
|
|
class MachineOperand;
|
2009-08-23 04:48:53 +08:00
|
|
|
class MCAsmInfo;
|
2010-04-05 13:24:55 +08:00
|
|
|
class DIEAbbrev;
|
|
|
|
class DIE;
|
|
|
|
class DIEBlock;
|
|
|
|
class DIEEntry;
|
|
|
|
|
|
|
|
class DIEnumerator;
|
|
|
|
class DIDescriptor;
|
|
|
|
class DIVariable;
|
|
|
|
class DIGlobal;
|
|
|
|
class DIGlobalVariable;
|
|
|
|
class DISubprogram;
|
|
|
|
class DIBasicType;
|
|
|
|
class DIDerivedType;
|
|
|
|
class DIType;
|
|
|
|
class DINameSpace;
|
|
|
|
class DISubrange;
|
|
|
|
class DICompositeType;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// SrcLineInfo - This class is used to record source line correspondence.
|
|
|
|
///
|
2009-11-17 17:17:08 +08:00
|
|
|
class SrcLineInfo {
|
2009-05-15 17:23:25 +08:00
|
|
|
unsigned Line; // Source line number.
|
|
|
|
unsigned Column; // Source column.
|
|
|
|
unsigned SourceID; // Source ID number.
|
2010-03-14 16:15:55 +08:00
|
|
|
MCSymbol *Label; // Label in code ID number.
|
2009-05-15 17:23:25 +08:00
|
|
|
public:
|
2010-03-14 16:15:55 +08:00
|
|
|
SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
|
|
|
|
: Line(L), Column(C), SourceID(S), Label(label) {}
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getLine() const { return Line; }
|
|
|
|
unsigned getColumn() const { return Column; }
|
|
|
|
unsigned getSourceID() const { return SourceID; }
|
2010-03-14 16:15:55 +08:00
|
|
|
MCSymbol *getLabel() const { return Label; }
|
2009-05-15 17:23:25 +08:00
|
|
|
};
|
|
|
|
|
2010-04-05 08:13:49 +08:00
|
|
|
class DwarfDebug {
|
|
|
|
/// Asm - Target of Dwarf emission.
|
|
|
|
AsmPrinter *Asm;
|
2010-04-05 13:31:04 +08:00
|
|
|
|
2010-04-05 08:13:49 +08:00
|
|
|
/// MMI - Collected machine module information.
|
|
|
|
MachineModuleInfo *MMI;
|
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Attributes used to construct specific Dwarf sections.
|
|
|
|
//
|
|
|
|
|
2010-05-11 06:49:55 +08:00
|
|
|
CompileUnit *FirstCU;
|
|
|
|
DenseMap <const MDNode *, CompileUnit *> CUMap;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// AbbreviationsSet - Used to uniquely define abbreviations.
|
|
|
|
///
|
|
|
|
FoldingSet<DIEAbbrev> AbbreviationsSet;
|
|
|
|
|
|
|
|
/// Abbreviations - A list of all the unique abbreviations in use.
|
|
|
|
///
|
|
|
|
std::vector<DIEAbbrev *> Abbreviations;
|
|
|
|
|
|
|
|
/// DirectoryIdMap - Directory name to directory id map.
|
|
|
|
///
|
|
|
|
StringMap<unsigned> DirectoryIdMap;
|
|
|
|
|
|
|
|
/// DirectoryNames - A list of directory names.
|
|
|
|
SmallVector<std::string, 8> DirectoryNames;
|
|
|
|
|
|
|
|
/// SourceFileIdMap - Source file name to source file id map.
|
|
|
|
///
|
|
|
|
StringMap<unsigned> SourceFileIdMap;
|
|
|
|
|
|
|
|
/// SourceFileNames - A list of source file names.
|
|
|
|
SmallVector<std::string, 8> SourceFileNames;
|
|
|
|
|
|
|
|
/// SourceIdMap - Source id map, i.e. pair of directory id and source file
|
|
|
|
/// id mapped to a unique id.
|
|
|
|
DenseMap<std::pair<unsigned, unsigned>, unsigned> SourceIdMap;
|
|
|
|
|
|
|
|
/// SourceIds - Reverse map from source id to directory id + file id pair.
|
|
|
|
///
|
|
|
|
SmallVector<std::pair<unsigned, unsigned>, 8> SourceIds;
|
|
|
|
|
2010-02-11 00:03:48 +08:00
|
|
|
/// Lines - List of source line correspondence.
|
2009-05-15 17:23:25 +08:00
|
|
|
std::vector<SrcLineInfo> Lines;
|
|
|
|
|
2010-04-01 03:34:01 +08:00
|
|
|
/// DIEBlocks - A list of all the DIEBlocks in use.
|
|
|
|
std::vector<DIEBlock *> DIEBlocks;
|
|
|
|
|
|
|
|
// DIEValueAllocator - All DIEValues are allocated through this allocator.
|
|
|
|
BumpPtrAllocator DIEValueAllocator;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-03-13 10:17:42 +08:00
|
|
|
/// StringPool - A String->Symbol mapping of strings used by indirect
|
|
|
|
/// references.
|
|
|
|
StringMap<std::pair<MCSymbol*, unsigned> > StringPool;
|
|
|
|
unsigned NextStringPoolNumber;
|
|
|
|
|
|
|
|
MCSymbol *getStringPoolEntry(StringRef Str);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// SectionMap - Provides a unique id per text section.
|
|
|
|
///
|
2009-08-01 02:48:30 +08:00
|
|
|
UniqueVector<const MCSection*> SectionMap;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// SectionSourceLines - Tracks line numbers per text section.
|
|
|
|
///
|
|
|
|
std::vector<std::vector<SrcLineInfo> > SectionSourceLines;
|
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
// CurrentFnDbgScope - Top level scope for the current function.
|
2009-05-15 17:23:25 +08:00
|
|
|
//
|
2009-11-11 07:06:00 +08:00
|
|
|
DbgScope *CurrentFnDbgScope;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-03-13 01:45:06 +08:00
|
|
|
/// DbgScopeMap - Tracks the scopes in the current function. Owns the
|
|
|
|
/// contained DbgScope*s.
|
2009-11-11 07:06:00 +08:00
|
|
|
///
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, DbgScope *> DbgScopeMap;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
/// ConcreteScopes - Tracks the concrete scopees in the current function.
|
|
|
|
/// These scopes are also included in DbgScopeMap.
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, DbgScope *> ConcreteScopes;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
|
|
|
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
|
2010-03-13 01:45:06 +08:00
|
|
|
/// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, DbgScope *> AbstractScopes;
|
2010-03-25 23:09:44 +08:00
|
|
|
|
|
|
|
/// AbstractScopesList - Tracks abstract scopes constructed while processing
|
|
|
|
/// a function. This list is cleared during endFunction().
|
2009-11-11 07:06:00 +08:00
|
|
|
SmallVector<DbgScope *, 4>AbstractScopesList;
|
|
|
|
|
2010-03-13 01:45:06 +08:00
|
|
|
/// AbstractVariables - Collection on abstract variables. Owned by the
|
|
|
|
/// DbgScopes in AbstractScopes.
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2010-03-30 06:59:58 +08:00
|
|
|
/// DbgValueStartMap - Tracks starting scope of variable DIEs.
|
|
|
|
/// If the scope of an object begins sometime after the low pc value for the
|
|
|
|
/// scope most closely enclosing the object, the object entry may have a
|
|
|
|
/// DW_AT_start_scope attribute.
|
|
|
|
DenseMap<const MachineInstr *, DbgVariable *> DbgValueStartMap;
|
|
|
|
|
2010-05-21 00:36:41 +08:00
|
|
|
/// DbgVariableToFrameIndexMap - Tracks frame index used to find
|
|
|
|
/// variable's value.
|
|
|
|
DenseMap<const DbgVariable *, int> DbgVariableToFrameIndexMap;
|
|
|
|
|
|
|
|
/// DbgVariableToDbgInstMap - Maps DbgVariable to corresponding DBG_VALUE
|
|
|
|
/// machine instruction.
|
|
|
|
DenseMap<const DbgVariable *, const MachineInstr *> DbgVariableToDbgInstMap;
|
|
|
|
|
|
|
|
/// DbgVariableLabelsMap - Maps DbgVariable to corresponding MCSymbol.
|
|
|
|
DenseMap<const DbgVariable *, const MCSymbol *> DbgVariableLabelsMap;
|
|
|
|
|
|
|
|
/// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
|
|
|
|
/// DbgVariable, if any.
|
|
|
|
DenseMap<const DbgVariable *, const DbgVariable *> VarToAbstractVarMap;
|
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
/// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked
|
|
|
|
/// (at the end of the module) as DW_AT_inline.
|
|
|
|
SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
|
|
|
|
|
2010-04-15 08:02:49 +08:00
|
|
|
/// ContainingTypeMap - This map is used to keep track of subprogram DIEs that
|
|
|
|
/// need DW_AT_containing_type attribute. This attribute points to a DIE that
|
|
|
|
/// corresponds to the MDNode mapped with the subprogram DIE.
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<DIE *, const MDNode *> ContainingTypeMap;
|
2009-12-04 03:11:07 +08:00
|
|
|
|
2010-05-20 05:58:28 +08:00
|
|
|
typedef SmallVector<DbgScope *, 2> ScopeVector;
|
|
|
|
SmallPtrSet<const MachineInstr *, 8> InsnsBeginScopeSet;
|
2010-04-09 00:50:29 +08:00
|
|
|
SmallPtrSet<const MachineInstr *, 8> InsnsEndScopeSet;
|
2009-10-02 04:31:14 +08:00
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
/// InlineInfo - Keep track of inlined functions and their location. This
|
|
|
|
/// information is used to populate debug_inlined section.
|
2010-05-08 04:54:48 +08:00
|
|
|
typedef std::pair<MCSymbol *, DIE *> InlineInfoLabels;
|
|
|
|
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
|
|
|
|
SmallVector<const MDNode *, 4> InlinedSPNodes;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-04-28 03:46:33 +08:00
|
|
|
/// LabelsBeforeInsn - Maps instruction with label emitted before
|
2010-04-09 00:50:29 +08:00
|
|
|
/// instruction.
|
2010-04-28 03:46:33 +08:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
|
2010-04-09 00:50:29 +08:00
|
|
|
|
2010-04-28 03:46:33 +08:00
|
|
|
/// LabelsAfterInsn - Maps instruction with label emitted after
|
2010-04-09 00:50:29 +08:00
|
|
|
/// instruction.
|
2010-04-28 03:46:33 +08:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
|
2010-04-09 00:50:29 +08:00
|
|
|
|
2010-04-17 07:33:45 +08:00
|
|
|
SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
|
2010-04-23 04:56:35 +08:00
|
|
|
|
2010-03-30 01:20:31 +08:00
|
|
|
/// Previous instruction's location information. This is used to determine
|
|
|
|
/// label location to indicate scope boundries in dwarf debug info.
|
2010-04-03 03:42:39 +08:00
|
|
|
DebugLoc PrevInstLoc;
|
2010-04-17 07:33:45 +08:00
|
|
|
MCSymbol *PrevLabel;
|
2010-03-30 01:20:31 +08:00
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
struct FunctionDebugFrameInfo {
|
|
|
|
unsigned Number;
|
|
|
|
std::vector<MachineMove> Moves;
|
|
|
|
|
|
|
|
FunctionDebugFrameInfo(unsigned Num, const std::vector<MachineMove> &M)
|
|
|
|
: Number(Num), Moves(M) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FunctionDebugFrameInfo> DebugFrames;
|
|
|
|
|
2010-04-05 06:59:04 +08:00
|
|
|
// Section Symbols: these are assembler temporary labels that are emitted at
|
|
|
|
// the beginning of each supported dwarf section. These are used to form
|
|
|
|
// section offsets and are created by EmitSectionLabels.
|
|
|
|
MCSymbol *DwarfFrameSectionSym, *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
|
2010-04-17 07:33:45 +08:00
|
|
|
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
|
2010-04-28 03:46:33 +08:00
|
|
|
|
|
|
|
MCSymbol *FunctionBeginSym;
|
2010-04-05 06:59:04 +08:00
|
|
|
private:
|
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
/// getSourceDirectoryAndFileIds - Return the directory and file ids that
|
|
|
|
/// maps to the source id. Source id starts at 1.
|
|
|
|
std::pair<unsigned, unsigned>
|
|
|
|
getSourceDirectoryAndFileIds(unsigned SId) const {
|
|
|
|
return SourceIds[SId-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getNumSourceDirectories - Return the number of source directories in the
|
|
|
|
/// debug info.
|
|
|
|
unsigned getNumSourceDirectories() const {
|
|
|
|
return DirectoryNames.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getSourceDirectoryName - Return the name of the directory corresponding
|
|
|
|
/// to the id.
|
|
|
|
const std::string &getSourceDirectoryName(unsigned Id) const {
|
|
|
|
return DirectoryNames[Id - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getSourceFileName - Return the name of the source file corresponding
|
|
|
|
/// to the id.
|
|
|
|
const std::string &getSourceFileName(unsigned Id) const {
|
|
|
|
return SourceFileNames[Id - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getNumSourceIds - Return the number of unique source ids.
|
|
|
|
unsigned getNumSourceIds() const {
|
|
|
|
return SourceIds.size();
|
|
|
|
}
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// assignAbbrevNumber - Define a unique number for the abbreviation.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
|
2009-05-21 07:24:48 +08:00
|
|
|
/// information entry.
|
2010-03-13 01:45:06 +08:00
|
|
|
DIEEntry *createDIEEntry(DIE *Entry);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addUInt - Add an unsigned integer attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addSInt - Add an signed integer attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addString - Add a string attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addString(DIE *Die, unsigned Attribute, unsigned Form,
|
2009-11-25 03:42:17 +08:00
|
|
|
const StringRef Str);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addLabel - Add a Dwarf label attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
|
2010-03-09 06:23:36 +08:00
|
|
|
const MCSymbol *Label);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addDelta - Add a label delta attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
|
2010-03-09 06:23:36 +08:00
|
|
|
const MCSymbol *Hi, const MCSymbol *Lo);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addDIEEntry - Add a DIE attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2010-04-05 13:24:55 +08:00
|
|
|
void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addBlock - Add block data.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addSourceLine - Add location information to specified debug information
|
2009-05-15 17:23:25 +08:00
|
|
|
/// entry.
|
2009-11-21 10:48:08 +08:00
|
|
|
void addSourceLine(DIE *Die, const DIVariable *V);
|
2010-05-08 07:19:07 +08:00
|
|
|
void addSourceLine(DIE *Die, const DIGlobalVariable *G);
|
2009-11-21 10:48:08 +08:00
|
|
|
void addSourceLine(DIE *Die, const DISubprogram *SP);
|
|
|
|
void addSourceLine(DIE *Die, const DIType *Ty);
|
2009-12-16 03:16:48 +08:00
|
|
|
void addSourceLine(DIE *Die, const DINameSpace *NS);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addAddress - Add an address attribute to a die based on the location
|
2009-05-15 17:23:25 +08:00
|
|
|
/// provided.
|
2009-11-21 10:48:08 +08:00
|
|
|
void addAddress(DIE *Die, unsigned Attribute,
|
2009-05-15 17:23:25 +08:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2010-04-28 09:03:09 +08:00
|
|
|
/// addRegisterAddress - Add register location entry in variable DIE.
|
2010-05-21 00:36:41 +08:00
|
|
|
bool addRegisterAddress(DIE *Die, const MCSymbol *VS, const MachineOperand &MO);
|
2010-04-28 09:03:09 +08:00
|
|
|
|
|
|
|
/// addConstantValue - Add constant value entry in variable DIE.
|
2010-05-21 00:36:41 +08:00
|
|
|
bool addConstantValue(DIE *Die, const MCSymbol *VS, const MachineOperand &MO);
|
2010-04-28 09:03:09 +08:00
|
|
|
|
|
|
|
/// addConstantFPValue - Add constant value entry in variable DIE.
|
2010-05-21 00:36:41 +08:00
|
|
|
bool addConstantFPValue(DIE *Die, const MCSymbol *VS, const MachineOperand &MO);
|
2010-04-28 09:03:09 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addComplexAddress - Start with the address based on the location provided,
|
2009-09-30 08:08:22 +08:00
|
|
|
/// and generate the DWARF information necessary to find the actual variable
|
|
|
|
/// (navigating the extra location information encoded in the type) based on
|
|
|
|
/// the starting location. Add the DWARF information to the die.
|
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
2009-09-30 08:08:22 +08:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
// FIXME: Should be reformulated in terms of addComplexAddress.
|
|
|
|
/// addBlockByrefAddress - Start with the address based on the location
|
2009-09-01 05:19:37 +08:00
|
|
|
/// provided, and generate the DWARF information necessary to find the
|
|
|
|
/// actual Block variable (navigating the Block struct) based on the
|
2009-09-30 08:08:22 +08:00
|
|
|
/// starting location. Add the DWARF information to the die. Obsolete,
|
2009-11-21 10:48:08 +08:00
|
|
|
/// please use addComplexAddress instead.
|
2009-09-01 05:19:37 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
2009-09-01 05:19:37 +08:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2009-12-11 03:14:49 +08:00
|
|
|
/// addToContextOwner - Add Die into the list of its context owner's children.
|
|
|
|
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addType - Add a new type attribute to the specified entity.
|
2009-12-10 02:24:21 +08:00
|
|
|
void addType(DIE *Entity, DIType Ty);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-12-16 03:16:48 +08:00
|
|
|
|
|
|
|
/// getOrCreateNameSpace - Create a DIE for DINameSpace.
|
|
|
|
DIE *getOrCreateNameSpace(DINameSpace NS);
|
|
|
|
|
2009-12-11 02:05:33 +08:00
|
|
|
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
|
|
|
|
/// given DIType.
|
|
|
|
DIE *getOrCreateTypeDIE(DIType Ty);
|
|
|
|
|
2009-11-24 09:14:22 +08:00
|
|
|
void addPubTypes(DISubprogram SP);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
2009-12-10 02:24:21 +08:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 17:23:25 +08:00
|
|
|
DIBasicType BTy);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructTypeDIE - Construct derived type die from DIDerivedType.
|
2009-12-10 02:24:21 +08:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 17:23:25 +08:00
|
|
|
DIDerivedType DTy);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructTypeDIE - Construct type DIE from DICompositeType.
|
2009-12-10 02:24:21 +08:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 17:23:25 +08:00
|
|
|
DICompositeType CTy);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
|
|
|
|
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
|
2009-12-10 02:24:21 +08:00
|
|
|
void constructArrayTypeDIE(DIE &Buffer,
|
2009-05-15 17:23:25 +08:00
|
|
|
DICompositeType *CTy);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
2010-03-09 04:52:55 +08:00
|
|
|
DIE *constructEnumTypeDIE(DIEnumerator ETy);
|
2009-12-08 05:41:32 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// createGlobalVariableDIE - Create new DIE using GV.
|
2009-12-10 02:24:21 +08:00
|
|
|
DIE *createGlobalVariableDIE(const DIGlobalVariable &GV);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// createMemberDIE - Create new member DIE.
|
2009-12-10 02:24:21 +08:00
|
|
|
DIE *createMemberDIE(const DIDerivedType &DT);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// createSubprogramDIE - Create new DIE using SP.
|
2009-12-15 00:18:45 +08:00
|
|
|
DIE *createSubprogramDIE(const DISubprogram &SP, bool MakeDecl = false);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-04-28 03:46:33 +08:00
|
|
|
/// getOrCreateDbgScope - Create DbgScope for the scope.
|
2010-05-08 04:54:48 +08:00
|
|
|
DbgScope *getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt);
|
2009-11-13 03:02:56 +08:00
|
|
|
|
2010-05-08 04:54:48 +08:00
|
|
|
DbgScope *getOrCreateAbstractScope(const MDNode *N);
|
2009-11-11 07:06:00 +08:00
|
|
|
|
|
|
|
/// findAbstractVariable - Find abstract variable associated with Var.
|
2010-05-21 00:36:41 +08:00
|
|
|
DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// updateSubprogramScopeDIE - Find DIE for the given subprogram and
|
|
|
|
/// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
|
|
|
|
/// If there are global variables in this scope then create and insert
|
|
|
|
/// DIEs for these variables.
|
2010-05-08 04:54:48 +08:00
|
|
|
DIE *updateSubprogramScopeDIE(const MDNode *SPNode);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructLexicalScope - Construct new DW_TAG_lexical_block
|
|
|
|
/// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
|
|
|
|
DIE *constructLexicalScopeDIE(DbgScope *Scope);
|
|
|
|
|
|
|
|
/// constructInlinedScopeDIE - This scope represents inlined body of
|
|
|
|
/// a function. Construct DIE to represent this concrete inlined copy
|
|
|
|
/// of the function.
|
|
|
|
DIE *constructInlinedScopeDIE(DbgScope *Scope);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
2009-12-10 02:24:21 +08:00
|
|
|
DIE *constructVariableDIE(DbgVariable *DV, DbgScope *S);
|
2009-11-21 10:48:08 +08:00
|
|
|
|
|
|
|
/// constructScopeDIE - Construct a DIE for this scope.
|
|
|
|
DIE *constructScopeDIE(DbgScope *Scope);
|
|
|
|
|
2010-04-05 06:33:59 +08:00
|
|
|
/// EmitSectionLabels - Emit initial Dwarf sections with a label at
|
|
|
|
/// the start of each one.
|
|
|
|
void EmitSectionLabels();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDIE - Recusively Emits a debug information entry.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDIE(DIE *Die);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// computeSizeAndOffset - Compute the size and offset of a DIE.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset, bool Last);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// computeSizeAndOffsets - Compute the size and offset of all the DIEs.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void computeSizeAndOffsets();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-12-10 02:24:21 +08:00
|
|
|
/// EmitDebugInfo - Emit the debug info section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugInfo();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitAbbreviations - Emit the abbreviation section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitAbbreviations() const;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitEndOfLineMatrix - Emit the last address of the section and the end of
|
2009-05-15 17:23:25 +08:00
|
|
|
/// the line matrix.
|
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitEndOfLineMatrix(unsigned SectionEnd);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugLines - Emit source line information.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugLines();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitCommonDebugFrame - Emit common frame info into a debug frame section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitCommonDebugFrame();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitFunctionDebugFrame - Emit per function frame info into a debug frame
|
2009-05-15 17:23:25 +08:00
|
|
|
/// section.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugPubNames - Emit visible names into a debug pubnames section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugPubNames();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-24 09:14:22 +08:00
|
|
|
/// emitDebugPubTypes - Emit visible types into a debug pubtypes section.
|
|
|
|
///
|
|
|
|
void emitDebugPubTypes();
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugStr - Emit visible names into a debug str section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugStr();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugLoc - Emit visible names into a debug loc section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugLoc();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// EmitDebugARanges - Emit visible names into a debug aranges section.
|
|
|
|
///
|
|
|
|
void EmitDebugARanges();
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugRanges - Emit visible names into a debug ranges section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugRanges();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugMacInfo - Emit visible names into a debug macinfo section.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugMacInfo();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// emitDebugInlineInfo - Emit inline info using following format.
|
2009-05-15 17:23:25 +08:00
|
|
|
/// Section Header:
|
|
|
|
/// 1. length of section
|
|
|
|
/// 2. Dwarf version number
|
|
|
|
/// 3. address size.
|
|
|
|
///
|
|
|
|
/// Entries (one "entry" for each function that was inlined):
|
|
|
|
///
|
|
|
|
/// 1. offset into __debug_str section for MIPS linkage name, if exists;
|
|
|
|
/// otherwise offset into __debug_str for regular function name.
|
|
|
|
/// 2. offset into __debug_str section for regular function name.
|
|
|
|
/// 3. an unsigned LEB128 number indicating the number of distinct inlining
|
|
|
|
/// instances for the function.
|
|
|
|
///
|
|
|
|
/// The rest of the entry consists of a {die_offset, low_pc} pair for each
|
|
|
|
/// inlined instance; the die_offset points to the inlined_subroutine die in
|
|
|
|
/// the __debug_info section, and the low_pc is the starting address for the
|
|
|
|
/// inlining instance.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugInlineInfo();
|
2009-05-21 07:19:06 +08:00
|
|
|
|
|
|
|
/// GetOrCreateSourceID - Look up the source id with the given directory and
|
|
|
|
/// source file names. If none currently exists, create a new id and insert it
|
2010-04-04 15:48:20 +08:00
|
|
|
/// in the SourceIds map. This can update DirectoryNames and SourceFileNames
|
|
|
|
/// maps as well.
|
2009-11-26 01:36:49 +08:00
|
|
|
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FileName);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2010-05-11 06:49:55 +08:00
|
|
|
/// constructCompileUnit - Create new CompileUnit for the given
|
|
|
|
/// metadata node with tag DW_TAG_compile_unit.
|
2010-05-08 04:54:48 +08:00
|
|
|
void constructCompileUnit(const MDNode *N);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2010-05-11 06:49:55 +08:00
|
|
|
/// getCompielUnit - Get CompileUnit DIE.
|
|
|
|
CompileUnit *getCompileUnit(const MDNode *N) const;
|
|
|
|
|
|
|
|
/// constructGlobalVariableDIE - Construct global variable DIE.
|
2010-05-08 04:54:48 +08:00
|
|
|
void constructGlobalVariableDIE(const MDNode *N);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2010-05-11 06:49:55 +08:00
|
|
|
/// construct SubprogramDIE - Construct subprogram DIE.
|
2010-05-08 04:54:48 +08:00
|
|
|
void constructSubprogramDIE(const MDNode *N);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2009-09-30 08:08:22 +08:00
|
|
|
// FIXME: This should go away in favor of complex addresses.
|
2009-09-01 05:19:37 +08:00
|
|
|
/// Find the type the programmer originally declared the variable to be
|
2009-09-30 08:08:22 +08:00
|
|
|
/// and return that type. Obsolete, use GetComplexAddrType instead.
|
2009-09-01 05:19:37 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
DIType getBlockByrefType(DIType Ty, std::string Name);
|
2009-09-01 05:19:37 +08:00
|
|
|
|
2010-03-09 12:54:43 +08:00
|
|
|
/// recordSourceLine - Register a source line with debug info. Returns the
|
|
|
|
/// unique label that was emitted and which provides correspondence to
|
|
|
|
/// the source line list.
|
2010-05-08 04:54:48 +08:00
|
|
|
MCSymbol *recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope);
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// getSourceLineCount - Return the number of source lines in the debug
|
2009-05-15 17:23:25 +08:00
|
|
|
/// info.
|
2009-11-21 10:48:08 +08:00
|
|
|
unsigned getSourceLineCount() const {
|
2009-05-15 17:23:25 +08:00
|
|
|
return Lines.size();
|
|
|
|
}
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2010-05-21 00:36:41 +08:00
|
|
|
/// recordVariableFrameIndex - Record a variable's index.
|
|
|
|
void recordVariableFrameIndex(const DbgVariable *V, int Index);
|
|
|
|
|
|
|
|
/// findVariableFrameIndex - Return true if frame index for the variable
|
|
|
|
/// is found. Update FI to hold value of the index.
|
|
|
|
bool findVariableFrameIndex(const DbgVariable *V, int *FI);
|
|
|
|
|
|
|
|
/// findVariableLabel - Find MCSymbol for the variable.
|
|
|
|
const MCSymbol *findVariableLabel(const DbgVariable *V);
|
|
|
|
|
2010-04-09 02:43:56 +08:00
|
|
|
/// identifyScopeMarkers() - Indentify instructions that are marking
|
|
|
|
/// beginning of or end of a scope.
|
|
|
|
void identifyScopeMarkers();
|
2010-04-08 23:37:09 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// extractScopeInformation - Scan machine instructions in this function
|
2009-10-02 04:31:14 +08:00
|
|
|
/// and collect DbgScopes. Return true, if atleast one scope was found.
|
2010-01-27 07:18:02 +08:00
|
|
|
bool extractScopeInformation();
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
2010-05-15 05:01:35 +08:00
|
|
|
void collectVariableInfo(const MachineFunction *);
|
2010-04-05 13:32:45 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Main entry points.
|
|
|
|
//
|
|
|
|
DwarfDebug(AsmPrinter *A, Module *M);
|
|
|
|
~DwarfDebug();
|
|
|
|
|
|
|
|
/// beginModule - Emit all Dwarf sections that should come prior to the
|
|
|
|
/// content.
|
|
|
|
void beginModule(Module *M);
|
|
|
|
|
|
|
|
/// endModule - Emit all Dwarf sections that should come after the content.
|
|
|
|
///
|
|
|
|
void endModule();
|
|
|
|
|
|
|
|
/// beginFunction - Gather pre-function debug information. Assumes being
|
|
|
|
/// emitted immediately after the function entry point.
|
|
|
|
void beginFunction(const MachineFunction *MF);
|
|
|
|
|
|
|
|
/// endFunction - Gather and emit post-function debug information.
|
|
|
|
///
|
|
|
|
void endFunction(const MachineFunction *MF);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-03-30 01:20:31 +08:00
|
|
|
/// beginScope - Process beginning of a scope.
|
|
|
|
void beginScope(const MachineInstr *MI);
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// endScope - Prcess end of a scope.
|
|
|
|
void endScope(const MachineInstr *MI);
|
2009-11-11 07:06:00 +08:00
|
|
|
};
|
2009-05-15 17:23:25 +08:00
|
|
|
} // End of namespace llvm
|
|
|
|
|
|
|
|
#endif
|