Refactor jit debugger interface and its ELF creation.
Make it possible to store more then one method per entry,
and ref-count the number of live methods per entry.
Test: m test-art-host-gtest
Change-Id: I45d69185e85e47fbee88a8d1f549ede9875a3c0a
diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc
index bb2a214..df5bb37 100644
--- a/compiler/debug/elf_debug_writer.cc
+++ b/compiler/debug/elf_debug_writer.cc
@@ -137,10 +137,17 @@
InstructionSet isa,
const InstructionSetFeatures* features,
bool mini_debug_info,
- const MethodDebugInfo& mi) {
- CHECK_EQ(mi.is_code_address_text_relative, false);
+ ArrayRef<const MethodDebugInfo> method_infos) {
+ CHECK_GT(method_infos.size(), 0u);
+ uint64_t min_address = std::numeric_limits<uint64_t>::max();
+ uint64_t max_address = 0;
+ for (const MethodDebugInfo& mi : method_infos) {
+ CHECK_EQ(mi.is_code_address_text_relative, false);
+ min_address = std::min(min_address, mi.code_address);
+ max_address = std::max(max_address, mi.code_address + mi.code_size);
+ }
DebugInfo debug_info{};
- debug_info.compiled_methods = ArrayRef<const debug::MethodDebugInfo>(&mi, 1);
+ debug_info.compiled_methods = method_infos;
std::vector<uint8_t> buffer;
buffer.reserve(KB);
linker::VectorOutputStream out("Debug ELF file", &buffer);
@@ -151,14 +158,14 @@
if (mini_debug_info) {
std::vector<uint8_t> mdi = MakeMiniDebugInfo(isa,
features,
- mi.code_address,
- mi.code_size,
+ min_address,
+ max_address - min_address,
/* dex_section_address */ 0,
/* dex_section_size */ 0,
debug_info);
builder->WriteSection(".gnu_debugdata", &mdi);
} else {
- builder->GetText()->AllocateVirtualMemory(mi.code_address, mi.code_size);
+ builder->GetText()->AllocateVirtualMemory(min_address, max_address - min_address);
WriteDebugInfo(builder.get(),
debug_info,
dwarf::DW_DEBUG_FRAME_FORMAT,
@@ -173,11 +180,11 @@
InstructionSet isa,
const InstructionSetFeatures* features,
bool mini_debug_info,
- const MethodDebugInfo& method_info) {
+ ArrayRef<const MethodDebugInfo> method_infos) {
if (Is64BitInstructionSet(isa)) {
- return MakeElfFileForJITInternal<ElfTypes64>(isa, features, mini_debug_info, method_info);
+ return MakeElfFileForJITInternal<ElfTypes64>(isa, features, mini_debug_info, method_infos);
} else {
- return MakeElfFileForJITInternal<ElfTypes32>(isa, features, mini_debug_info, method_info);
+ return MakeElfFileForJITInternal<ElfTypes32>(isa, features, mini_debug_info, method_infos);
}
}
diff --git a/compiler/debug/elf_debug_writer.h b/compiler/debug/elf_debug_writer.h
index 8ad0c42..e442e00 100644
--- a/compiler/debug/elf_debug_writer.h
+++ b/compiler/debug/elf_debug_writer.h
@@ -54,7 +54,7 @@
InstructionSet isa,
const InstructionSetFeatures* features,
bool mini_debug_info,
- const MethodDebugInfo& method_info);
+ ArrayRef<const MethodDebugInfo> method_infos);
std::vector<uint8_t> WriteDebugElfFileForClasses(
InstructionSet isa,
diff --git a/compiler/debug/elf_symtab_writer.h b/compiler/debug/elf_symtab_writer.h
index a853714..9c9e8b3 100644
--- a/compiler/debug/elf_symtab_writer.h
+++ b/compiler/debug/elf_symtab_writer.h
@@ -72,8 +72,8 @@
continue; // Add symbol only for the first instance.
}
size_t name_offset;
- if (!info.trampoline_name.empty()) {
- name_offset = strtab->Write(info.trampoline_name);
+ if (!info.custom_name.empty()) {
+ name_offset = strtab->Write(info.custom_name);
} else {
DCHECK(info.dex_file != nullptr);
std::string name = info.dex_file->PrettyMethod(info.dex_method_index, !mini_debug_info);
diff --git a/compiler/debug/method_debug_info.h b/compiler/debug/method_debug_info.h
index 43c8de2..d0b03ec 100644
--- a/compiler/debug/method_debug_info.h
+++ b/compiler/debug/method_debug_info.h
@@ -27,7 +27,7 @@
namespace debug {
struct MethodDebugInfo {
- std::string trampoline_name;
+ std::string custom_name;
const DexFile* dex_file; // Native methods (trampolines) do not reference dex file.
size_t class_def_index;
uint32_t dex_method_index;