1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2013, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef BASE_UNIT_H 7 #define BASE_UNIT_H 8 9 10 #include <String.h> 11 12 #include <Array.h> 13 14 #include "Types.h" 15 16 17 class AbbreviationTable; 18 class DebugInfoEntry; 19 struct SourceLanguageInfo; 20 21 22 enum dwarf_unit_kind { 23 dwarf_unit_kind_compilation = 0, 24 dwarf_unit_kind_type 25 }; 26 27 28 class BaseUnit { 29 public: 30 BaseUnit(off_t headerOffset, 31 off_t contentOffset, 32 off_t totalSize, 33 off_t abbreviationOffset, 34 uint8 addressSize, bool isDwarf64); 35 virtual ~BaseUnit(); 36 37 off_t HeaderOffset() const { return fHeaderOffset; } 38 off_t ContentOffset() const { return fContentOffset; } 39 off_t RelativeContentOffset() const 40 { return fContentOffset - fHeaderOffset; } 41 off_t TotalSize() const { return fTotalSize; } 42 off_t ContentSize() const 43 { return fTotalSize 44 - RelativeContentOffset(); } 45 off_t AbbreviationOffset() const 46 { return fAbbreviationOffset; } 47 48 bool ContainsAbsoluteOffset(off_t offset) const; 49 50 uint8 AddressSize() const { return fAddressSize; } 51 bool IsDwarf64() const { return fIsDwarf64; } 52 53 AbbreviationTable* GetAbbreviationTable() const 54 { return fAbbreviationTable; } 55 void SetAbbreviationTable( 56 AbbreviationTable* abbreviationTable); 57 58 const SourceLanguageInfo* SourceLanguage() const 59 { return fSourceLanguage; } 60 void SetSourceLanguage( 61 const SourceLanguageInfo* language); 62 63 status_t AddDebugInfoEntry(DebugInfoEntry* entry, 64 off_t offset); 65 int CountEntries() const; 66 void GetEntryAt(int index, DebugInfoEntry*& entry, 67 off_t& offset) const; 68 DebugInfoEntry* EntryForOffset(off_t offset) const; 69 70 virtual dwarf_unit_kind Kind() const = 0; 71 72 private: 73 off_t fHeaderOffset; 74 off_t fContentOffset; 75 off_t fTotalSize; 76 off_t fAbbreviationOffset; 77 AbbreviationTable* fAbbreviationTable; 78 const SourceLanguageInfo* fSourceLanguage; 79 Array<DebugInfoEntry*> fEntries; 80 Array<off_t> fEntryOffsets; 81 uint8 fAddressSize; 82 bool fIsDwarf64; 83 }; 84 85 86 #endif // BASE_UNIT_H 87