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

@@ -18,59 +18,15 @@ DebugInfo::DebugInfo()
: source_disasm_(nullptr),
raw_hir_disasm_(nullptr),
hir_disasm_(nullptr),
machine_code_disasm_(nullptr),
source_map_count_(0),
source_map_entries_(nullptr) {}
machine_code_disasm_(nullptr) {}
DebugInfo::~DebugInfo() {
free(source_map_entries_);
free(source_disasm_);
free(raw_hir_disasm_);
free(hir_disasm_);
free(machine_code_disasm_);
}
void DebugInfo::InitializeSourceMap(size_t source_map_count,
SourceMapEntry* source_map) {
source_map_count_ = source_map_count;
source_map_entries_ = source_map;
// TODO(benvanik): ensure sorted in some way? MC offset?
}
SourceMapEntry* DebugInfo::LookupSourceOffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t n = 0; n < source_map_count_; n++) {
auto entry = &source_map_entries_[n];
if (entry->source_offset == offset) {
return entry;
}
}
return nullptr;
}
SourceMapEntry* DebugInfo::LookupHIROffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t n = 0; n < source_map_count_; n++) {
auto entry = &source_map_entries_[n];
if (entry->hir_offset >= offset) {
return entry;
}
}
return nullptr;
}
SourceMapEntry* DebugInfo::LookupCodeOffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (int64_t n = source_map_count_ - 1; n >= 0; n--) {
auto entry = &source_map_entries_[n];
if (entry->code_offset <= offset) {
return entry;
}
}
return source_map_count_ ? &source_map_entries_[0] : nullptr;
}
void DebugInfo::Dump() {
if (source_disasm_) {
printf("PPC:\n%s\n", source_disasm_);