LCOV - code coverage report
Current view: top level - lib/CodeGen/AsmPrinter - DwarfDebug.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 37 70 52.9 %
Date: 2018-10-20 13:21:21 Functions: 6 37 16.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/CodeGen/DwarfDebug.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             : // This file contains support for writing dwarf debug info into asm files.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
      15             : #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
      16             : 
      17             : #include "AddressPool.h"
      18             : #include "DbgEntityHistoryCalculator.h"
      19             : #include "DebugHandlerBase.h"
      20             : #include "DebugLocStream.h"
      21             : #include "DwarfFile.h"
      22             : #include "llvm/ADT/ArrayRef.h"
      23             : #include "llvm/ADT/DenseMap.h"
      24             : #include "llvm/ADT/DenseSet.h"
      25             : #include "llvm/ADT/MapVector.h"
      26             : #include "llvm/ADT/STLExtras.h"
      27             : #include "llvm/ADT/SetVector.h"
      28             : #include "llvm/ADT/SmallPtrSet.h"
      29             : #include "llvm/ADT/SmallVector.h"
      30             : #include "llvm/ADT/StringMap.h"
      31             : #include "llvm/ADT/StringRef.h"
      32             : #include "llvm/BinaryFormat/Dwarf.h"
      33             : #include "llvm/CodeGen/AccelTable.h"
      34             : #include "llvm/CodeGen/MachineInstr.h"
      35             : #include "llvm/IR/DebugInfoMetadata.h"
      36             : #include "llvm/IR/DebugLoc.h"
      37             : #include "llvm/IR/Metadata.h"
      38             : #include "llvm/MC/MCDwarf.h"
      39             : #include "llvm/Support/Allocator.h"
      40             : #include "llvm/Target/TargetOptions.h"
      41             : #include <cassert>
      42             : #include <cstdint>
      43             : #include <limits>
      44             : #include <memory>
      45             : #include <utility>
      46             : #include <vector>
      47             : 
      48             : namespace llvm {
      49             : 
      50             : class AsmPrinter;
      51             : class ByteStreamer;
      52             : class DebugLocEntry;
      53             : class DIE;
      54             : class DwarfCompileUnit;
      55             : class DwarfTypeUnit;
      56             : class DwarfUnit;
      57             : class LexicalScope;
      58             : class MachineFunction;
      59             : class MCSection;
      60             : class MCSymbol;
      61             : class MDNode;
      62             : class Module;
      63             : 
      64             : //===----------------------------------------------------------------------===//
      65             : /// This class is defined as the common parent of DbgVariable and DbgLabel
      66             : /// such that it could levarage polymorphism to extract common code for
      67             : /// DbgVariable and DbgLabel.
      68             : class DbgEntity {
      69             :   const DINode *Entity;
      70             :   const DILocation *InlinedAt;
      71             :   DIE *TheDIE = nullptr;
      72             :   unsigned SubclassID;
      73             : 
      74             : public:
      75             :   enum DbgEntityKind {
      76             :     DbgVariableKind,
      77             :     DbgLabelKind
      78             :   };
      79             : 
      80             :   DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
      81           8 :     : Entity(N), InlinedAt(IA), SubclassID(ID) {}
      82           0 :   virtual ~DbgEntity() {}
      83             : 
      84             :   /// Accessors.
      85             :   /// @{
      86           0 :   const DINode *getEntity() const { return Entity; }
      87             :   const DILocation *getInlinedAt() const { return InlinedAt; }
      88           0 :   DIE *getDIE() const { return TheDIE; }
      89           0 :   unsigned getDbgEntityID() const { return SubclassID; }
      90             :   /// @}
      91             : 
      92           8 :   void setDIE(DIE &D) { TheDIE = &D; }
      93             : 
      94             :   static bool classof(const DbgEntity *N) {
      95             :     switch (N->getDbgEntityID()) {
      96             :     default:
      97             :       return false;
      98             :     case DbgVariableKind:
      99             :     case DbgLabelKind:
     100             :       return true;
     101             :     }
     102             :   }
     103             : };
     104             : 
     105             : //===----------------------------------------------------------------------===//
     106             : /// This class is used to track local variable information.
     107             : ///
     108             : /// Variables can be created from allocas, in which case they're generated from
     109             : /// the MMI table.  Such variables can have multiple expressions and frame
     110             : /// indices.
     111             : ///
     112             : /// Variables can be created from \c DBG_VALUE instructions.  Those whose
     113             : /// location changes over time use \a DebugLocListIndex, while those with a
     114             : /// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
     115             : ///
     116             : /// Variables that have been optimized out use none of these fields.
     117             : class DbgVariable : public DbgEntity {
     118             :   unsigned DebugLocListIndex = ~0u;          /// Offset in DebugLocs.
     119             :   const MachineInstr *MInsn = nullptr;       /// DBG_VALUE instruction.
     120             : 
     121             :   struct FrameIndexExpr {
     122             :     int FI;
     123             :     const DIExpression *Expr;
     124             :   };
     125             :   mutable SmallVector<FrameIndexExpr, 1>
     126             :       FrameIndexExprs; /// Frame index + expression.
     127             : 
     128             : public:
     129             :   /// Construct a DbgVariable.
     130             :   ///
     131             :   /// Creates a variable without any DW_AT_location.  Call \a initializeMMI()
     132             :   /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
     133             :   DbgVariable(const DILocalVariable *V, const DILocation *IA)
     134           0 :       : DbgEntity(V, IA, DbgVariableKind) {}
     135             : 
     136             :   /// Initialize from the MMI table.
     137             :   void initializeMMI(const DIExpression *E, int FI) {
     138             :     assert(FrameIndexExprs.empty() && "Already initialized?");
     139             :     assert(!MInsn && "Already initialized?");
     140             : 
     141             :     assert((!E || E->isValid()) && "Expected valid expression");
     142             :     assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
     143             : 
     144         644 :     FrameIndexExprs.push_back({FI, E});
     145             :   }
     146             : 
     147             :   /// Initialize from a DBG_VALUE instruction.
     148       60344 :   void initializeDbgValue(const MachineInstr *DbgValue) {
     149             :     assert(FrameIndexExprs.empty() && "Already initialized?");
     150             :     assert(!MInsn && "Already initialized?");
     151             : 
     152             :     assert(getVariable() == DbgValue->getDebugVariable() && "Wrong variable");
     153             :     assert(getInlinedAt() == DbgValue->getDebugLoc()->getInlinedAt() &&
     154             :            "Wrong inlined-at");
     155             : 
     156       60344 :     MInsn = DbgValue;
     157       60344 :     if (auto *E = DbgValue->getDebugExpression())
     158       60344 :       if (E->getNumElements())
     159       10627 :         FrameIndexExprs.push_back({0, E});
     160       60344 :   }
     161             : 
     162             :   // Accessors.
     163             :   const DILocalVariable *getVariable() const {
     164      381349 :     return cast<DILocalVariable>(getEntity());
     165             :   }
     166             : 
     167             :   const DIExpression *getSingleExpression() const {
     168             :     assert(MInsn && FrameIndexExprs.size() <= 1);
     169        6357 :     return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
     170             :   }
     171             : 
     172       47172 :   void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
     173           0 :   unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
     174             :   StringRef getName() const { return getVariable()->getName(); }
     175           0 :   const MachineInstr *getMInsn() const { return MInsn; }
     176             :   /// Get the FI entries, sorted by fragment offset.
     177             :   ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
     178        2614 :   bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
     179             :   void addMMIEntry(const DbgVariable &V);
     180             : 
     181             :   // Translate tag to proper Dwarf tag.
     182             :   dwarf::Tag getTag() const {
     183             :     // FIXME: Why don't we just infer this tag and store it all along?
     184       77237 :     if (getVariable()->isParameter())
     185             :       return dwarf::DW_TAG_formal_parameter;
     186             : 
     187             :     return dwarf::DW_TAG_variable;
     188             :   }
     189             : 
     190             :   /// Return true if DbgVariable is artificial.
     191       22323 :   bool isArtificial() const {
     192       22323 :     if (getVariable()->isArtificial())
     193             :       return true;
     194       16384 :     if (getType()->isArtificial())
     195           8 :       return true;
     196             :     return false;
     197             :   }
     198             : 
     199       77237 :   bool isObjectPointer() const {
     200       77237 :     if (getVariable()->isObjectPointer())
     201             :       return true;
     202       52074 :     if (getType()->isObjectPointer())
     203           4 :       return true;
     204             :     return false;
     205             :   }
     206             : 
     207             :   bool hasComplexAddress() const {
     208             :     assert(MInsn && "Expected DBG_VALUE, not MMI variable");
     209             :     assert((FrameIndexExprs.empty() ||
     210             :             (FrameIndexExprs.size() == 1 &&
     211             :              FrameIndexExprs[0].Expr->getNumElements())) &&
     212             :            "Invalid Expr for DBG_VALUE");
     213        8249 :     return !FrameIndexExprs.empty();
     214             :   }
     215             : 
     216             :   bool isBlockByrefVariable() const;
     217             :   const DIType *getType() const;
     218             : 
     219             :   static bool classof(const DbgEntity *N) {
     220        8050 :     return N->getDbgEntityID() == DbgVariableKind;
     221             :   }
     222             : 
     223             : private:
     224           0 :   template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
     225           0 :     return Ref.resolve();
     226             :   }
     227             : };
     228             : 
     229             : //===----------------------------------------------------------------------===//
     230             : /// This class is used to track label information.
     231             : ///
     232             : /// Labels are collected from \c DBG_LABEL instructions.
     233             : class DbgLabel : public DbgEntity {
     234             :   const MCSymbol *Sym;                  /// Symbol before DBG_LABEL instruction.
     235             : 
     236             : public:
     237             :   /// We need MCSymbol information to generate DW_AT_low_pc.
     238             :   DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
     239           8 :       : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
     240             : 
     241             :   /// Accessors.
     242             :   /// @{
     243          22 :   const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
     244           0 :   const MCSymbol *getSymbol() const { return Sym; }
     245             : 
     246             :   StringRef getName() const { return getLabel()->getName(); }
     247             :   /// @}
     248             : 
     249             :   /// Translate tag to proper Dwarf tag.
     250           0 :   dwarf::Tag getTag() const {
     251           0 :     return dwarf::DW_TAG_label;
     252             :   }
     253             : 
     254             :   static bool classof(const DbgEntity *N) {
     255       54915 :     return N->getDbgEntityID() == DbgLabelKind;
     256             :   }
     257             : 
     258             : private:
     259             :   template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
     260             :     return Ref.resolve();
     261             :   }
     262             : };
     263             : 
     264             : /// Helper used to pair up a symbol and its DWARF compile unit.
     265             : struct SymbolCU {
     266          10 :   SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
     267             : 
     268             :   const MCSymbol *Sym;
     269             :   DwarfCompileUnit *CU;
     270             : };
     271             : 
     272             : /// The kind of accelerator tables we should emit.
     273             : enum class AccelTableKind {
     274             :   Default, ///< Platform default.
     275             :   None,    ///< None.
     276             :   Apple,   ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
     277             :   Dwarf,   ///< DWARF v5 .debug_names.
     278             : };
     279             : 
     280             : /// Collects and handles dwarf debug information.
     281      134220 : class DwarfDebug : public DebugHandlerBase {
     282             :   /// All DIEValues are allocated through this allocator.
     283             :   BumpPtrAllocator DIEValueAllocator;
     284             : 
     285             :   /// Maps MDNode with its corresponding DwarfCompileUnit.
     286             :   MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
     287             : 
     288             :   /// Maps a CU DIE with its corresponding DwarfCompileUnit.
     289             :   DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
     290             : 
     291             :   /// List of all labels used in aranges generation.
     292             :   std::vector<SymbolCU> ArangeLabels;
     293             : 
     294             :   /// Size of each symbol emitted (for those symbols that have a specific size).
     295             :   DenseMap<const MCSymbol *, uint64_t> SymSize;
     296             : 
     297             :   /// Collection of abstract variables/labels.
     298             :   SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
     299             : 
     300             :   /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
     301             :   /// can refer to them in spite of insertions into this list.
     302             :   DebugLocStream DebugLocs;
     303             : 
     304             :   /// This is a collection of subprogram MDNodes that are processed to
     305             :   /// create DIEs.
     306             :   SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
     307             :             SmallPtrSet<const DISubprogram *, 16>>
     308             :       ProcessedSPNodes;
     309             : 
     310             :   /// If nonnull, stores the current machine function we're processing.
     311             :   const MachineFunction *CurFn = nullptr;
     312             : 
     313             :   /// If nonnull, stores the CU in which the previous subprogram was contained.
     314             :   const DwarfCompileUnit *PrevCU;
     315             : 
     316             :   /// As an optimization, there is no need to emit an entry in the directory
     317             :   /// table for the same directory as DW_AT_comp_dir.
     318             :   StringRef CompilationDir;
     319             : 
     320             :   /// Holder for the file specific debug information.
     321             :   DwarfFile InfoHolder;
     322             : 
     323             :   /// Holders for the various debug information flags that we might need to
     324             :   /// have exposed. See accessor functions below for description.
     325             : 
     326             :   /// Map from MDNodes for user-defined types to their type signatures. Also
     327             :   /// used to keep track of which types we have emitted type units for.
     328             :   DenseMap<const MDNode *, uint64_t> TypeSignatures;
     329             : 
     330             :   SmallVector<
     331             :       std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
     332             :       TypeUnitsUnderConstruction;
     333             : 
     334             :   /// Whether to use the GNU TLS opcode (instead of the standard opcode).
     335             :   bool UseGNUTLSOpcode;
     336             : 
     337             :   /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
     338             :   bool UseDWARF2Bitfields;
     339             : 
     340             :   /// Whether to emit all linkage names, or just abstract subprograms.
     341             :   bool UseAllLinkageNames;
     342             : 
     343             :   /// Use inlined strings.
     344             :   bool UseInlineStrings = false;
     345             : 
     346             :   /// Allow emission of .debug_ranges section.
     347             :   bool UseRangesSection = true;
     348             : 
     349             :   /// True if the sections itself must be used as references and don't create
     350             :   /// temp symbols inside DWARF sections.
     351             :   bool UseSectionsAsReferences = false;
     352             : 
     353             :   ///Allow emission of the .debug_loc section.
     354             :   bool UseLocSection = true;
     355             : 
     356             :   /// Generate DWARF v4 type units.
     357             :   bool GenerateTypeUnits;
     358             : 
     359             :   /// DWARF5 Experimental Options
     360             :   /// @{
     361             :   AccelTableKind TheAccelTableKind;
     362             :   bool HasAppleExtensionAttributes;
     363             :   bool HasSplitDwarf;
     364             : 
     365             :   /// Whether to generate the DWARF v5 string offsets table.
     366             :   /// It consists of a series of contributions, each preceded by a header.
     367             :   /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
     368             :   /// a monolithic sequence of string offsets.
     369             :   bool UseSegmentedStringOffsetsTable;
     370             : 
     371             :   /// Separated Dwarf Variables
     372             :   /// In general these will all be for bits that are left in the
     373             :   /// original object file, rather than things that are meant
     374             :   /// to be in the .dwo sections.
     375             : 
     376             :   /// Holder for the skeleton information.
     377             :   DwarfFile SkeletonHolder;
     378             : 
     379             :   /// Store file names for type units under fission in a line table
     380             :   /// header that will be emitted into debug_line.dwo.
     381             :   // FIXME: replace this with a map from comp_dir to table so that we
     382             :   // can emit multiple tables during LTO each of which uses directory
     383             :   // 0, referencing the comp_dir of all the type units that use it.
     384             :   MCDwarfDwoLineTable SplitTypeUnitFileTable;
     385             :   /// @}
     386             : 
     387             :   /// True iff there are multiple CUs in this module.
     388             :   bool SingleCU;
     389             :   bool IsDarwin;
     390             : 
     391             :   AddressPool AddrPool;
     392             : 
     393             :   /// Accelerator tables.
     394             :   AccelTable<DWARF5AccelTableData> AccelDebugNames;
     395             :   AccelTable<AppleAccelTableOffsetData> AccelNames;
     396             :   AccelTable<AppleAccelTableOffsetData> AccelObjC;
     397             :   AccelTable<AppleAccelTableOffsetData> AccelNamespace;
     398             :   AccelTable<AppleAccelTableTypeData> AccelTypes;
     399             : 
     400             :   // Identify a debugger for "tuning" the debug info.
     401             :   DebuggerKind DebuggerTuning = DebuggerKind::Default;
     402             : 
     403             :   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
     404             : 
     405             :   const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
     406             :     return InfoHolder.getUnits();
     407             :   }
     408             : 
     409             :   using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
     410             : 
     411             :   void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
     412             :                                      const DINode *Node,
     413             :                                      const MDNode *Scope);
     414             :   void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
     415             :                                              const DINode *Node,
     416             :                                              const MDNode *Scope);
     417             : 
     418             :   DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
     419             :                                   LexicalScope &Scope,
     420             :                                   const DINode *Node,
     421             :                                   const DILocation *Location,
     422             :                                   const MCSymbol *Sym = nullptr);
     423             : 
     424             :   /// Construct a DIE for this abstract scope.
     425             :   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
     426             : 
     427             :   /// Construct DIEs for call site entries describing the calls in \p MF.
     428             :   void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
     429             :                                   DIE &ScopeDIE, const MachineFunction &MF);
     430             : 
     431             :   template <typename DataT>
     432             :   void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel,
     433             :                         StringRef Name, const DIE &Die);
     434             : 
     435             :   void finishEntityDefinitions();
     436             : 
     437             :   void finishSubprogramDefinitions();
     438             : 
     439             :   /// Finish off debug information after all functions have been
     440             :   /// processed.
     441             :   void finalizeModuleInfo();
     442             : 
     443             :   /// Emit the debug info section.
     444             :   void emitDebugInfo();
     445             : 
     446             :   /// Emit the abbreviation section.
     447             :   void emitAbbreviations();
     448             : 
     449             :   /// Emit the string offsets table header.
     450             :   void emitStringOffsetsTableHeader();
     451             : 
     452             :   /// Emit a specified accelerator table.
     453             :   template <typename AccelTableT>
     454             :   void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
     455             : 
     456             :   /// Emit DWARF v5 accelerator table.
     457             :   void emitAccelDebugNames();
     458             : 
     459             :   /// Emit visible names into a hashed accelerator table section.
     460             :   void emitAccelNames();
     461             : 
     462             :   /// Emit objective C classes and categories into a hashed
     463             :   /// accelerator table section.
     464             :   void emitAccelObjC();
     465             : 
     466             :   /// Emit namespace dies into a hashed accelerator table.
     467             :   void emitAccelNamespaces();
     468             : 
     469             :   /// Emit type dies into a hashed accelerator table.
     470             :   void emitAccelTypes();
     471             : 
     472             :   /// Emit visible names and types into debug pubnames and pubtypes sections.
     473             :   void emitDebugPubSections();
     474             : 
     475             :   void emitDebugPubSection(bool GnuStyle, StringRef Name,
     476             :                            DwarfCompileUnit *TheU,
     477             :                            const StringMap<const DIE *> &Globals);
     478             : 
     479             :   /// Emit null-terminated strings into a debug str section.
     480             :   void emitDebugStr();
     481             : 
     482             :   /// Emit variable locations into a debug loc section.
     483             :   void emitDebugLoc();
     484             : 
     485             :   /// Emit variable locations into a debug loc dwo section.
     486             :   void emitDebugLocDWO();
     487             : 
     488             :   /// Emit address ranges into a debug aranges section.
     489             :   void emitDebugARanges();
     490             : 
     491             :   /// Emit address ranges into a debug ranges section.
     492             :   void emitDebugRanges();
     493             : 
     494             :   /// Emit range lists into a DWARF v5 debug rnglists section.
     495             :   void emitDebugRnglists();
     496             : 
     497             :   /// Emit macros into a debug macinfo section.
     498             :   void emitDebugMacinfo();
     499             :   void emitMacro(DIMacro &M);
     500             :   void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
     501             :   void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
     502             : 
     503             :   /// DWARF 5 Experimental Split Dwarf Emitters
     504             : 
     505             :   /// Initialize common features of skeleton units.
     506             :   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
     507             :                         std::unique_ptr<DwarfCompileUnit> NewU);
     508             : 
     509             :   /// Construct the split debug info compile unit for the debug info section.
     510             :   /// In DWARF v5, the skeleton unit DIE may have the following attributes:
     511             :   /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,
     512             :   /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.
     513             :   /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name
     514             :   /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of
     515             :   /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.
     516             :   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
     517             : 
     518             :   /// Emit the debug info dwo section.
     519             :   void emitDebugInfoDWO();
     520             : 
     521             :   /// Emit the debug abbrev dwo section.
     522             :   void emitDebugAbbrevDWO();
     523             : 
     524             :   /// Emit the debug line dwo section.
     525             :   void emitDebugLineDWO();
     526             : 
     527             :   /// Emit the dwo stringoffsets table header.
     528             :   void emitStringOffsetsTableHeaderDWO();
     529             : 
     530             :   /// Emit the debug str dwo section.
     531             :   void emitDebugStrDWO();
     532             : 
     533             :   /// Emit DWO addresses.
     534             :   void emitDebugAddr();
     535             : 
     536             :   /// Flags to let the linker know we have emitted new style pubnames. Only
     537             :   /// emit it here if we don't have a skeleton CU for split dwarf.
     538             :   void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
     539             : 
     540             :   /// Create new DwarfCompileUnit for the given metadata node with tag
     541             :   /// DW_TAG_compile_unit.
     542             :   DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
     543             : 
     544             :   /// Construct imported_module or imported_declaration DIE.
     545             :   void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
     546             :                                         const DIImportedEntity *N);
     547             : 
     548             :   /// Register a source line with debug info. Returns the unique
     549             :   /// label that was emitted and which provides correspondence to the
     550             :   /// source line list.
     551             :   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
     552             :                         unsigned Flags);
     553             : 
     554             :   /// Populate LexicalScope entries with variables' info.
     555             :   void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
     556             :                          DenseSet<InlinedEntity> &ProcessedVars);
     557             : 
     558             :   /// Build the location list for all DBG_VALUEs in the
     559             :   /// function that describe the same variable.
     560             :   void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     561             :                          const DbgValueHistoryMap::InstrRanges &Ranges);
     562             : 
     563             :   /// Collect variable information from the side table maintained by MF.
     564             :   void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
     565             :                                       DenseSet<InlinedEntity> &P);
     566             : 
     567             :   /// Emit the reference to the section.
     568             :   void emitSectionReference(const DwarfCompileUnit &CU);
     569             : 
     570             : protected:
     571             :   /// Gather pre-function debug information.
     572             :   void beginFunctionImpl(const MachineFunction *MF) override;
     573             : 
     574             :   /// Gather and emit post-function debug information.
     575             :   void endFunctionImpl(const MachineFunction *MF) override;
     576             : 
     577             :   void skippedNonDebugFunction() override;
     578             : 
     579             : public:
     580             :   //===--------------------------------------------------------------------===//
     581             :   // Main entry points.
     582             :   //
     583             :   DwarfDebug(AsmPrinter *A, Module *M);
     584             : 
     585             :   ~DwarfDebug() override;
     586             : 
     587             :   /// Emit all Dwarf sections that should come prior to the
     588             :   /// content.
     589             :   void beginModule();
     590             : 
     591             :   /// Emit all Dwarf sections that should come after the content.
     592             :   void endModule() override;
     593             : 
     594             :   /// Process beginning of an instruction.
     595             :   void beginInstruction(const MachineInstr *MI) override;
     596             : 
     597             :   /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
     598             :   static uint64_t makeTypeSignature(StringRef Identifier);
     599             : 
     600             :   /// Add a DIE to the set of types that we're going to pull into
     601             :   /// type units.
     602             :   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
     603             :                             DIE &Die, const DICompositeType *CTy);
     604             : 
     605             :   /// Add a label so that arange data can be generated for it.
     606       90572 :   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
     607             : 
     608             :   /// For symbols that have a size designated (e.g. common symbols),
     609             :   /// this tracks that size.
     610      273420 :   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
     611      273420 :     SymSize[Sym] = Size;
     612      273420 :   }
     613             : 
     614             :   /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
     615             :   /// If not, we still might emit certain cases.
     616           0 :   bool useAllLinkageNames() const { return UseAllLinkageNames; }
     617             : 
     618             :   /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
     619             :   /// standard DW_OP_form_tls_address opcode
     620           0 :   bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
     621             : 
     622             :   /// Returns whether to use the DWARF2 format for bitfields instyead of the
     623             :   /// DWARF4 format.
     624           0 :   bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
     625             : 
     626             :   /// Returns whether to use inline strings.
     627           0 :   bool useInlineStrings() const { return UseInlineStrings; }
     628             : 
     629             :   /// Returns whether ranges section should be emitted.
     630           0 :   bool useRangesSection() const { return UseRangesSection; }
     631             : 
     632             :   /// Returns whether to use sections as labels rather than temp symbols.
     633           0 :   bool useSectionsAsReferences() const {
     634           0 :     return UseSectionsAsReferences;
     635             :   }
     636             : 
     637             :   /// Returns whether .debug_loc section should be emitted.
     638           0 :   bool useLocSection() const { return UseLocSection; }
     639             : 
     640             :   /// Returns whether to generate DWARF v4 type units.
     641           0 :   bool generateTypeUnits() const { return GenerateTypeUnits; }
     642             : 
     643             :   // Experimental DWARF5 features.
     644             : 
     645             :   /// Returns what kind (if any) of accelerator tables to emit.
     646           0 :   AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
     647             : 
     648           0 :   bool useAppleExtensionAttributes() const {
     649           0 :     return HasAppleExtensionAttributes;
     650             :   }
     651             : 
     652             :   /// Returns whether or not to change the current debug info for the
     653             :   /// split dwarf proposal support.
     654           0 :   bool useSplitDwarf() const { return HasSplitDwarf; }
     655             : 
     656             :   /// Returns whether to generate a string offsets table with (possibly shared)
     657             :   /// contributions from each CU and type unit. This implies the use of
     658             :   /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
     659             :   /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
     660             :   /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
     661             :   /// monolithic string offsets table.
     662           0 :   bool useSegmentedStringOffsetsTable() const {
     663           0 :     return UseSegmentedStringOffsetsTable;
     664             :   }
     665             : 
     666             :   bool shareAcrossDWOCUs() const;
     667             : 
     668             :   /// Returns the Dwarf Version.
     669             :   uint16_t getDwarfVersion() const;
     670             : 
     671             :   /// Returns the previous CU that was being updated
     672           0 :   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
     673        9433 :   void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
     674             : 
     675             :   /// Returns the entries for the .debug_loc section.
     676             :   const DebugLocStream &getDebugLocs() const { return DebugLocs; }
     677             : 
     678             :   /// Emit an entry for the debug loc section. This can be used to
     679             :   /// handle an entry that's going to be emitted into the debug loc section.
     680             :   void emitDebugLocEntry(ByteStreamer &Streamer,
     681             :                          const DebugLocStream::Entry &Entry);
     682             : 
     683             :   /// Emit the location for a debug loc entry, including the size header.
     684             :   void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
     685             : 
     686             :   /// Find the MDNode for the given reference.
     687           0 :   template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
     688           0 :     return Ref.resolve();
     689             :   }
     690             : 
     691             :   void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
     692             :                           DIE &Die);
     693             : 
     694          91 :   AddressPool &getAddressPool() { return AddrPool; }
     695             : 
     696             :   void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die);
     697             : 
     698             :   void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die);
     699             : 
     700             :   void addAccelNamespace(const DICompileUnit &CU, StringRef Name,
     701             :                          const DIE &Die);
     702             : 
     703             :   void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die,
     704             :                     char Flags);
     705             : 
     706           0 :   const MachineFunction *getCurrentFunction() const { return CurFn; }
     707             : 
     708             :   /// A helper function to check whether the DIE for a given Scope is
     709             :   /// going to be null.
     710             :   bool isLexicalScopeDIENull(LexicalScope *Scope);
     711             : 
     712             :   /// Find the matching DwarfCompileUnit for the given CU DIE.
     713        2858 :   DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
     714             :   const DwarfCompileUnit *lookupCU(const DIE *Die) const {
     715             :     return CUDieMap.lookup(Die);
     716             :   }
     717             : 
     718             :   /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
     719             :   ///
     720             :   /// Returns whether we are "tuning" for a given debugger.
     721             :   /// @{
     722           0 :   bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
     723       26981 :   bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
     724           0 :   bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
     725             :   /// @}
     726             : };
     727             : 
     728             : } // end namespace llvm
     729             : 
     730             : #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H

Generated by: LCOV version 1.13