1 //===- DWARFDebugAbbrev.h ---------------------------------------*- 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 LLVM_DEBUGINFO_DWARFDEBUGABBREV_H 11 #define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H 12 13 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" 14 #include "llvm/Support/DataExtractor.h" 15 #include <cstdint> 16 #include <map> 17 #include <vector> 18 19 namespace llvm { 20 21 class raw_ostream; 22 23 class DWARFAbbreviationDeclarationSet { 24 uint32_t Offset; 25 /// Code of the first abbreviation, if all abbreviations in the set have 26 /// consecutive codes. UINT32_MAX otherwise. 27 uint32_t FirstAbbrCode; 28 std::vector<DWARFAbbreviationDeclaration> Decls; 29 30 using const_iterator = 31 std::vector<DWARFAbbreviationDeclaration>::const_iterator; 32 33 public: 34 DWARFAbbreviationDeclarationSet(); 35 36 uint32_t getOffset() const { return Offset; } 37 void dump(raw_ostream &OS) const; 38 bool extract(DataExtractor Data, uint32_t *OffsetPtr); 39 40 const DWARFAbbreviationDeclaration * 41 getAbbreviationDeclaration(uint32_t AbbrCode) const; 42 43 const_iterator begin() const { 44 return Decls.begin(); 45 } 46 47 const_iterator end() const { 48 return Decls.end(); 49 } 50 51 private: 52 void clear(); 53 }; 54 55 class DWARFDebugAbbrev { 56 using DWARFAbbreviationDeclarationSetMap = 57 std::map<uint64_t, DWARFAbbreviationDeclarationSet>; 58 59 mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets; 60 mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; 61 mutable Optional<DataExtractor> Data; 62 63 public: 64 DWARFDebugAbbrev(); 65 66 const DWARFAbbreviationDeclarationSet * 67 getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const; 68 69 void dump(raw_ostream &OS) const; 70 void parse() const; 71 void extract(DataExtractor Data); 72 73 DWARFAbbreviationDeclarationSetMap::const_iterator begin() const { 74 parse(); 75 return AbbrDeclSets.begin(); 76 } 77 78 DWARFAbbreviationDeclarationSetMap::const_iterator end() const { 79 return AbbrDeclSets.end(); 80 } 81 82 private: 83 void clear(); 84 }; 85 86 } // end namespace llvm 87 88 #endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H 89