From 5cc349f3dd578e974f78314c50b6a0267c23e591 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Fri, 18 Dec 2015 15:04:48 +0000 Subject: Report DWARF debug information for JITed code. Change-Id: Ia5b2133c54386932c76c22774cf3d2ae61e0925f --- compiler/optimizing/optimizing_compiler.cc | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 3eb72744ee..82f1e84454 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -17,6 +17,7 @@ #include "optimizing_compiler.h" #include +#include #include #ifdef ART_ENABLE_CODEGEN_arm64 @@ -52,6 +53,8 @@ #include "driver/compiler_driver-inl.h" #include "driver/compiler_options.h" #include "driver/dex_compilation_unit.h" +#include "dwarf/method_debug_info.h" +#include "elf_writer_debug.h" #include "elf_writer_quick.h" #include "graph_checker.h" #include "graph_visualizer.h" @@ -60,6 +63,7 @@ #include "inliner.h" #include "instruction_simplifier.h" #include "intrinsics.h" +#include "jit/debugger_interface.h" #include "jit/jit_code_cache.h" #include "licm.h" #include "jni/quick/jni_compiler.h" @@ -68,6 +72,7 @@ #include "prepare_for_register_allocation.h" #include "reference_type_propagation.h" #include "register_allocator.h" +#include "oat_quick_method_header.h" #include "sharpening.h" #include "side_effects_analysis.h" #include "ssa_builder.h" @@ -968,6 +973,39 @@ bool OptimizingCompiler::JitCompile(Thread* self, return false; } + if (GetCompilerDriver()->GetCompilerOptions().GetGenerateDebugInfo()) { + const auto* method_header = reinterpret_cast(code); + const uintptr_t code_address = reinterpret_cast(method_header->GetCode()); + CompiledMethod compiled_method( + GetCompilerDriver(), + codegen->GetInstructionSet(), + ArrayRef(code_allocator.GetMemory()), + codegen->HasEmptyFrame() ? 0 : codegen->GetFrameSize(), + codegen->GetCoreSpillMask(), + codegen->GetFpuSpillMask(), + ArrayRef(), + ArrayRef(), // mapping_table. + ArrayRef(stack_map_data, stack_map_size), + ArrayRef(), // native_gc_map. + ArrayRef(*codegen->GetAssembler()->cfi().data()), + ArrayRef()); + dwarf::MethodDebugInfo method_debug_info { + dex_file, + class_def_idx, + method_idx, + access_flags, + code_item, + false, // deduped. + code_address, + code_address + code_allocator.GetSize(), + &compiled_method + }; + ArrayRef elf_file = dwarf::WriteDebugElfFile(method_debug_info); + CreateJITCodeEntryForAddress(code_address, + std::unique_ptr(elf_file.data()), + elf_file.size()); + } + return true; } -- cgit v1.2.3-59-g8ed1b