diff options
author | 2019-04-26 12:46:08 +0100 | |
---|---|---|
committer | 2019-04-29 16:33:51 +0000 | |
commit | 36ec6c7314b824f03f955a5c0c2cbce56ef63412 (patch) | |
tree | cb3b72b2eefc25dd6ce59219d4d685145566d48e | |
parent | c36a8ccf44454f1a4b8b57420205faf11dec7046 (diff) |
Fix DWARF line-number generation for JITed methods.
Don't strip, repack or compress debug-info if explicitly
requested by the developer (using the -g compiler flag).
If enabled, the DWARF debug info has about 1:1 size
overhead relative to JIT code + data.
Bug: 131422204
Test: Check that gdb shows line numbers for JITed method.
Test: Hard-code always-enable generation and run maps.
Change-Id: If06de8ae2317af4d57d84e8a8bfae86a597dd4e4
-rw-r--r-- | compiler/jit/jit_compiler.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 2 | ||||
-rw-r--r-- | runtime/jit/debugger_interface.cc | 19 | ||||
-rw-r--r-- | runtime/jit/debugger_interface.h | 2 |
4 files changed, 21 insertions, 4 deletions
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index 1957c82ef5..b42e9f2592 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -150,7 +150,7 @@ extern "C" void jit_types_loaded(void* handle, mirror::Class** types, size_t cou AddNativeDebugInfoForJit(Thread::Current(), /*code_ptr=*/ nullptr, elf_file, - debug::PackElfFileForJIT, + /*pack*/ nullptr, compiler_options.GetInstructionSet(), compiler_options.GetInstructionSetFeatures()); } diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index f4bf11d3d3..c799b12a4b 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -1482,7 +1482,7 @@ void OptimizingCompiler::GenerateJitDebugInfo(ArtMethod* method ATTRIBUTE_UNUSED AddNativeDebugInfoForJit(Thread::Current(), reinterpret_cast<const void*>(info.code_address), elf_file, - debug::PackElfFileForJIT, + mini_debug_info ? debug::PackElfFileForJIT : nullptr, compiler_options.GetInstructionSet(), compiler_options.GetInstructionSetFeatures()); } diff --git a/runtime/jit/debugger_interface.cc b/runtime/jit/debugger_interface.cc index f522be81bd..2a5485c422 100644 --- a/runtime/jit/debugger_interface.cc +++ b/runtime/jit/debugger_interface.cc @@ -299,6 +299,7 @@ static void RepackEntries(PackElfFileForJITFunction pack, // The number of methods per entry is variable (depending on how many fit in that range). constexpr uint32_t kGroupSize = 64 * KB; + CHECK(pack != nullptr); JITCodeEntries packed_entries; std::vector<ArrayRef<const uint8_t>> added; std::vector<const void*> removed; @@ -367,7 +368,21 @@ void AddNativeDebugInfoForJit(Thread* self, // Must be done before addition in case the added code_ptr is in the removed set. if (!g_jit_removed_entries.empty()) { g_compressed_jit_debug_entries.merge(g_uncompressed_jit_debug_entries); - RepackEntries(pack, isa, features, /*compress=*/ true, &g_compressed_jit_debug_entries); + if (pack != nullptr) { + RepackEntries(pack, isa, features, /*compress=*/ true, &g_compressed_jit_debug_entries); + } else { + // If repacking function is not provided, just remove the individual entries. + for (const void* removed_code_ptr : g_jit_removed_entries) { + auto it = g_compressed_jit_debug_entries.find(removed_code_ptr); + if (it != g_compressed_jit_debug_entries.end()) { + DeleteJITCodeEntryInternal(__jit_debug_descriptor, + __jit_debug_register_code_ptr, + /*entry=*/ it->second, + /*free_symfile=*/ true); + g_compressed_jit_debug_entries.erase(it); + } + } + } g_jit_removed_entries.clear(); g_jit_num_unpacked_entries = 0; } @@ -397,7 +412,7 @@ void AddNativeDebugInfoForJit(Thread* self, // Pack (but don't compress) recent entries - this is cheap and reduces memory use by ~4x. // We delay compression until after GC since it is more expensive (and saves further ~4x). - if (g_jit_num_unpacked_entries >= kJitMaxUnpackedEntries) { + if (g_jit_num_unpacked_entries >= kJitMaxUnpackedEntries && pack != nullptr) { RepackEntries(pack, isa, features, /*compress=*/ false, &g_uncompressed_jit_debug_entries); g_jit_num_unpacked_entries = 0; } diff --git a/runtime/jit/debugger_interface.h b/runtime/jit/debugger_interface.h index 19507b0f9a..f84f08d019 100644 --- a/runtime/jit/debugger_interface.h +++ b/runtime/jit/debugger_interface.h @@ -48,6 +48,8 @@ void RemoveNativeDebugInfoForDex(Thread* self, const DexFile* dexfile); // Notify native tools (e.g. libunwind) that JIT has compiled a new method. // The method will make copy of the passed ELF file (to shrink it to the minimum size). +// If packing function is provided, ELF files can be merged to save space +// (however, the merging drops advanced gdb debug-info as it is too complex). void AddNativeDebugInfoForJit(Thread* self, const void* code_ptr, const std::vector<uint8_t>& symfile, |