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__
|
|
|
|
|
2012-06-28 08:05:13 +08:00
|
|
|
#include "DIE.h"
|
|
|
|
#include "llvm/DebugInfo.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2011-08-11 04:55:27 +08:00
|
|
|
#include "llvm/CodeGen/LexicalScopes.h"
|
2011-07-19 06:29:13 +08:00
|
|
|
#include "llvm/MC/MachineLocation.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"
|
2010-09-14 04:04:49 +08:00
|
|
|
#include "llvm/Support/DebugLoc.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class CompileUnit;
|
2012-01-27 04:44:57 +08:00
|
|
|
class ConstantInt;
|
|
|
|
class ConstantFP;
|
2009-11-17 17:17:08 +08:00
|
|
|
class DbgVariable;
|
2009-05-15 17:23:25 +08:00
|
|
|
class MachineFrameInfo;
|
|
|
|
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;
|
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
|
|
|
};
|
|
|
|
|
2011-02-05 06:57:18 +08:00
|
|
|
/// DotDebugLocEntry - This struct describes location entries emitted in
|
|
|
|
/// .debug_loc section.
|
|
|
|
typedef struct DotDebugLocEntry {
|
|
|
|
const MCSymbol *Begin;
|
|
|
|
const MCSymbol *End;
|
|
|
|
MachineLocation Loc;
|
2011-04-28 10:22:40 +08:00
|
|
|
const MDNode *Variable;
|
2011-02-05 06:57:18 +08:00
|
|
|
bool Merged;
|
2011-06-02 06:03:25 +08:00
|
|
|
bool Constant;
|
2011-07-09 00:49:43 +08:00
|
|
|
enum EntryType {
|
|
|
|
E_Location,
|
|
|
|
E_Integer,
|
|
|
|
E_ConstantFP,
|
|
|
|
E_ConstantInt
|
|
|
|
};
|
|
|
|
enum EntryType EntryKind;
|
|
|
|
|
|
|
|
union {
|
|
|
|
int64_t Int;
|
|
|
|
const ConstantFP *CFP;
|
|
|
|
const ConstantInt *CIP;
|
|
|
|
} Constants;
|
2011-06-02 06:03:25 +08:00
|
|
|
DotDebugLocEntry()
|
|
|
|
: Begin(0), End(0), Variable(0), Merged(false),
|
2011-07-09 00:49:43 +08:00
|
|
|
Constant(false) { Constants.Int = 0;}
|
2011-04-28 10:22:40 +08:00
|
|
|
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
|
|
|
|
const MDNode *V)
|
2011-06-02 06:03:25 +08:00
|
|
|
: Begin(B), End(E), Loc(L), Variable(V), Merged(false),
|
2011-07-09 00:49:43 +08:00
|
|
|
Constant(false) { Constants.Int = 0; EntryKind = E_Location; }
|
2011-06-02 06:03:25 +08:00
|
|
|
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
|
|
|
|
: Begin(B), End(E), Variable(0), Merged(false),
|
2011-07-09 00:49:43 +08:00
|
|
|
Constant(true) { Constants.Int = i; EntryKind = E_Integer; }
|
|
|
|
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
|
|
|
|
: Begin(B), End(E), Variable(0), Merged(false),
|
|
|
|
Constant(true) { Constants.CFP = FPtr; EntryKind = E_ConstantFP; }
|
|
|
|
DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantInt *IPtr)
|
|
|
|
: Begin(B), End(E), Variable(0), Merged(false),
|
|
|
|
Constant(true) { Constants.CIP = IPtr; EntryKind = E_ConstantInt; }
|
2011-06-02 06:03:25 +08:00
|
|
|
|
2011-02-05 06:57:18 +08:00
|
|
|
/// Empty entries are also used as a trigger to emit temp label. Such
|
|
|
|
/// labels are referenced is used to find debug_loc offset for a given DIE.
|
|
|
|
bool isEmpty() { return Begin == 0 && End == 0; }
|
|
|
|
bool isMerged() { return Merged; }
|
|
|
|
void Merge(DotDebugLocEntry *Next) {
|
|
|
|
if (!(Begin && Loc == Next->Loc && End == Next->Begin))
|
|
|
|
return;
|
|
|
|
Next->Begin = Begin;
|
|
|
|
Merged = true;
|
|
|
|
}
|
2011-07-09 00:49:43 +08:00
|
|
|
bool isLocation() const { return EntryKind == E_Location; }
|
|
|
|
bool isInt() const { return EntryKind == E_Integer; }
|
|
|
|
bool isConstantFP() const { return EntryKind == E_ConstantFP; }
|
|
|
|
bool isConstantInt() const { return EntryKind == E_ConstantInt; }
|
|
|
|
int64_t getInt() { return Constants.Int; }
|
|
|
|
const ConstantFP *getConstantFP() { return Constants.CFP; }
|
|
|
|
const ConstantInt *getConstantInt() { return Constants.CIP; }
|
2011-02-05 06:57:18 +08:00
|
|
|
} DotDebugLocEntry;
|
|
|
|
|
2011-04-13 06:53:02 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DbgVariable - This class is used to track local variable information.
|
|
|
|
///
|
|
|
|
class DbgVariable {
|
|
|
|
DIVariable Var; // Variable Descriptor.
|
|
|
|
DIE *TheDIE; // Variable DIE.
|
|
|
|
unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
|
2011-08-16 03:01:20 +08:00
|
|
|
DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
|
2011-08-16 05:24:36 +08:00
|
|
|
const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
|
|
|
|
int FrameIndex;
|
2011-04-13 06:53:02 +08:00
|
|
|
public:
|
|
|
|
// AbsVar may be NULL.
|
2011-08-16 03:01:20 +08:00
|
|
|
DbgVariable(DIVariable V, DbgVariable *AV)
|
2011-08-16 05:24:36 +08:00
|
|
|
: Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
|
2011-08-16 05:35:16 +08:00
|
|
|
FrameIndex(~0) {}
|
2011-04-13 06:53:02 +08:00
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
DIVariable getVariable() const { return Var; }
|
|
|
|
void setDIE(DIE *D) { TheDIE = D; }
|
|
|
|
DIE *getDIE() const { return TheDIE; }
|
|
|
|
void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
|
|
|
|
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
|
|
|
StringRef getName() const { return Var.getName(); }
|
2011-08-16 03:01:20 +08:00
|
|
|
DbgVariable *getAbstractVariable() const { return AbsVar; }
|
2011-08-16 05:24:36 +08:00
|
|
|
const MachineInstr *getMInsn() const { return MInsn; }
|
|
|
|
void setMInsn(const MachineInstr *M) { MInsn = M; }
|
|
|
|
int getFrameIndex() const { return FrameIndex; }
|
|
|
|
void setFrameIndex(int FI) { FrameIndex = FI; }
|
2011-08-16 02:35:42 +08:00
|
|
|
// Translate tag to proper Dwarf tag.
|
|
|
|
unsigned getTag() const {
|
|
|
|
if (Var.getTag() == dwarf::DW_TAG_arg_variable)
|
|
|
|
return dwarf::DW_TAG_formal_parameter;
|
|
|
|
|
|
|
|
return dwarf::DW_TAG_variable;
|
|
|
|
}
|
2011-08-16 02:40:16 +08:00
|
|
|
/// isArtificial - Return true if DbgVariable is artificial.
|
|
|
|
bool isArtificial() const {
|
|
|
|
if (Var.isArtificial())
|
|
|
|
return true;
|
|
|
|
if (Var.getTag() == dwarf::DW_TAG_arg_variable
|
|
|
|
&& getType().isArtificial())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2011-04-13 06:53:02 +08:00
|
|
|
bool variableHasComplexAddress() const {
|
|
|
|
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
|
|
|
return Var.hasComplexAddress();
|
|
|
|
}
|
|
|
|
bool isBlockByrefVariable() const {
|
|
|
|
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
|
|
|
return Var.isBlockByrefVariable();
|
|
|
|
}
|
|
|
|
unsigned getNumAddrElements() const {
|
|
|
|
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
|
|
|
return Var.getNumAddrElements();
|
|
|
|
}
|
|
|
|
uint64_t getAddrElement(unsigned i) const {
|
|
|
|
return Var.getAddrElement(i);
|
|
|
|
}
|
|
|
|
DIType getType() const;
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2012-06-09 18:34:15 +08:00
|
|
|
/// DIEValueAllocator - All DIEValues are allocated through this allocator.
|
|
|
|
BumpPtrAllocator DIEValueAllocator;
|
|
|
|
|
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;
|
2011-08-17 06:09:43 +08:00
|
|
|
|
|
|
|
/// Maps MDNode with its corresponding CompileUnit.
|
2010-05-11 06:49:55 +08:00
|
|
|
DenseMap <const MDNode *, CompileUnit *> CUMap;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2011-08-17 06:09:43 +08:00
|
|
|
/// Maps subprogram MDNode with its corresponding CompileUnit.
|
|
|
|
DenseMap <const MDNode *, CompileUnit *> SPMap;
|
|
|
|
|
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;
|
|
|
|
|
2012-03-11 22:56:26 +08:00
|
|
|
/// SourceIdMap - Source id map, i.e. pair of source filename and directory,
|
|
|
|
/// separated by a zero byte, mapped to a unique id.
|
2012-06-09 18:34:15 +08:00
|
|
|
StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
|
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.
|
2012-06-09 18:34:15 +08:00
|
|
|
StringMap<std::pair<MCSymbol*, unsigned>, BumpPtrAllocator&> StringPool;
|
2010-03-13 10:17:42 +08:00
|
|
|
unsigned NextStringPoolNumber;
|
|
|
|
|
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
|
|
|
|
2011-03-02 06:58:55 +08:00
|
|
|
/// CurrentFnArguments - List of Arguments (DbgValues) for current function.
|
|
|
|
SmallVector<DbgVariable *, 8> CurrentFnArguments;
|
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
LexicalScopes LScopes;
|
2010-03-25 23:09:44 +08:00
|
|
|
|
2010-07-08 06:20:57 +08:00
|
|
|
/// AbstractSPDies - Collection of abstract subprogram DIEs.
|
|
|
|
DenseMap<const MDNode *, DIE *> AbstractSPDies;
|
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
/// ScopeVariables - Collection of dbg variables of a scope.
|
|
|
|
DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> > ScopeVariables;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
/// AbstractVariables - Collection on abstract variables.
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2010-05-26 07:40:22 +08:00
|
|
|
/// DotDebugLocEntries - Collection of DotDebugLocEntry.
|
|
|
|
SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
|
|
|
|
|
2011-10-19 06:40:18 +08:00
|
|
|
/// InlinedSubprogramDIEs - Collection of subprogram DIEs that are marked
|
2009-11-11 07:06:00 +08:00
|
|
|
/// (at the end of the module) as DW_AT_inline.
|
|
|
|
SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
|
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
/// InlineInfo - Keep track of inlined functions and their location. This
|
2012-03-02 09:57:55 +08:00
|
|
|
/// information is used to populate the debug_inlined section.
|
2010-05-26 07:40:22 +08:00
|
|
|
typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
|
2010-05-08 04:54:48 +08:00
|
|
|
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
|
|
|
|
SmallVector<const MDNode *, 4> InlinedSPNodes;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2010-06-29 02:25:03 +08:00
|
|
|
// ProcessedSPNodes - This is a collection of subprogram MDNodes that
|
|
|
|
// are processed to create DIEs.
|
|
|
|
SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
|
|
|
|
|
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
|
|
|
|
2011-03-26 10:19:36 +08:00
|
|
|
/// UserVariables - Every user variable mentioned by a DBG_VALUE instruction
|
|
|
|
/// in order of appearance.
|
|
|
|
SmallVector<const MDNode*, 8> UserVariables;
|
2010-05-27 03:37:24 +08:00
|
|
|
|
2011-03-26 10:19:36 +08:00
|
|
|
/// DbgValues - For each user variable, keep a list of DBG_VALUE
|
|
|
|
/// instructions in order. The list can also contain normal instructions that
|
|
|
|
/// clobber the previous DBG_VALUE.
|
|
|
|
typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
|
|
|
|
DbgValueHistoryMap;
|
|
|
|
DbgValueHistoryMap DbgValues;
|
2011-03-23 06:33:08 +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
|
|
|
|
2011-05-12 03:22:19 +08:00
|
|
|
/// PrologEndLoc - This location indicates end of function prologue and
|
|
|
|
/// beginning of function body.
|
|
|
|
DebugLoc PrologEndLoc;
|
|
|
|
|
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.
|
2011-05-06 22:56:22 +08:00
|
|
|
MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
|
2010-04-17 07:33:45 +08:00
|
|
|
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
|
2010-05-26 07:40:22 +08:00
|
|
|
MCSymbol *DwarfDebugLocSectionSym;
|
|
|
|
MCSymbol *FunctionBeginSym, *FunctionEndSym;
|
2010-07-09 04:10:35 +08:00
|
|
|
|
2011-11-03 04:55:33 +08:00
|
|
|
// As an optimization, there is no need to emit an entry in the directory
|
|
|
|
// table for the same directory as DW_at_comp_dir.
|
|
|
|
StringRef CompilationDir;
|
|
|
|
|
2011-04-01 00:53:49 +08:00
|
|
|
private:
|
2009-05-15 17:23:25 +08:00
|
|
|
|
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
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
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.
|
2011-08-16 06:24:32 +08:00
|
|
|
DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, 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.
|
2011-08-16 06:24:32 +08:00
|
|
|
DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
|
2009-11-21 10:48:08 +08:00
|
|
|
|
|
|
|
/// constructInlinedScopeDIE - This scope represents inlined body of
|
|
|
|
/// a function. Construct DIE to represent this concrete inlined copy
|
|
|
|
/// of the function.
|
2011-08-16 06:24:32 +08:00
|
|
|
DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *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.
|
2011-08-11 04:55:27 +08:00
|
|
|
DIE *constructVariableDIE(DbgVariable *DV, LexicalScope *S);
|
2009-11-21 10:48:08 +08:00
|
|
|
|
|
|
|
/// constructScopeDIE - Construct a DIE for this scope.
|
2011-08-16 06:04:40 +08:00
|
|
|
DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
|
2009-11-21 10:48:08 +08:00
|
|
|
|
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
|
|
|
|
2011-10-19 06:39:43 +08:00
|
|
|
/// emitDIE - Recursively 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
|
|
|
|
2011-11-07 17:24:32 +08:00
|
|
|
/// emitAccelNames - Emit visible names into a hashed accelerator table
|
|
|
|
/// section.
|
|
|
|
void emitAccelNames();
|
|
|
|
|
|
|
|
/// emitAccelObjC - Emit objective C classes and categories into a hashed
|
|
|
|
/// accelerator table section.
|
|
|
|
void emitAccelObjC();
|
|
|
|
|
|
|
|
/// emitAccelNamespace - Emit namespace dies into a hashed accelerator
|
|
|
|
/// table.
|
|
|
|
void emitAccelNamespaces();
|
|
|
|
|
|
|
|
/// emitAccelTypes() - Emit type dies into a hashed accelerator table.
|
2011-11-09 13:24:07 +08:00
|
|
|
///
|
2011-11-07 17:24:32 +08:00
|
|
|
void emitAccelTypes();
|
|
|
|
|
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.
|
|
|
|
///
|
2011-10-19 06:39:43 +08:00
|
|
|
/// The rest of the entry consists of a {die_offset, low_pc} pair for each
|
2009-05-15 17:23:25 +08:00
|
|
|
/// inlined instance; the die_offset points to the inlined_subroutine die in
|
2011-10-19 06:39:43 +08:00
|
|
|
/// 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
|
|
|
|
2010-05-11 06:49:55 +08:00
|
|
|
/// constructCompileUnit - Create new CompileUnit for the given
|
|
|
|
/// metadata node with tag DW_TAG_compile_unit.
|
2011-08-17 06:09:43 +08:00
|
|
|
CompileUnit *constructCompileUnit(const MDNode *N);
|
2010-05-11 06:49:55 +08:00
|
|
|
|
|
|
|
/// construct SubprogramDIE - Construct subprogram DIE.
|
2011-08-16 07:36:40 +08:00
|
|
|
void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
|
2009-05-21 07:19:06 +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.
|
2011-05-12 03:22:19 +08:00
|
|
|
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
|
|
|
|
unsigned Flags);
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2011-10-19 06:39:43 +08:00
|
|
|
/// identifyScopeMarkers() - Indentify instructions that are marking the
|
|
|
|
/// beginning of or ending of a scope.
|
2010-04-09 02:43:56 +08:00
|
|
|
void identifyScopeMarkers();
|
2010-04-08 23:37:09 +08:00
|
|
|
|
2011-03-02 06:58:55 +08:00
|
|
|
/// addCurrentFnArgument - If Var is an current function argument that add
|
|
|
|
/// it in CurrentFnArguments list.
|
|
|
|
bool addCurrentFnArgument(const MachineFunction *MF,
|
2011-08-11 04:55:27 +08:00
|
|
|
DbgVariable *Var, LexicalScope *Scope);
|
2011-03-02 06:58:55 +08:00
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
/// collectVariableInfo - Populate LexicalScope entries with variables' info.
|
2010-06-26 06:07:34 +08:00
|
|
|
void collectVariableInfo(const MachineFunction *,
|
|
|
|
SmallPtrSet<const MDNode *, 16> &ProcessedVars);
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2010-05-21 03:57:06 +08:00
|
|
|
/// collectVariableInfoFromMMITable - Collect variable information from
|
|
|
|
/// side table maintained by MMI.
|
|
|
|
void collectVariableInfoFromMMITable(const MachineFunction * MF,
|
|
|
|
SmallPtrSet<const MDNode *, 16> &P);
|
2011-03-26 10:19:36 +08:00
|
|
|
|
|
|
|
/// requestLabelBeforeInsn - Ensure that a label will be emitted before MI.
|
|
|
|
void requestLabelBeforeInsn(const MachineInstr *MI) {
|
|
|
|
LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getLabelBeforeInsn - Return Label preceding the instruction.
|
|
|
|
const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
|
|
|
|
|
|
|
|
/// requestLabelAfterInsn - Ensure that a label will be emitted after MI.
|
|
|
|
void requestLabelAfterInsn(const MachineInstr *MI) {
|
|
|
|
LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getLabelAfterInsn - Return Label immediately following the instruction.
|
|
|
|
const MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
|
|
|
|
|
2010-04-05 13:32:45 +08:00
|
|
|
public:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Main entry points.
|
|
|
|
//
|
|
|
|
DwarfDebug(AsmPrinter *A, Module *M);
|
|
|
|
~DwarfDebug();
|
|
|
|
|
2011-08-16 07:47:24 +08:00
|
|
|
/// collectInfoFromNamedMDNodes - Collect debug info from named mdnodes such
|
|
|
|
/// as llvm.dbg.enum and llvm.dbg.ty
|
|
|
|
void collectInfoFromNamedMDNodes(Module *M);
|
|
|
|
|
|
|
|
/// collectLegacyDebugInfo - Collect debug info using DebugInfoFinder.
|
2011-10-19 06:39:43 +08:00
|
|
|
/// FIXME - Remove this when DragonEgg switches to DIBuilder.
|
2011-08-16 07:47:24 +08:00
|
|
|
bool collectLegacyDebugInfo(Module *M);
|
|
|
|
|
2010-04-05 13:32:45 +08:00
|
|
|
/// 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-10-27 01:49:02 +08:00
|
|
|
/// beginInstruction - Process beginning of an instruction.
|
|
|
|
void beginInstruction(const MachineInstr *MI);
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2010-10-27 01:49:02 +08:00
|
|
|
/// endInstruction - Prcess end of an instruction.
|
|
|
|
void endInstruction(const MachineInstr *MI);
|
2011-04-13 06:53:02 +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.
|
|
|
|
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FullName);
|
|
|
|
|
|
|
|
/// createSubprogramDIE - Create new DIE using SP.
|
|
|
|
DIE *createSubprogramDIE(DISubprogram SP);
|
2011-10-27 14:44:11 +08:00
|
|
|
|
|
|
|
/// getStringPool - returns the entry into the start of the pool.
|
|
|
|
MCSymbol *getStringPool();
|
|
|
|
|
|
|
|
/// getStringPoolEntry - returns an entry into the string pool with the given
|
|
|
|
/// string text.
|
|
|
|
MCSymbol *getStringPoolEntry(StringRef Str);
|
2009-11-11 07:06:00 +08:00
|
|
|
};
|
2009-05-15 17:23:25 +08:00
|
|
|
} // End of namespace llvm
|
|
|
|
|
|
|
|
#endif
|