blob: 02d296ebd23582e947755b16bd2192a92ab9e2b7 [file] [log] [blame]
David Blaikie85f80d72014-04-23 18:54:00 +00001//===-- llvm/CodeGen/DwarfFile.h - Dwarf Debug Framework -------*- C++ -*--===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
11#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFFILE_H
David Blaikie85f80d72014-04-23 18:54:00 +000012
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/FoldingSet.h"
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringMap.h"
17#include "llvm/Support/Allocator.h"
David Blaikiee226b082014-04-23 21:04:59 +000018#include "AddressPool.h"
David Blaikiedaefdbf2014-04-25 21:34:35 +000019#include "DwarfStringPool.h"
David Blaikie85f80d72014-04-23 18:54:00 +000020
21#include <vector>
22#include <string>
23#include <memory>
24
25namespace llvm {
26class AsmPrinter;
27class DwarfUnit;
28class DIEAbbrev;
29class MCSymbol;
30class DIE;
31class StringRef;
32class DwarfDebug;
33class MCSection;
34class DwarfFile {
35 // Target of Dwarf emission, used for sizing of abbreviations.
36 AsmPrinter *Asm;
37
David Blaikie2b22b1e2014-10-23 00:16:03 +000038 DwarfDebug &DD;
39
David Blaikie85f80d72014-04-23 18:54:00 +000040 // Used to uniquely define abbreviations.
41 FoldingSet<DIEAbbrev> AbbreviationsSet;
42
43 // A list of all the unique abbreviations in use.
44 std::vector<DIEAbbrev *> Abbreviations;
45
46 // A pointer to all units in the section.
47 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
48
David Blaikiedaefdbf2014-04-25 21:34:35 +000049 DwarfStringPool StrPool;
David Blaikie85f80d72014-04-23 18:54:00 +000050
David Blaikie85f80d72014-04-23 18:54:00 +000051public:
David Blaikie2b22b1e2014-10-23 00:16:03 +000052 DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref,
53 BumpPtrAllocator &DA);
David Blaikie85f80d72014-04-23 18:54:00 +000054
55 ~DwarfFile();
56
57 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
58
59 /// \brief Compute the size and offset of a DIE given an incoming Offset.
60 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
61
62 /// \brief Compute the size and offset of all the DIEs.
63 void computeSizeAndOffsets();
64
65 /// \brief Define a unique number for the abbreviation.
66 void assignAbbrevNumber(DIEAbbrev &Abbrev);
67
68 /// \brief Add a unit to the list of CUs.
69 void addUnit(std::unique_ptr<DwarfUnit> U);
70
71 /// \brief Emit all of the units to the section listed with the given
72 /// abbreviation section.
David Blaikie2b22b1e2014-10-23 00:16:03 +000073 void emitUnits(const MCSymbol *ASectionSym);
David Blaikie85f80d72014-04-23 18:54:00 +000074
75 /// \brief Emit a set of abbreviations to the specific section.
76 void emitAbbrevs(const MCSection *);
77
78 /// \brief Emit all of the strings to the section given.
79 void emitStrings(const MCSection *StrSection,
David Blaikie6741bb02014-09-11 21:12:48 +000080 const MCSection *OffsetSection = nullptr);
David Blaikie85f80d72014-04-23 18:54:00 +000081
David Blaikie85f80d72014-04-23 18:54:00 +000082 /// \brief Returns the string pool.
David Blaikiedaefdbf2014-04-25 21:34:35 +000083 DwarfStringPool &getStringPool() { return StrPool; }
David Blaikie85f80d72014-04-23 18:54:00 +000084};
85}
86#endif