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 "DWARFAbbreviationDeclaration.h" 14 #include <list> 15 #include <map> 16 #include <vector> 17 18 namespace llvm { 19 20 typedef std::vector<DWARFAbbreviationDeclaration> 21 DWARFAbbreviationDeclarationColl; 22 typedef DWARFAbbreviationDeclarationColl::iterator 23 DWARFAbbreviationDeclarationCollIter; 24 typedef DWARFAbbreviationDeclarationColl::const_iterator 25 DWARFAbbreviationDeclarationCollConstIter; 26 27 class DWARFAbbreviationDeclarationSet { 28 uint64_t Offset; 29 uint32_t IdxOffset; 30 std::vector<DWARFAbbreviationDeclaration> Decls; 31 public: DWARFAbbreviationDeclarationSet()32 DWARFAbbreviationDeclarationSet() 33 : Offset(0), IdxOffset(0) {} 34 DWARFAbbreviationDeclarationSet(uint64_t offset,uint32_t idxOffset)35 DWARFAbbreviationDeclarationSet(uint64_t offset, uint32_t idxOffset) 36 : Offset(offset), IdxOffset(idxOffset) {} 37 clear()38 void clear() { 39 IdxOffset = 0; 40 Decls.clear(); 41 } getOffset()42 uint64_t getOffset() const { return Offset; } 43 void dump(raw_ostream &OS) const; 44 bool extract(DataExtractor data, uint32_t* offset_ptr); 45 46 const DWARFAbbreviationDeclaration * 47 getAbbreviationDeclaration(uint32_t abbrCode) const; 48 }; 49 50 class DWARFDebugAbbrev { 51 public: 52 typedef std::map<uint64_t, DWARFAbbreviationDeclarationSet> 53 DWARFAbbreviationDeclarationCollMap; 54 typedef DWARFAbbreviationDeclarationCollMap::iterator 55 DWARFAbbreviationDeclarationCollMapIter; 56 typedef DWARFAbbreviationDeclarationCollMap::const_iterator 57 DWARFAbbreviationDeclarationCollMapConstIter; 58 59 private: 60 DWARFAbbreviationDeclarationCollMap AbbrevCollMap; 61 mutable DWARFAbbreviationDeclarationCollMapConstIter PrevAbbrOffsetPos; 62 63 public: 64 DWARFDebugAbbrev(); 65 const DWARFAbbreviationDeclarationSet * 66 getAbbreviationDeclarationSet(uint64_t cu_abbr_offset) const; 67 void dump(raw_ostream &OS) const; 68 void parse(DataExtractor data); 69 }; 70 71 } 72 73 #endif 74