2009-05-15 09:23:25 +00: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 06:12:01 +00:00
|
|
|
#include "DIE.h"
|
2010-01-19 06:19:05 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2009-05-15 09:23:25 +00:00
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
2010-04-05 05:24:55 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2009-05-15 09:23:25 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/UniqueVector.h"
|
2010-04-05 05:24:55 +00:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2009-05-15 09:23:25 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class CompileUnit;
|
|
|
|
class DbgConcreteScope;
|
2009-11-17 09:17:08 +00:00
|
|
|
class DbgScope;
|
|
|
|
class DbgVariable;
|
2009-05-15 09:23:25 +00:00
|
|
|
class MachineFrameInfo;
|
2010-04-05 05:24:55 +00:00
|
|
|
class MachineLocation;
|
2009-05-15 09:23:25 +00:00
|
|
|
class MachineModuleInfo;
|
2009-08-22 20:48:53 +00:00
|
|
|
class MCAsmInfo;
|
2010-04-05 05:24:55 +00: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 09:23:25 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// SrcLineInfo - This class is used to record source line correspondence.
|
|
|
|
///
|
2009-11-17 09:17:08 +00:00
|
|
|
class SrcLineInfo {
|
2009-05-15 09:23:25 +00:00
|
|
|
unsigned Line; // Source line number.
|
|
|
|
unsigned Column; // Source column.
|
|
|
|
unsigned SourceID; // Source ID number.
|
2010-03-14 08:15:55 +00:00
|
|
|
MCSymbol *Label; // Label in code ID number.
|
2009-05-15 09:23:25 +00:00
|
|
|
public:
|
2010-03-14 08:15:55 +00:00
|
|
|
SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
|
|
|
|
: Line(L), Column(C), SourceID(S), Label(label) {}
|
2009-05-15 09:23:25 +00:00
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getLine() const { return Line; }
|
|
|
|
unsigned getColumn() const { return Column; }
|
|
|
|
unsigned getSourceID() const { return SourceID; }
|
2010-03-14 08:15:55 +00:00
|
|
|
MCSymbol *getLabel() const { return Label; }
|
2009-05-15 09:23:25 +00:00
|
|
|
};
|
|
|
|
|
2010-04-05 00:13:49 +00:00
|
|
|
class DwarfDebug {
|
|
|
|
/// Asm - Target of Dwarf emission.
|
|
|
|
AsmPrinter *Asm;
|
2010-04-05 05:31:04 +00:00
|
|
|
|
2010-04-05 00:13:49 +00:00
|
|
|
/// MMI - Collected machine module information.
|
|
|
|
MachineModuleInfo *MMI;
|
|
|
|
|
2009-05-15 09:23:25 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Attributes used to construct specific Dwarf sections.
|
|
|
|
//
|
|
|
|
|
2009-06-29 20:45:18 +00:00
|
|
|
/// ModuleCU - All DIEs are inserted in ModuleCU.
|
|
|
|
CompileUnit *ModuleCU;
|
2009-05-15 09:23:25 +00: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-10 16:03:48 +00:00
|
|
|
/// Lines - List of source line correspondence.
|
2009-05-15 09:23:25 +00:00
|
|
|
std::vector<SrcLineInfo> Lines;
|
|
|
|
|
2010-03-31 19:34:01 +00: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 09:23:25 +00:00
|
|
|
|
2010-03-13 02:17:42 +00: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 09:23:25 +00:00
|
|
|
|
|
|
|
/// SectionMap - Provides a unique id per text section.
|
|
|
|
///
|
2009-07-31 18:48:30 +00:00
|
|
|
UniqueVector<const MCSection*> SectionMap;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
|
|
|
/// SectionSourceLines - Tracks line numbers per text section.
|
|
|
|
///
|
|
|
|
std::vector<std::vector<SrcLineInfo> > SectionSourceLines;
|
|
|
|
|
2009-11-10 23:06:00 +00:00
|
|
|
// CurrentFnDbgScope - Top level scope for the current function.
|
2009-05-15 09:23:25 +00:00
|
|
|
//
|
2009-11-10 23:06:00 +00:00
|
|
|
DbgScope *CurrentFnDbgScope;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2010-03-12 17:45:06 +00:00
|
|
|
/// DbgScopeMap - Tracks the scopes in the current function. Owns the
|
|
|
|
/// contained DbgScope*s.
|
2009-11-10 23:06:00 +00:00
|
|
|
///
|
2010-01-19 06:19:05 +00:00
|
|
|
DenseMap<MDNode *, DbgScope *> DbgScopeMap;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-10 23:06:00 +00:00
|
|
|
/// ConcreteScopes - Tracks the concrete scopees in the current function.
|
|
|
|
/// These scopes are also included in DbgScopeMap.
|
2010-01-19 06:19:05 +00:00
|
|
|
DenseMap<MDNode *, DbgScope *> ConcreteScopes;
|
2009-11-10 23:06:00 +00:00
|
|
|
|
|
|
|
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
|
2010-03-12 17:45:06 +00:00
|
|
|
/// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
|
2010-01-19 06:19:05 +00:00
|
|
|
DenseMap<MDNode *, DbgScope *> AbstractScopes;
|
2010-03-25 15:09:44 +00:00
|
|
|
|
|
|
|
/// AbstractScopesList - Tracks abstract scopes constructed while processing
|
|
|
|
/// a function. This list is cleared during endFunction().
|
2009-11-10 23:06:00 +00:00
|
|
|
SmallVector<DbgScope *, 4>AbstractScopesList;
|
|
|
|
|
2010-03-12 17:45:06 +00:00
|
|
|
/// AbstractVariables - Collection on abstract variables. Owned by the
|
|
|
|
/// DbgScopes in AbstractScopes.
|
2010-01-19 06:19:05 +00:00
|
|
|
DenseMap<MDNode *, DbgVariable *> AbstractVariables;
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2010-03-29 22:59:58 +00: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;
|
|
|
|
|
2009-11-10 23:06:00 +00: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 00:02:49 +00: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-01-19 06:19:05 +00:00
|
|
|
DenseMap<DIE *, MDNode *> ContainingTypeMap;
|
2009-12-03 19:11:07 +00:00
|
|
|
|
2009-11-10 23:06:00 +00:00
|
|
|
typedef SmallVector<DbgScope *, 2> ScopeVector;
|
2010-04-08 16:50:29 +00:00
|
|
|
SmallPtrSet<const MachineInstr *, 8> InsnsBeginScopeSet;
|
|
|
|
SmallPtrSet<const MachineInstr *, 8> InsnsEndScopeSet;
|
2009-10-01 20:31:14 +00:00
|
|
|
|
2009-05-15 09:23:25 +00:00
|
|
|
/// InlineInfo - Keep track of inlined functions and their location. This
|
|
|
|
/// information is used to populate debug_inlined section.
|
2010-03-09 00:31:02 +00:00
|
|
|
typedef std::pair<MCSymbol*, DIE *> InlineInfoLabels;
|
|
|
|
DenseMap<MDNode*, SmallVector<InlineInfoLabels, 4> > InlineInfo;
|
2009-11-10 23:06:00 +00:00
|
|
|
SmallVector<MDNode *, 4> InlinedSPNodes;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2010-04-27 19:46:33 +00:00
|
|
|
/// LabelsBeforeInsn - Maps instruction with label emitted before
|
2010-04-08 16:50:29 +00:00
|
|
|
/// instruction.
|
2010-04-27 19:46:33 +00:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
|
2010-04-08 16:50:29 +00:00
|
|
|
|
2010-04-27 19:46:33 +00:00
|
|
|
/// LabelsAfterInsn - Maps instruction with label emitted after
|
2010-04-08 16:50:29 +00:00
|
|
|
/// instruction.
|
2010-04-27 19:46:33 +00:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
|
2010-04-08 16:50:29 +00:00
|
|
|
|
2010-04-16 23:33:45 +00:00
|
|
|
SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
|
2010-04-22 20:56:35 +00:00
|
|
|
|
2010-03-29 17:20:31 +00:00
|
|
|
/// Previous instruction's location information. This is used to determine
|
|
|
|
/// label location to indicate scope boundries in dwarf debug info.
|
2010-04-02 19:42:39 +00:00
|
|
|
DebugLoc PrevInstLoc;
|
2010-04-16 23:33:45 +00:00
|
|
|
MCSymbol *PrevLabel;
|
2010-03-29 17:20:31 +00:00
|
|
|
|
2009-05-15 09:23:25 +00: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-04 22:59:04 +00: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-16 23:33:45 +00:00
|
|
|
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
|
2010-04-27 19:46:33 +00:00
|
|
|
|
|
|
|
MCSymbol *FunctionBeginSym;
|
2010-04-04 22:59:04 +00:00
|
|
|
private:
|
|
|
|
|
2009-05-15 09:23:25 +00: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 02:48:08 +00:00
|
|
|
/// assignAbbrevNumber - Define a unique number for the abbreviation.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
|
2009-05-20 23:24:48 +00:00
|
|
|
/// information entry.
|
2010-03-12 17:45:06 +00:00
|
|
|
DIEEntry *createDIEEntry(DIE *Entry);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addUInt - Add an unsigned integer attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addSInt - Add an signed integer attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addString - Add a string attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addString(DIE *Die, unsigned Attribute, unsigned Form,
|
2009-11-24 19:42:17 +00:00
|
|
|
const StringRef Str);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addLabel - Add a Dwarf label attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
|
2010-03-08 22:23:36 +00:00
|
|
|
const MCSymbol *Label);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addDelta - Add a label delta attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
|
2010-03-08 22:23:36 +00:00
|
|
|
const MCSymbol *Hi, const MCSymbol *Lo);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addDIEEntry - Add a DIE attribute data and value.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2010-04-05 05:24:55 +00:00
|
|
|
void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addBlock - Add block data.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addSourceLine - Add location information to specified debug information
|
2009-05-15 09:23:25 +00:00
|
|
|
/// entry.
|
2009-11-21 02:48:08 +00:00
|
|
|
void addSourceLine(DIE *Die, const DIVariable *V);
|
|
|
|
void addSourceLine(DIE *Die, const DIGlobal *G);
|
|
|
|
void addSourceLine(DIE *Die, const DISubprogram *SP);
|
|
|
|
void addSourceLine(DIE *Die, const DIType *Ty);
|
2009-12-15 19:16:48 +00:00
|
|
|
void addSourceLine(DIE *Die, const DINameSpace *NS);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addAddress - Add an address attribute to a die based on the location
|
2009-05-15 09:23:25 +00:00
|
|
|
/// provided.
|
2009-11-21 02:48:08 +00:00
|
|
|
void addAddress(DIE *Die, unsigned Attribute,
|
2009-05-15 09:23:25 +00:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addComplexAddress - Start with the address based on the location provided,
|
2009-09-30 00:08:22 +00: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 02:48:08 +00:00
|
|
|
void addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
2009-09-30 00:08:22 +00:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
// FIXME: Should be reformulated in terms of addComplexAddress.
|
|
|
|
/// addBlockByrefAddress - Start with the address based on the location
|
2009-08-31 21:19:37 +00:00
|
|
|
/// provided, and generate the DWARF information necessary to find the
|
|
|
|
/// actual Block variable (navigating the Block struct) based on the
|
2009-09-30 00:08:22 +00:00
|
|
|
/// starting location. Add the DWARF information to the die. Obsolete,
|
2009-11-21 02:48:08 +00:00
|
|
|
/// please use addComplexAddress instead.
|
2009-08-31 21:19:37 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
2009-08-31 21:19:37 +00:00
|
|
|
const MachineLocation &Location);
|
|
|
|
|
2009-12-10 19:14:49 +00:00
|
|
|
/// addToContextOwner - Add Die into the list of its context owner's children.
|
|
|
|
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// addType - Add a new type attribute to the specified entity.
|
2009-12-09 18:24:21 +00:00
|
|
|
void addType(DIE *Entity, DIType Ty);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-12-15 19:16:48 +00:00
|
|
|
|
|
|
|
/// getOrCreateNameSpace - Create a DIE for DINameSpace.
|
|
|
|
DIE *getOrCreateNameSpace(DINameSpace NS);
|
|
|
|
|
2009-12-10 18:05:33 +00:00
|
|
|
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
|
|
|
|
/// given DIType.
|
|
|
|
DIE *getOrCreateTypeDIE(DIType Ty);
|
|
|
|
|
2009-11-24 01:14:22 +00:00
|
|
|
void addPubTypes(DISubprogram SP);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
2009-12-09 18:24:21 +00:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 09:23:25 +00:00
|
|
|
DIBasicType BTy);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructTypeDIE - Construct derived type die from DIDerivedType.
|
2009-12-09 18:24:21 +00:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 09:23:25 +00:00
|
|
|
DIDerivedType DTy);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructTypeDIE - Construct type DIE from DICompositeType.
|
2009-12-09 18:24:21 +00:00
|
|
|
void constructTypeDIE(DIE &Buffer,
|
2009-05-15 09:23:25 +00:00
|
|
|
DICompositeType CTy);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
|
|
|
|
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
|
2009-12-09 18:24:21 +00:00
|
|
|
void constructArrayTypeDIE(DIE &Buffer,
|
2009-05-15 09:23:25 +00:00
|
|
|
DICompositeType *CTy);
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
2010-03-08 20:52:55 +00:00
|
|
|
DIE *constructEnumTypeDIE(DIEnumerator ETy);
|
2009-12-07 21:41:32 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// createGlobalVariableDIE - Create new DIE using GV.
|
2009-12-09 18:24:21 +00:00
|
|
|
DIE *createGlobalVariableDIE(const DIGlobalVariable &GV);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// createMemberDIE - Create new member DIE.
|
2009-12-09 18:24:21 +00:00
|
|
|
DIE *createMemberDIE(const DIDerivedType &DT);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// createSubprogramDIE - Create new DIE using SP.
|
2009-12-14 16:18:45 +00:00
|
|
|
DIE *createSubprogramDIE(const DISubprogram &SP, bool MakeDecl = false);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2010-04-27 19:46:33 +00:00
|
|
|
/// getOrCreateDbgScope - Create DbgScope for the scope.
|
|
|
|
DbgScope *getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt);
|
2009-11-12 19:02:56 +00:00
|
|
|
|
2009-11-10 23:06:00 +00:00
|
|
|
DbgScope *getOrCreateAbstractScope(MDNode *N);
|
|
|
|
|
|
|
|
/// findAbstractVariable - Find abstract variable associated with Var.
|
|
|
|
DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx,
|
2010-04-02 19:42:39 +00:00
|
|
|
DebugLoc Loc);
|
2010-03-15 18:33:46 +00:00
|
|
|
DbgVariable *findAbstractVariable(DIVariable &Var, const MachineInstr *MI,
|
2010-04-02 19:42:39 +00:00
|
|
|
DebugLoc Loc);
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2009-11-21 02:48:08 +00: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.
|
|
|
|
DIE *updateSubprogramScopeDIE(MDNode *SPNode);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00: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 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
2009-12-09 18:24:21 +00:00
|
|
|
DIE *constructVariableDIE(DbgVariable *DV, DbgScope *S);
|
2009-11-21 02:48:08 +00:00
|
|
|
|
|
|
|
/// constructScopeDIE - Construct a DIE for this scope.
|
|
|
|
DIE *constructScopeDIE(DbgScope *Scope);
|
|
|
|
|
2010-04-04 22:33:59 +00:00
|
|
|
/// EmitSectionLabels - Emit initial Dwarf sections with a label at
|
|
|
|
/// the start of each one.
|
|
|
|
void EmitSectionLabels();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDIE - Recusively Emits a debug information entry.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDIE(DIE *Die);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// computeSizeAndOffset - Compute the size and offset of a DIE.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset, bool Last);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// computeSizeAndOffsets - Compute the size and offset of all the DIEs.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void computeSizeAndOffsets();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-12-09 18:24:21 +00:00
|
|
|
/// EmitDebugInfo - Emit the debug info section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugInfo();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitAbbreviations - Emit the abbreviation section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitAbbreviations() const;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitEndOfLineMatrix - Emit the last address of the section and the end of
|
2009-05-15 09:23:25 +00:00
|
|
|
/// the line matrix.
|
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitEndOfLineMatrix(unsigned SectionEnd);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugLines - Emit source line information.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugLines();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitCommonDebugFrame - Emit common frame info into a debug frame section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitCommonDebugFrame();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitFunctionDebugFrame - Emit per function frame info into a debug frame
|
2009-05-15 09:23:25 +00:00
|
|
|
/// section.
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo);
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugPubNames - Emit visible names into a debug pubnames section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugPubNames();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-24 01:14:22 +00:00
|
|
|
/// emitDebugPubTypes - Emit visible types into a debug pubtypes section.
|
|
|
|
///
|
|
|
|
void emitDebugPubTypes();
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugStr - Emit visible names into a debug str section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugStr();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugLoc - Emit visible names into a debug loc section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugLoc();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
|
|
|
/// EmitDebugARanges - Emit visible names into a debug aranges section.
|
|
|
|
///
|
|
|
|
void EmitDebugARanges();
|
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugRanges - Emit visible names into a debug ranges section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugRanges();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugMacInfo - Emit visible names into a debug macinfo section.
|
2009-05-15 09:23:25 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugMacInfo();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// emitDebugInlineInfo - Emit inline info using following format.
|
2009-05-15 09:23:25 +00: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 02:48:08 +00:00
|
|
|
void emitDebugInlineInfo();
|
2009-05-20 23:19:06 +00: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 07:48:20 +00:00
|
|
|
/// in the SourceIds map. This can update DirectoryNames and SourceFileNames
|
|
|
|
/// maps as well.
|
2009-11-25 17:36:49 +00:00
|
|
|
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FileName);
|
2009-05-20 23:19:06 +00:00
|
|
|
|
2010-03-11 18:29:55 +00:00
|
|
|
void constructCompileUnit(MDNode *N);
|
2009-05-20 23:19:06 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
void constructGlobalVariableDIE(MDNode *N);
|
2009-05-20 23:19:06 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
void constructSubprogramDIE(MDNode *N);
|
2009-05-20 23:19:06 +00:00
|
|
|
|
2009-09-30 00:08:22 +00:00
|
|
|
// FIXME: This should go away in favor of complex addresses.
|
2009-08-31 21:19:37 +00:00
|
|
|
/// Find the type the programmer originally declared the variable to be
|
2009-09-30 00:08:22 +00:00
|
|
|
/// and return that type. Obsolete, use GetComplexAddrType instead.
|
2009-08-31 21:19:37 +00:00
|
|
|
///
|
2009-11-21 02:48:08 +00:00
|
|
|
DIType getBlockByrefType(DIType Ty, std::string Name);
|
2009-08-31 21:19:37 +00:00
|
|
|
|
2010-03-09 04:54:43 +00: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.
|
|
|
|
MCSymbol *recordSourceLine(unsigned Line, unsigned Col, MDNode *Scope);
|
2010-04-05 05:32:45 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// getSourceLineCount - Return the number of source lines in the debug
|
2009-05-15 09:23:25 +00:00
|
|
|
/// info.
|
2009-11-21 02:48:08 +00:00
|
|
|
unsigned getSourceLineCount() const {
|
2009-05-15 09:23:25 +00:00
|
|
|
return Lines.size();
|
|
|
|
}
|
2010-04-05 05:32:45 +00:00
|
|
|
|
2010-04-08 18:43:56 +00:00
|
|
|
/// identifyScopeMarkers() - Indentify instructions that are marking
|
|
|
|
/// beginning of or end of a scope.
|
|
|
|
void identifyScopeMarkers();
|
2010-04-08 15:37:09 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// extractScopeInformation - Scan machine instructions in this function
|
2009-10-01 20:31:14 +00:00
|
|
|
/// and collect DbgScopes. Return true, if atleast one scope was found.
|
2010-01-26 23:18:02 +00:00
|
|
|
bool extractScopeInformation();
|
2010-04-05 05:32:45 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
|
|
|
void collectVariableInfo();
|
2010-04-05 05:32:45 +00: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 09:23:25 +00:00
|
|
|
|
2010-03-29 17:20:31 +00:00
|
|
|
/// beginScope - Process beginning of a scope.
|
|
|
|
void beginScope(const MachineInstr *MI);
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2009-11-21 02:48:08 +00:00
|
|
|
/// endScope - Prcess end of a scope.
|
|
|
|
void endScope(const MachineInstr *MI);
|
2009-11-10 23:06:00 +00:00
|
|
|
};
|
2009-05-15 09:23:25 +00:00
|
|
|
} // End of namespace llvm
|
|
|
|
|
|
|
|
#endif
|