diff options
author | 2016-02-04 13:17:41 +0000 | |
---|---|---|
committer | 2016-02-04 13:17:41 +0000 | |
commit | ac6a195ec8e1b5a7a6bd3d0c53d8997ff7a5e2cc (patch) | |
tree | 541d9f2eeeeb4d1b7f3e56846542d826d0f6be59 /compiler/elf_writer_debug.cc | |
parent | 867d63b65f653d27dc7ea87e924f47148cec22a7 (diff) | |
parent | 579942fc26f8a0b0ff1d909d19086fca6d2396a3 (diff) |
Merge "Reduce the size of native debug info generated by JIT."
Diffstat (limited to 'compiler/elf_writer_debug.cc')
-rw-r--r-- | compiler/elf_writer_debug.cc | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc index d1f50073a0..ca8cd68b33 100644 --- a/compiler/elf_writer_debug.cc +++ b/compiler/elf_writer_debug.cc @@ -1148,13 +1148,19 @@ class DebugInfoWriter { writer.Write(types); } - void End() { + void End(bool write_oat_patches) { builder_->GetDebugInfo()->End(); - builder_->WritePatches(".debug_info.oat_patches", - ArrayRef<const uintptr_t>(debug_info_patches_)); + if (write_oat_patches) { + builder_->WritePatches(".debug_info.oat_patches", + ArrayRef<const uintptr_t>(debug_info_patches_)); + } builder_->WriteSection(".debug_abbrev", &debug_abbrev_buffer_); - builder_->WriteSection(".debug_loc", &debug_loc_); - builder_->WriteSection(".debug_ranges", &debug_ranges_); + if (!debug_loc_.empty()) { + builder_->WriteSection(".debug_loc", &debug_loc_); + } + if (!debug_ranges_.empty()) { + builder_->WriteSection(".debug_ranges", &debug_ranges_); + } } private: @@ -1357,10 +1363,12 @@ class DebugLineWriter { return buffer.size(); } - void End() { + void End(bool write_oat_patches) { builder_->GetDebugLine()->End(); - builder_->WritePatches(".debug_line.oat_patches", - ArrayRef<const uintptr_t>(debug_line_patches)); + if (write_oat_patches) { + builder_->WritePatches(".debug_line.oat_patches", + ArrayRef<const uintptr_t>(debug_line_patches)); + } } private: @@ -1370,7 +1378,8 @@ class DebugLineWriter { template<typename ElfTypes> static void WriteDebugSections(ElfBuilder<ElfTypes>* builder, - const ArrayRef<const MethodDebugInfo>& method_infos) { + const ArrayRef<const MethodDebugInfo>& method_infos, + bool write_oat_patches) { // Group the methods into compilation units based on source file. std::vector<CompilationUnit> compilation_units; const char* last_source_file = nullptr; @@ -1394,7 +1403,7 @@ static void WriteDebugSections(ElfBuilder<ElfTypes>* builder, for (auto& compilation_unit : compilation_units) { line_writer.WriteCompilationUnit(compilation_unit); } - line_writer.End(); + line_writer.End(write_oat_patches); } // Write .debug_info section. @@ -1404,7 +1413,7 @@ static void WriteDebugSections(ElfBuilder<ElfTypes>* builder, for (const auto& compilation_unit : compilation_units) { info_writer.WriteCompilationUnit(compilation_unit); } - info_writer.End(); + info_writer.End(write_oat_patches); } } @@ -1484,13 +1493,14 @@ static void WriteDebugSymbols(ElfBuilder<ElfTypes>* builder, template <typename ElfTypes> void WriteDebugInfo(ElfBuilder<ElfTypes>* builder, const ArrayRef<const MethodDebugInfo>& method_infos, - CFIFormat cfi_format) { + CFIFormat cfi_format, + bool write_oat_patches) { // Add methods to .symtab. WriteDebugSymbols(builder, method_infos, true /* with_signature */); // Generate CFI (stack unwinding information). - WriteCFISection(builder, method_infos, cfi_format, true /* write_oat_patches */); + WriteCFISection(builder, method_infos, cfi_format, write_oat_patches); // Write DWARF .debug_* sections. - WriteDebugSections(builder, method_infos); + WriteDebugSections(builder, method_infos, write_oat_patches); } static void XzCompress(const std::vector<uint8_t>* src, std::vector<uint8_t>* dst) { @@ -1571,10 +1581,12 @@ static ArrayRef<const uint8_t> WriteDebugElfFileForMethodInternal( buffer.reserve(KB); VectorOutputStream out("Debug ELF file", &buffer); std::unique_ptr<ElfBuilder<ElfTypes>> builder(new ElfBuilder<ElfTypes>(isa, &out)); - builder->Start(); + // No program headers since the ELF file is not linked and has no allocated sections. + builder->Start(false /* write_program_headers */); WriteDebugInfo(builder.get(), ArrayRef<const MethodDebugInfo>(&method_info, 1), - DW_DEBUG_FRAME_FORMAT); + DW_DEBUG_FRAME_FORMAT, + false /* write_oat_patches */); builder->End(); CHECK(builder->Good()); // Make a copy of the buffer. We want to shrink it anyway. @@ -1601,12 +1613,12 @@ static ArrayRef<const uint8_t> WriteDebugElfFileForClassesInternal( buffer.reserve(KB); VectorOutputStream out("Debug ELF file", &buffer); std::unique_ptr<ElfBuilder<ElfTypes>> builder(new ElfBuilder<ElfTypes>(isa, &out)); - builder->Start(); - + // No program headers since the ELF file is not linked and has no allocated sections. + builder->Start(false /* write_program_headers */); DebugInfoWriter<ElfTypes> info_writer(builder.get()); info_writer.Start(); info_writer.WriteTypes(types); - info_writer.End(); + info_writer.End(false /* write_oat_patches */); builder->End(); CHECK(builder->Good()); @@ -1630,11 +1642,13 @@ ArrayRef<const uint8_t> WriteDebugElfFileForClasses(const InstructionSet isa, template void WriteDebugInfo<ElfTypes32>( ElfBuilder<ElfTypes32>* builder, const ArrayRef<const MethodDebugInfo>& method_infos, - CFIFormat cfi_format); + CFIFormat cfi_format, + bool write_oat_patches); template void WriteDebugInfo<ElfTypes64>( ElfBuilder<ElfTypes64>* builder, const ArrayRef<const MethodDebugInfo>& method_infos, - CFIFormat cfi_format); + CFIFormat cfi_format, + bool write_oat_patches); template void WriteMiniDebugInfo<ElfTypes32>( ElfBuilder<ElfTypes32>* builder, const ArrayRef<const MethodDebugInfo>& method_infos); |