blob: 0ce9072fb1ee48a139a20014ea0b7fba221a1b83 [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;
David Blaikief2999472014-10-23 00:16:05 +000027class DbgVariable;
David Blaikie85f80d72014-04-23 18:54:00 +000028class DwarfUnit;
29class DIEAbbrev;
30class MCSymbol;
31class DIE;
David Blaikief2999472014-10-23 00:16:05 +000032class LexicalScope;
David Blaikie85f80d72014-04-23 18:54:00 +000033class StringRef;
34class DwarfDebug;
35class MCSection;
36class DwarfFile {
37 // Target of Dwarf emission, used for sizing of abbreviations.
38 AsmPrinter *Asm;
39
David Blaikie2b22b1e2014-10-23 00:16:03 +000040 DwarfDebug &DD;
41
David Blaikie85f80d72014-04-23 18:54:00 +000042 // Used to uniquely define abbreviations.
43 FoldingSet<DIEAbbrev> AbbreviationsSet;
44
45 // A list of all the unique abbreviations in use.
46 std::vector<DIEAbbrev *> Abbreviations;
47
48 // A pointer to all units in the section.
49 SmallVector<std::unique_ptr<DwarfUnit>, 1> CUs;
50
David Blaikiedaefdbf2014-04-25 21:34:35 +000051 DwarfStringPool StrPool;
David Blaikie85f80d72014-04-23 18:54:00 +000052
David Blaikie85f80d72014-04-23 18:54:00 +000053public:
David Blaikie2b22b1e2014-10-23 00:16:03 +000054 DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref,
55 BumpPtrAllocator &DA);
David Blaikie85f80d72014-04-23 18:54:00 +000056
57 ~DwarfFile();
58
59 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { return CUs; }
60
61 /// \brief Compute the size and offset of a DIE given an incoming Offset.
62 unsigned computeSizeAndOffset(DIE &Die, unsigned Offset);
63
64 /// \brief Compute the size and offset of all the DIEs.
65 void computeSizeAndOffsets();
66
67 /// \brief Define a unique number for the abbreviation.
68 void assignAbbrevNumber(DIEAbbrev &Abbrev);
69
70 /// \brief Add a unit to the list of CUs.
71 void addUnit(std::unique_ptr<DwarfUnit> U);
72
73 /// \brief Emit all of the units to the section listed with the given
74 /// abbreviation section.
David Blaikie2b22b1e2014-10-23 00:16:03 +000075 void emitUnits(const MCSymbol *ASectionSym);
David Blaikie85f80d72014-04-23 18:54:00 +000076
77 /// \brief Emit a set of abbreviations to the specific section.
78 void emitAbbrevs(const MCSection *);
79
80 /// \brief Emit all of the strings to the section given.
81 void emitStrings(const MCSection *StrSection,
David Blaikie6741bb02014-09-11 21:12:48 +000082 const MCSection *OffsetSection = nullptr);
David Blaikie85f80d72014-04-23 18:54:00 +000083
David Blaikie85f80d72014-04-23 18:54:00 +000084 /// \brief Returns the string pool.
David Blaikiedaefdbf2014-04-25 21:34:35 +000085 DwarfStringPool &getStringPool() { return StrPool; }
David Blaikief2999472014-10-23 00:16:05 +000086
87 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
David Blaikie3b5c8402014-10-23 22:04:30 +000088 void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
David Blaikie85f80d72014-04-23 18:54:00 +000089};
90}
91#endif