diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/debug/elf_debug_info_writer.h | 14 | ||||
| -rw-r--r-- | compiler/debug/elf_debug_line_writer.h | 14 | ||||
| -rw-r--r-- | compiler/optimizing/instruction_builder.cc | 17 |
3 files changed, 16 insertions, 29 deletions
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h index bda7108c74..233f61cec3 100644 --- a/compiler/debug/elf_debug_info_writer.h +++ b/compiler/debug/elf_debug_info_writer.h @@ -49,18 +49,12 @@ static void LocalInfoCallback(void* ctx, const DexFile::LocalInfo& entry) { static std::vector<const char*> GetParamNames(const MethodDebugInfo* mi) { std::vector<const char*> names; + DCHECK(mi->dex_file != nullptr); CodeItemDebugInfoAccessor accessor(*mi->dex_file, mi->code_item, mi->dex_method_index); if (accessor.HasCodeItem()) { - DCHECK(mi->dex_file != nullptr); - const uint8_t* stream = mi->dex_file->GetDebugInfoStream(accessor.DebugInfoOffset()); - if (stream != nullptr) { - DecodeUnsignedLeb128(&stream); // line. - uint32_t parameters_size = DecodeUnsignedLeb128(&stream); - for (uint32_t i = 0; i < parameters_size; ++i) { - uint32_t id = DecodeUnsignedLeb128P1(&stream); - names.push_back(mi->dex_file->StringDataByIdx(dex::StringIndex(id))); - } - } + accessor.VisitParameterNames([&](const dex::StringIndex& id) { + names.push_back(mi->dex_file->StringDataByIdx(id)); + }); } return names; } diff --git a/compiler/debug/elf_debug_line_writer.h b/compiler/debug/elf_debug_line_writer.h index 3d78943cd0..0a13a92d07 100644 --- a/compiler/debug/elf_debug_line_writer.h +++ b/compiler/debug/elf_debug_line_writer.h @@ -34,11 +34,6 @@ namespace debug { typedef std::vector<DexFile::PositionInfo> PositionInfos; -static bool PositionInfoCallback(void* ctx, const DexFile::PositionInfo& entry) { - static_cast<PositionInfos*>(ctx)->push_back(entry); - return false; -} - template<typename ElfTypes> class ElfDebugLineWriter { using Elf_Addr = typename ElfTypes::Addr; @@ -154,11 +149,14 @@ class ElfDebugLineWriter { Elf_Addr method_address = base_address + mi->code_address; PositionInfos dex2line_map; - DCHECK(mi->dex_file != nullptr); const DexFile* dex = mi->dex_file; + DCHECK(dex != nullptr); CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index); - const uint32_t debug_info_offset = accessor.DebugInfoOffset(); - if (!dex->DecodeDebugPositionInfo(debug_info_offset, PositionInfoCallback, &dex2line_map)) { + if (!accessor.DecodeDebugPositionInfo( + [&](const DexFile::PositionInfo& entry) { + dex2line_map.push_back(entry); + return false; + })) { continue; } diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index e555d0d890..034761db57 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -466,22 +466,17 @@ void HInstructionBuilder::BuildIntrinsic(ArtMethod* method) { } ArenaBitVector* HInstructionBuilder::FindNativeDebugInfoLocations() { - // The callback gets called when the line number changes. - // In other words, it marks the start of new java statement. - struct Callback { - static bool Position(void* ctx, const DexFile::PositionInfo& entry) { - static_cast<ArenaBitVector*>(ctx)->SetBit(entry.address_); - return false; - } - }; ArenaBitVector* locations = ArenaBitVector::Create(local_allocator_, code_item_accessor_.InsnsSizeInCodeUnits(), /* expandable */ false, kArenaAllocGraphBuilder); locations->ClearAllBits(); - dex_file_->DecodeDebugPositionInfo(code_item_accessor_.DebugInfoOffset(), - Callback::Position, - locations); + // The visitor gets called when the line number changes. + // In other words, it marks the start of new java statement. + code_item_accessor_.DecodeDebugPositionInfo([&](const DexFile::PositionInfo& entry) { + locations->SetBit(entry.address_); + return false; + }); // Instruction-specific tweaks. for (const DexInstructionPcPair& inst : code_item_accessor_) { switch (inst->Opcode()) { |