Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:41

0001 //===- DWARFDebugAbbrev.h ---------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H
0011 
0012 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
0013 #include "llvm/Support/DataExtractor.h"
0014 #include <cstdint>
0015 #include <map>
0016 #include <vector>
0017 
0018 namespace llvm {
0019 
0020 class raw_ostream;
0021 
0022 class DWARFAbbreviationDeclarationSet {
0023   uint64_t Offset;
0024   /// Code of the first abbreviation, if all abbreviations in the set have
0025   /// consecutive codes. UINT32_MAX otherwise.
0026   uint32_t FirstAbbrCode;
0027   std::vector<DWARFAbbreviationDeclaration> Decls;
0028 
0029   using const_iterator =
0030       std::vector<DWARFAbbreviationDeclaration>::const_iterator;
0031 
0032 public:
0033   DWARFAbbreviationDeclarationSet();
0034 
0035   uint64_t getOffset() const { return Offset; }
0036   void dump(raw_ostream &OS) const;
0037   Error extract(DataExtractor Data, uint64_t *OffsetPtr);
0038 
0039   const DWARFAbbreviationDeclaration *
0040   getAbbreviationDeclaration(uint32_t AbbrCode) const;
0041 
0042   const_iterator begin() const {
0043     return Decls.begin();
0044   }
0045 
0046   const_iterator end() const {
0047     return Decls.end();
0048   }
0049 
0050   std::string getCodeRange() const;
0051 
0052   uint32_t getFirstAbbrCode() const { return FirstAbbrCode; }
0053 
0054 private:
0055   void clear();
0056 };
0057 
0058 class DWARFDebugAbbrev {
0059   using DWARFAbbreviationDeclarationSetMap =
0060       std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
0061 
0062   mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
0063   mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
0064   mutable std::optional<DataExtractor> Data;
0065 
0066 public:
0067   DWARFDebugAbbrev(DataExtractor Data);
0068 
0069   Expected<const DWARFAbbreviationDeclarationSet *>
0070   getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const;
0071 
0072   void dump(raw_ostream &OS) const;
0073   Error parse() const;
0074 
0075   DWARFAbbreviationDeclarationSetMap::const_iterator begin() const {
0076     assert(!Data && "Must call parse before iterating over DWARFDebugAbbrev");
0077     return AbbrDeclSets.begin();
0078   }
0079 
0080   DWARFAbbreviationDeclarationSetMap::const_iterator end() const {
0081     return AbbrDeclSets.end();
0082   }
0083 };
0084 
0085 } // end namespace llvm
0086 
0087 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGABBREV_H