2014-04-24 02:54:00 +08:00
|
|
|
//===-- llvm/CodeGen/DwarfFile.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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
|
|
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
|
2014-04-24 02:54:00 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/Support/Allocator.h"
|
2014-04-24 05:04:59 +08:00
|
|
|
#include "AddressPool.h"
|
2014-04-26 05:34:35 +08:00
|
|
|
#include "DwarfStringPool.h"
|
2014-04-24 02:54:00 +08:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class AsmPrinter;
|
2014-10-23 08:16:05 +08:00
|
|
|
class DbgVariable;
|
2014-04-24 02:54:00 +08:00
|
|
|
class DwarfUnit;
|
|
|
|
class DIEAbbrev;
|
|
|
|
class MCSymbol;
|
|
|
|
class DIE;
|
2014-11-01 06:30:30 +08:00
|
|
|
class DISubprogram;
|
2014-10-23 08:16:05 +08:00
|
|
|
class LexicalScope;
|
2014-04-24 02:54:00 +08:00
|
|
|
class StringRef;
|
|
|
|
class DwarfDebug;
|
|
|
|
class MCSection;
|
|
|
|
class DwarfFile {
|
|
|
|
// Target of Dwarf emission, used for sizing of abbreviations.
|
|
|
|
AsmPrinter *Asm;
|
|
|
|
|
2014-10-23 08:16:03 +08:00
|
|
|
DwarfDebug ⅅ
|
|
|
|
|
2014-04-24 02:54:00 +08:00
|
|
|
// Used to uniquely define abbreviations.
|
|
|
|
FoldingSet<DIEAbbrev> AbbreviationsSet;
|
|
|
|
|
|
|
|
// A list of all the unique abbreviations in use.
|
|
|
|
std::vector<DIEAbbrev *> Abbreviations;
|
|
|
|
|
|
|
|
// A pointer to all units in the section.
|
|
|
|
SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
|
|
|
|
|
2014-04-26 05:34:35 +08:00
|
|
|
DwarfStringPool StrPool;
|
2014-04-24 02:54:00 +08:00
|
|
|
|
2014-10-25 01:57:34 +08:00
|
|
|
// Collection of dbg variables of a scope.
|
|
|
|
DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> ScopeVariables;
|
|
|
|
|
2014-11-02 01:21:26 +08:00
|
|
|
// Collection of abstract subprogram DIEs.
|
|
|
|
DenseMap<const MDNode *, DIE *> AbstractSPDies;
|
|
|
|
|
2014-11-05 06:12:18 +08:00
|
|
|
/// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
|
|
|
|
/// be shared across CUs, that is why we keep the map here instead
|
|
|
|
/// of in DwarfCompileUnit.
|
|
|
|
DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
|
|
|
|
|
2014-04-24 02:54:00 +08:00
|
|
|
public:
|
2014-10-23 08:16:03 +08:00
|
|
|
DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref,
|
|
|
|
BumpPtrAllocator &DA);
|
2014-04-24 02:54:00 +08:00
|
|
|
|
|
|
|
~DwarfFile();
|
|
|
|
|
|
|
|
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
|
|
|
|
|
|
|
|
/// \brief Compute the size and offset of a DIE given an incoming Offset.
|
|
|
|
unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
|
|
|
|
|
|
|
|
/// \brief Compute the size and offset of all the DIEs.
|
|
|
|
void computeSizeAndOffsets();
|
|
|
|
|
|
|
|
/// \brief Define a unique number for the abbreviation.
|
|
|
|
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
|
|
|
|
|
|
|
/// \brief Add a unit to the list of CUs.
|
|
|
|
void addUnit(std::unique_ptr<DwarfUnit> U);
|
|
|
|
|
|
|
|
/// \brief Emit all of the units to the section listed with the given
|
|
|
|
/// abbreviation section.
|
2014-10-23 08:16:03 +08:00
|
|
|
void emitUnits(const MCSymbol *ASectionSym);
|
2014-04-24 02:54:00 +08:00
|
|
|
|
|
|
|
/// \brief Emit a set of abbreviations to the specific section.
|
|
|
|
void emitAbbrevs(const MCSection *);
|
|
|
|
|
|
|
|
/// \brief Emit all of the strings to the section given.
|
|
|
|
void emitStrings(const MCSection *StrSection,
|
2014-09-12 05:12:48 +08:00
|
|
|
const MCSection *OffsetSection = nullptr);
|
2014-04-24 02:54:00 +08:00
|
|
|
|
|
|
|
/// \brief Returns the string pool.
|
2014-04-26 05:34:35 +08:00
|
|
|
DwarfStringPool &getStringPool() { return StrPool; }
|
2014-10-23 08:16:05 +08:00
|
|
|
|
2014-10-24 08:43:47 +08:00
|
|
|
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
2014-10-25 01:57:34 +08:00
|
|
|
|
|
|
|
DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> &getScopeVariables() {
|
|
|
|
return ScopeVariables;
|
|
|
|
}
|
2014-11-02 01:21:26 +08:00
|
|
|
|
|
|
|
DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
|
|
|
|
return AbstractSPDies;
|
|
|
|
}
|
2014-11-05 06:12:18 +08:00
|
|
|
|
|
|
|
void insertDIE(const MDNode *TypeMD, DIE *Die) {
|
|
|
|
MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
|
|
|
|
}
|
|
|
|
DIE *getDIE(const MDNode *TypeMD) {
|
|
|
|
return MDTypeNodeToDieMap.lookup(TypeMD);
|
|
|
|
}
|
2014-04-24 02:54:00 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|