From 626a1666015b0fa201e979870baf06afa93b65e7 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Sun, 12 Apr 2015 13:12:26 +0100 Subject: Append [DEDUPED] suffix to all deduped methods in the symbol table. This resolves old TODO in the code. The first method was never marked as deduped and only the subsequent copies were recognised. Therefore the suffix might have been missing in backtraces. Change-Id: I4882d90f3049f7e196cd38c8987ba02960dab338 --- compiler/elf_writer_debug.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'compiler/elf_writer_debug.cc') diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc index f7811dd18b..6fe05a483d 100644 --- a/compiler/elf_writer_debug.cc +++ b/compiler/elf_writer_debug.cc @@ -16,6 +16,8 @@ #include "elf_writer_debug.h" +#include + #include "compiled_method.h" #include "driver/compiler_driver.h" #include "dex_file-inl.h" @@ -193,6 +195,15 @@ void WriteDebugSections(const CompilerDriver* compiler, cunit_high_pc = std::max(cunit_high_pc, method_info.high_pc_); } + // Find all addresses (low_pc) which contain deduped methods. + // The first instance of method is not marked deduped_, but the rest is. + std::unordered_set deduped_addresses; + for (auto it = method_infos.begin(); it != method_infos.end(); ++it) { + if (it->deduped_) { + deduped_addresses.insert(it->low_pc_); + } + } + // Write .debug_info section. size_t debug_abbrev_offset = debug_abbrev->size(); DebugInfoEntryWriter<> info(false /* 32 bit */, debug_abbrev); @@ -205,10 +216,8 @@ void WriteDebugSections(const CompilerDriver* compiler, for (auto method_info : method_infos) { std::string method_name = PrettyMethod(method_info.dex_method_index_, *method_info.dex_file_, true); - if (method_info.deduped_) { - // TODO We should place the DEDUPED tag on the first instance of a deduplicated symbol - // so that it will show up in a debuggerd crash report. - method_name += " [ DEDUPED ]"; + if (deduped_addresses.find(method_info.low_pc_) != deduped_addresses.end()) { + method_name += " [DEDUPED]"; } info.StartTag(DW_TAG_subprogram, DW_CHILDREN_no); info.WriteStrp(DW_AT_name, method_name.data(), debug_str); -- cgit v1.2.3