Moving source map to Function.

This commit is contained in:
Ben Vanik
2015-08-01 14:07:13 -07:00
parent 5aa50b3c18
commit b0425f7ee2
13 changed files with 121 additions and 114 deletions

View File

@@ -23,6 +23,39 @@ Function::Function(FunctionInfo* symbol_info)
Function::~Function() = default;
const SourceMapEntry* Function::LookupSourceOffset(uint32_t offset) const {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t i = 0; i < source_map_.size(); ++i) {
const auto& entry = source_map_[i];
if (entry.source_offset == offset) {
return &entry;
}
}
return nullptr;
}
const SourceMapEntry* Function::LookupHIROffset(uint32_t offset) const {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t i = 0; i < source_map_.size(); ++i) {
const auto& entry = source_map_[i];
if (entry.hir_offset >= offset) {
return &entry;
}
}
return nullptr;
}
const SourceMapEntry* Function::LookupCodeOffset(uint32_t offset) const {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (int64_t i = source_map_.size() - 1; i >= 0; --i) {
const auto& entry = source_map_[i];
if (entry.code_offset <= offset) {
return &entry;
}
}
return source_map_.empty() ? nullptr : &source_map_[0];
}
bool Function::AddBreakpoint(Breakpoint* breakpoint) {
std::lock_guard<xe::mutex> guard(lock_);
bool found = false;