2014-04-23 18:54:00 +00: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-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
|
|
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
|
2014-04-23 18:54:00 +00:00
|
|
|
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "AddressPool.h"
|
|
|
|
#include "DwarfStringPool.h"
|
2014-04-23 18:54:00 +00: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"
|
|
|
|
#include <memory>
|
2015-01-14 11:23:27 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2014-04-23 18:54:00 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class AsmPrinter;
|
2014-10-23 00:16:05 +00:00
|
|
|
class DbgVariable;
|
2014-04-23 18:54:00 +00:00
|
|
|
class DwarfUnit;
|
|
|
|
class DIEAbbrev;
|
|
|
|
class MCSymbol;
|
|
|
|
class DIE;
|
2014-10-31 22:30:30 +00:00
|
|
|
class DISubprogram;
|
2014-10-23 00:16:05 +00:00
|
|
|
class LexicalScope;
|
2014-04-23 18:54:00 +00:00
|
|
|
class StringRef;
|
|
|
|
class DwarfDebug;
|
|
|
|
class MCSection;
|
|
|
|
class DwarfFile {
|
|
|
|
// Target of Dwarf emission, used for sizing of abbreviations.
|
|
|
|
AsmPrinter *Asm;
|
|
|
|
|
2014-10-23 00:16:03 +00:00
|
|
|
DwarfDebug ⅅ
|
|
|
|
|
2014-04-23 18:54:00 +00: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-25 21:34:35 +00:00
|
|
|
DwarfStringPool StrPool;
|
2014-04-23 18:54:00 +00:00
|
|
|
|
2014-10-24 17:57:34 +00:00
|
|
|
// Collection of dbg variables of a scope.
|
|
|
|
DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> ScopeVariables;
|
|
|
|
|
2014-11-01 17:21:26 +00:00
|
|
|
// Collection of abstract subprogram DIEs.
|
|
|
|
DenseMap<const MDNode *, DIE *> AbstractSPDies;
|
|
|
|
|
2014-11-04 22:12:18 +00: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-23 18:54:00 +00:00
|
|
|
public:
|
2014-10-23 00:16:03 +00:00
|
|
|
DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref,
|
|
|
|
BumpPtrAllocator &DA);
|
2014-04-23 18:54:00 +00: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 00:16:03 +00:00
|
|
|
void emitUnits(const MCSymbol *ASectionSym);
|
2014-04-23 18:54:00 +00: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-11 21:12:48 +00:00
|
|
|
const MCSection *OffsetSection = nullptr);
|
2014-04-23 18:54:00 +00:00
|
|
|
|
|
|
|
/// \brief Returns the string pool.
|
2014-04-25 21:34:35 +00:00
|
|
|
DwarfStringPool &getStringPool() { return StrPool; }
|
2014-10-23 00:16:05 +00:00
|
|
|
|
2015-02-10 23:18:28 +00:00
|
|
|
/// \returns false if the variable was merged with a previous one.
|
|
|
|
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
2014-10-24 17:57:34 +00:00
|
|
|
|
|
|
|
DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8>> &getScopeVariables() {
|
|
|
|
return ScopeVariables;
|
|
|
|
}
|
2014-11-01 17:21:26 +00:00
|
|
|
|
|
|
|
DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
|
|
|
|
return AbstractSPDies;
|
|
|
|
}
|
2014-11-04 22:12:18 +00: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-23 18:54:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|