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 "DIE.h"
|
|
|
|
#include "DwarfPrinter.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
|
|
|
#include "llvm/CodeGen/MachineLocation.h"
|
|
|
|
#include "llvm/Analysis/DebugInfo.h"
|
|
|
|
#include "llvm/Support/raw_ostream.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"
|
2009-05-19 06:02:36 +08:00
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/UniqueVector.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
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;
|
|
|
|
class MachineModuleInfo;
|
2009-08-23 04:48:53 +08:00
|
|
|
class MCAsmInfo;
|
2009-05-15 17:23:25 +08:00
|
|
|
class Timer;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// 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.
|
|
|
|
unsigned LabelID; // Label in code ID number.
|
|
|
|
public:
|
|
|
|
SrcLineInfo(unsigned L, unsigned C, unsigned S, unsigned I)
|
|
|
|
: Line(L), Column(C), SourceID(S), LabelID(I) {}
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getLine() const { return Line; }
|
|
|
|
unsigned getColumn() const { return Column; }
|
|
|
|
unsigned getSourceID() const { return SourceID; }
|
|
|
|
unsigned getLabelID() const { return LabelID; }
|
|
|
|
};
|
|
|
|
|
2010-01-23 06:23:57 +08:00
|
|
|
class DwarfDebug : public DwarfPrinter {
|
2009-05-15 17:23:25 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Attributes used to construct specific Dwarf sections.
|
|
|
|
//
|
|
|
|
|
|
|
|
/// CompileUnitMap - A map of global variables representing compile units to
|
|
|
|
/// compile units.
|
|
|
|
DenseMap<Value *, CompileUnit *> CompileUnitMap;
|
|
|
|
|
|
|
|
/// CompileUnits - All the compile units in this module.
|
|
|
|
///
|
|
|
|
SmallVector<CompileUnit *, 8> CompileUnits;
|
|
|
|
|
2009-06-30 04:45:18 +08:00
|
|
|
/// ModuleCU - All DIEs are inserted in ModuleCU.
|
|
|
|
CompileUnit *ModuleCU;
|
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;
|
|
|
|
|
|
|
|
/// Lines - List of of source line correspondence.
|
|
|
|
std::vector<SrcLineInfo> Lines;
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// DIEValues - A list of all the unique values in use.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
std::vector<DIEValue *> DIEValues;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// StringPool - A UniqueVector of strings used by indirect references.
|
|
|
|
///
|
|
|
|
UniqueVector<std::string> StringPool;
|
|
|
|
|
|
|
|
/// 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;
|
|
|
|
|
|
|
|
/// didInitial - Flag to indicate if initial emission has been done.
|
|
|
|
///
|
|
|
|
bool didInitial;
|
|
|
|
|
|
|
|
/// shouldEmit - Flag to indicate if debug information should be emitted.
|
|
|
|
///
|
|
|
|
bool shouldEmit;
|
|
|
|
|
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
|
|
|
|
|
|
|
/// DbgScopeMap - Tracks the scopes in the current function.
|
2009-11-11 07:06:00 +08:00
|
|
|
///
|
2010-01-19 14:19:05 +08:00
|
|
|
DenseMap<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-01-19 14:19:05 +08:00
|
|
|
DenseMap<MDNode *, DbgScope *> ConcreteScopes;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
|
|
|
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
|
|
|
|
/// not included DbgScopeMap.
|
2010-01-19 14:19:05 +08:00
|
|
|
DenseMap<MDNode *, DbgScope *> AbstractScopes;
|
2009-11-11 07:06:00 +08:00
|
|
|
SmallVector<DbgScope *, 4>AbstractScopesList;
|
|
|
|
|
|
|
|
/// AbstractVariables - Collection on abstract variables.
|
2010-01-19 14:19:05 +08:00
|
|
|
DenseMap<MDNode *, DbgVariable *> AbstractVariables;
|
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-01-19 14:19:05 +08:00
|
|
|
DenseMap<DIE *, MDNode *> ContainingTypeMap;
|
2009-12-04 03:11:07 +08:00
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
/// AbstractSubprogramDIEs - Collection of abstruct subprogram DIEs.
|
|
|
|
SmallPtrSet<DIE *, 4> AbstractSubprogramDIEs;
|
|
|
|
|
2009-12-03 09:25:38 +08:00
|
|
|
/// TopLevelDIEs - Collection of top level DIEs.
|
|
|
|
SmallPtrSet<DIE *, 4> TopLevelDIEs;
|
|
|
|
SmallVector<DIE *, 4> TopLevelDIEsVector;
|
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
typedef SmallVector<DbgScope *, 2> ScopeVector;
|
|
|
|
typedef DenseMap<const MachineInstr *, ScopeVector>
|
2009-10-02 04:31:14 +08:00
|
|
|
InsnToDbgScopeMapTy;
|
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
/// DbgScopeBeginMap - Maps instruction with a list of DbgScopes it starts.
|
2009-10-02 04:31:14 +08:00
|
|
|
InsnToDbgScopeMapTy DbgScopeBeginMap;
|
|
|
|
|
|
|
|
/// DbgScopeEndMap - Maps instruction with a list DbgScopes it ends.
|
|
|
|
InsnToDbgScopeMapTy DbgScopeEndMap;
|
|
|
|
|
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.
|
2009-11-11 07:06:00 +08:00
|
|
|
typedef std::pair<unsigned, DIE *> InlineInfoLabels;
|
2010-01-19 14:19:05 +08:00
|
|
|
DenseMap<MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
|
2009-11-11 07:06:00 +08:00
|
|
|
SmallVector<MDNode *, 4> InlinedSPNodes;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
/// CompileUnitOffsets - A vector of the offsets of the compile units. This is
|
|
|
|
/// used when calculating the "origin" of a concrete instance of an inlined
|
|
|
|
/// function.
|
|
|
|
DenseMap<CompileUnit *, unsigned> CompileUnitOffsets;
|
|
|
|
|
|
|
|
/// DebugTimer - Timer for the Dwarf debug writer.
|
|
|
|
Timer *DebugTimer;
|
2009-07-14 05:26:33 +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;
|
|
|
|
|
|
|
|
/// 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.
|
2009-11-21 10:48:08 +08:00
|
|
|
DIEEntry *createDIEEntry(DIE *Entry = NULL);
|
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,
|
2009-05-15 17:23:25 +08:00
|
|
|
const DWLabel &Label);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addObjectLabel - Add an non-Dwarf label attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addObjectLabel(DIE *Die, unsigned Attribute, unsigned Form,
|
2010-01-17 02:50:28 +08:00
|
|
|
const MCSymbol *Sym);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addSectionOffset - Add a section offset label attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
|
2009-05-15 17:23:25 +08:00
|
|
|
const DWLabel &Label, const DWLabel &Section,
|
|
|
|
bool isEH = false, bool useSet = true);
|
|
|
|
|
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,
|
2009-05-15 17:23:25 +08:00
|
|
|
const DWLabel &Hi, const DWLabel &Lo);
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// addDIEEntry - Add a DIE attribute data and value.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry) {
|
|
|
|
Die->addValue(Attribute, Form, createDIEEntry(Entry));
|
2009-05-15 17:23:25 +08:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
void addSourceLine(DIE *Die, const DIGlobal *G);
|
|
|
|
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);
|
|
|
|
|
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.
|
2009-12-10 02:24:21 +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
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// findCompileUnit - Get the compile unit for the given descriptor.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-12-12 05:37:07 +08:00
|
|
|
CompileUnit *findCompileUnit(DICompileUnit Unit);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
/// getUpdatedDbgScope - Find or create DbgScope assicated with
|
|
|
|
/// the instruction. Initialize scope and update scope hierarchy.
|
|
|
|
DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt);
|
|
|
|
|
|
|
|
/// createDbgScope - Create DbgScope for the scope.
|
|
|
|
void createDbgScope(MDNode *Scope, MDNode *InlinedAt);
|
2009-11-13 03:02:56 +08:00
|
|
|
|
2009-11-11 07:06:00 +08:00
|
|
|
DbgScope *getOrCreateAbstractScope(MDNode *N);
|
|
|
|
|
|
|
|
/// findAbstractVariable - Find abstract variable associated with Var.
|
|
|
|
DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx,
|
|
|
|
DILocation &Loc);
|
|
|
|
|
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.
|
|
|
|
DIE *updateSubprogramScopeDIE(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);
|
|
|
|
|
|
|
|
/// emitInitial - Emit initial Dwarf declarations. This is necessary for cc
|
2009-05-15 17:23:25 +08:00
|
|
|
/// tools to recognize the object file contains Dwarf information.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitInitial();
|
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
|
|
|
|
/// 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
|
|
|
|
2009-12-12 05:37:07 +08:00
|
|
|
CompileUnit *constructCompileUnit(MDNode *N);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
void constructGlobalVariableDIE(MDNode *N);
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
void constructSubprogramDIE(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
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
public:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Main entry points.
|
|
|
|
//
|
2009-08-23 04:48:53 +08:00
|
|
|
DwarfDebug(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T);
|
2009-05-15 17:23:25 +08:00
|
|
|
virtual ~DwarfDebug();
|
|
|
|
|
|
|
|
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
|
|
|
|
/// be emitted.
|
|
|
|
bool ShouldEmitDwarfDebug() const { return shouldEmit; }
|
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// beginModule - Emit all Dwarf sections that should come prior to the
|
2009-05-15 17:23:25 +08:00
|
|
|
/// content.
|
2009-11-21 10:48:08 +08:00
|
|
|
void beginModule(Module *M, MachineModuleInfo *MMI);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// endModule - Emit all Dwarf sections that should come after the content.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void endModule();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// beginFunction - Gather pre-function debug information. Assumes being
|
2009-05-15 17:23:25 +08:00
|
|
|
/// emitted immediately after the function entry point.
|
2009-11-21 10:48:08 +08:00
|
|
|
void beginFunction(MachineFunction *MF);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// endFunction - Gather and emit post-function debug information.
|
2009-05-15 17:23:25 +08:00
|
|
|
///
|
2009-11-21 10:48:08 +08:00
|
|
|
void endFunction(MachineFunction *MF);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// recordSourceLine - Records location information and associates it with a
|
2009-05-15 17:23:25 +08:00
|
|
|
/// label. Returns a unique label ID used to generate a label and provide
|
|
|
|
/// correspondence to the source line list.
|
2009-11-21 10:48:08 +08:00
|
|
|
unsigned recordSourceLine(unsigned Line, unsigned Col, MDNode *Scope);
|
2009-05-15 17:23:25 +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();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be
|
|
|
|
/// timed. 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
|
|
|
|
/// SourceIds map. This can update DirectoryNames and SourceFileNames maps as
|
|
|
|
/// well.
|
|
|
|
unsigned getOrCreateSourceID(const std::string &DirName,
|
|
|
|
const std::string &FileName);
|
|
|
|
|
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.
|
2009-11-21 10:48:08 +08:00
|
|
|
bool extractScopeInformation(MachineFunction *MF);
|
2009-10-06 09:26:37 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
|
|
|
void collectVariableInfo();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2009-11-21 10:48:08 +08:00
|
|
|
/// beginScope - Process beginning of a scope starting at Label.
|
|
|
|
void beginScope(const MachineInstr *MI, unsigned Label);
|
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
|