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
),
32 for (int32 i
= 0; i
< fEntries
.Count(); i
++)
38 BaseUnit::SetAbbreviationTable(AbbreviationTable
* abbreviationTable
)
40 fAbbreviationTable
= abbreviationTable
;
45 BaseUnit::AddDebugInfoEntry(DebugInfoEntry
* entry
, off_t offset
)
47 if (!fEntries
.Add(entry
))
49 if (!fEntryOffsets
.Add(offset
)) {
50 fEntries
.Remove(fEntries
.Count() - 1);
59 BaseUnit::ContainsAbsoluteOffset(off_t offset
) const
61 return fHeaderOffset
<= offset
&& fHeaderOffset
+ fTotalSize
> offset
;
66 BaseUnit::SetSourceLanguage(const SourceLanguageInfo
* language
)
68 fSourceLanguage
= language
;
73 BaseUnit::CountEntries() const
75 return fEntries
.Count();
80 BaseUnit::GetEntryAt(int index
, DebugInfoEntry
*& entry
,
83 entry
= fEntries
[index
];
84 offset
= fEntryOffsets
[index
];
89 BaseUnit::EntryForOffset(off_t offset
) const
91 if (fEntries
.IsEmpty())
96 int upper
= fEntries
.Count() - 1;
97 while (lower
< upper
) {
98 int mid
= (lower
+ upper
+ 1) / 2;
99 if (fEntryOffsets
[mid
] > offset
)
105 return fEntryOffsets
[lower
] == offset
? fEntries
[lower
] : NULL
;