LLVM API Documentation
00001 //===-- llvm/CodeGen/DwarfFile.h - Dwarf Debug Framework -------*- C++ -*--===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H 00011 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H 00012 00013 #include "llvm/ADT/DenseMap.h" 00014 #include "llvm/ADT/FoldingSet.h" 00015 #include "llvm/ADT/SmallVector.h" 00016 #include "llvm/ADT/StringMap.h" 00017 #include "llvm/Support/Allocator.h" 00018 #include "AddressPool.h" 00019 #include "DwarfStringPool.h" 00020 00021 #include <vector> 00022 #include <string> 00023 #include <memory> 00024 00025 namespace llvm { 00026 class AsmPrinter; 00027 class DwarfUnit; 00028 class DIEAbbrev; 00029 class MCSymbol; 00030 class DIE; 00031 class StringRef; 00032 class DwarfDebug; 00033 class MCSection; 00034 class DwarfFile { 00035 // Target of Dwarf emission, used for sizing of abbreviations. 00036 AsmPrinter *Asm; 00037 00038 // Used to uniquely define abbreviations. 00039 FoldingSet<DIEAbbrev> AbbreviationsSet; 00040 00041 // A list of all the unique abbreviations in use. 00042 std::vector<DIEAbbrev *> Abbreviations; 00043 00044 // A pointer to all units in the section. 00045 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs; 00046 00047 DwarfStringPool StrPool; 00048 00049 public: 00050 DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA); 00051 00052 ~DwarfFile(); 00053 00054 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; } 00055 00056 /// \brief Compute the size and offset of a DIE given an incoming Offset. 00057 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset); 00058 00059 /// \brief Compute the size and offset of all the DIEs. 00060 void computeSizeAndOffsets(); 00061 00062 /// \brief Define a unique number for the abbreviation. 00063 void assignAbbrevNumber(DIEAbbrev &Abbrev); 00064 00065 /// \brief Add a unit to the list of CUs. 00066 void addUnit(std::unique_ptr<DwarfUnit> U); 00067 00068 /// \brief Emit all of the units to the section listed with the given 00069 /// abbreviation section. 00070 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym); 00071 00072 /// \brief Emit a set of abbreviations to the specific section. 00073 void emitAbbrevs(const MCSection *); 00074 00075 /// \brief Emit all of the strings to the section given. 00076 void emitStrings(const MCSection *StrSection, 00077 const MCSection *OffsetSection = nullptr); 00078 00079 /// \brief Returns the string pool. 00080 DwarfStringPool &getStringPool() { return StrPool; } 00081 }; 00082 } 00083 #endif