blob: 3985eb28cd6d078b6da7a5c4660fb12d7d107623 [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
10#ifndef CODEGEN_ASMPRINTER_DWARFFILE_H__
11#define CODEGEN_ASMPRINTER_DWARFFILE_H__
12
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
38 // Used to uniquely define abbreviations.
39 FoldingSet<DIEAbbrev> AbbreviationsSet;
40
41 // A list of all the unique abbreviations in use.
42 std::vector<DIEAbbrev *> Abbreviations;
43
44 // A pointer to all units in the section.
45 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
46
David Blaikiedaefdbf2014-04-25 21:34:35 +000047 DwarfStringPool StrPool;
David Blaikie85f80d72014-04-23 18:54:00 +000048
David Blaikie85f80d72014-04-23 18:54:00 +000049public:
David Blaikiedaefdbf2014-04-25 21:34:35 +000050 DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA);
David Blaikie85f80d72014-04-23 18:54:00 +000051
52 ~DwarfFile();
53
54 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
55
56 /// \brief Compute the size and offset of a DIE given an incoming Offset.
57 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
58
59 /// \brief Compute the size and offset of all the DIEs.
60 void computeSizeAndOffsets();
61
62 /// \brief Define a unique number for the abbreviation.
63 void assignAbbrevNumber(DIEAbbrev &Abbrev);
64
65 /// \brief Add a unit to the list of CUs.
66 void addUnit(std::unique_ptr<DwarfUnit> U);
67
68 /// \brief Emit all of the units to the section listed with the given
69 /// abbreviation section.
70 void emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym);
71
72 /// \brief Emit a set of abbreviations to the specific section.
73 void emitAbbrevs(const MCSection *);
74
75 /// \brief Emit all of the strings to the section given.
76 void emitStrings(const MCSection *StrSection,
77 const MCSection *OffsetSection = nullptr,
78 const MCSymbol *StrSecSym = nullptr);
79
David Blaikie85f80d72014-04-23 18:54:00 +000080 /// \brief Returns the string pool.
David Blaikiedaefdbf2014-04-25 21:34:35 +000081 DwarfStringPool &getStringPool() { return StrPool; }
David Blaikie85f80d72014-04-23 18:54:00 +000082};
83}
84#endif