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.
12 #include "DebugInfoEntries.h"
15 BaseUnit::BaseUnit(off_t headerOffset
, off_t contentOffset
,
16 off_t totalSize
, off_t abbreviationOffset
, uint8 addressSize
,
19 fHeaderOffset(headerOffset
),
20 fContentOffset(contentOffset
),
21 fTotalSize(totalSize
),
22 fAbbreviationOffset(abbreviationOffset
),
23 fAbbreviationTable(NULL
),
24 fAddressSize(addressSize
),
36 BaseUnit::SetAbbreviationTable(AbbreviationTable
* abbreviationTable
)
38 fAbbreviationTable
= abbreviationTable
;
43 BaseUnit::AddDebugInfoEntry(DebugInfoEntry
* entry
, off_t offset
)
45 if (!fEntries
.Add(entry
))
47 if (!fEntryOffsets
.Add(offset
)) {
48 fEntries
.Remove(fEntries
.Count() - 1);
57 BaseUnit::ContainsAbsoluteOffset(off_t offset
) const
59 return fHeaderOffset
<= offset
&& fHeaderOffset
+ fTotalSize
> offset
;
64 BaseUnit::SetSourceLanguage(const SourceLanguageInfo
* language
)
66 fSourceLanguage
= language
;
71 BaseUnit::CountEntries() const
73 return fEntries
.Count();
78 BaseUnit::GetEntryAt(int index
, DebugInfoEntry
*& entry
,
81 entry
= fEntries
[index
];
82 offset
= fEntryOffsets
[index
];
87 BaseUnit::EntryForOffset(off_t offset
) const
89 if (fEntries
.IsEmpty())
94 int upper
= fEntries
.Count() - 1;
95 while (lower
< upper
) {
96 int mid
= (lower
+ upper
+ 1) / 2;
97 if (fEntryOffsets
[mid
] > offset
)
103 return fEntryOffsets
[lower
] == offset
? fEntries
[lower
] : NULL
;