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