Debugger: Add dedicated functions for global {un}init.
[haiku.git] / src / apps / debugger / dwarf / BaseUnit.h
blob0f8e77be4f1a400e0d93847f1dc95047a312e9d1
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
10 #include <String.h>
12 #include <Array.h>
14 #include "Types.h"
17 class AbbreviationTable;
18 class DebugInfoEntry;
19 class SourceLanguageInfo;
22 enum dwarf_unit_kind {
23 dwarf_unit_kind_compilation = 0,
24 dwarf_unit_kind_type
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();
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; }
48 bool ContainsAbsoluteOffset(off_t offset) const;
50 uint8 AddressSize() const { return fAddressSize; }
51 bool IsDwarf64() const { return fIsDwarf64; }
53 AbbreviationTable* GetAbbreviationTable() const
54 { return fAbbreviationTable; }
55 void SetAbbreviationTable(
56 AbbreviationTable* abbreviationTable);
58 const SourceLanguageInfo* SourceLanguage() const
59 { return fSourceLanguage; }
60 void SetSourceLanguage(
61 const SourceLanguageInfo* language);
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;
70 virtual dwarf_unit_kind Kind() const = 0;
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;
86 #endif // BASE_UNIT_H