Bug 1464537 - Fall back to the raw symbol name from DW_AT_MIPS_linkage_name when there is nothing else. r?ted draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 29 May 2018 08:28:39 +0900
changeset 800730 494342c311c07be38d7fff6c9809a0ff913bfd95
parent 800729 d070d21328acd5e0c4a1dc5d55e30592b362f930
child 800731 7c140332acccd2e572ab0a59a8a134c6fcfe6c92
child 801272 8b88666223d6b67885dcbe9abc52395c12a2bd61
push id111452
push userbmo:mh+mozilla@glandium.org
push dateMon, 28 May 2018 23:46:10 +0000
reviewersted
bugs1464537
milestone62.0a1
Bug 1464537 - Fall back to the raw symbol name from DW_AT_MIPS_linkage_name when there is nothing else. r?ted When DW_AT_MIPS_linkage_name doesn't demangle, breakpad currently throws the symbol completely, but in some cases, there is no DW_AT_name or DW_AT_abstract_origin to figure out a name, and the raw value from DW_AT_MIPS_linkage_name is still better than nothing. Fall back to that in when there is nothing else.
toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
@@ -283,16 +283,20 @@ class DwarfCUToModule::GenericDIEHandler
   // The value of the DW_AT_name attribute, or the empty string if the
   // DIE has no such attribute.
   string name_attribute_;
 
   // The demangled value of the DW_AT_MIPS_linkage_name attribute, or the empty
   // string if the DIE has no such attribute or its content could not be
   // demangled.
   string demangled_name_;
+
+  // The non-demangled value of the DW_AT_MIPS_linkage_name attribute,
+  // it its content count not be demangled.
+  string raw_name_;
 };
 
 void DwarfCUToModule::GenericDIEHandler::ProcessAttributeUnsigned(
     enum DwarfAttribute attr,
     enum DwarfForm form,
     uint64 data) {
   switch (attr) {
     case dwarf2reader::DW_AT_declaration: declaration_ = (data != 0); break;
@@ -355,16 +359,17 @@ void DwarfCUToModule::GenericDIEHandler:
       char* demangled = NULL;
       int status = -1;
 #if !defined(__ANDROID__)  // Android NDK doesn't provide abi::__cxa_demangle.
       demangled = abi::__cxa_demangle(data.c_str(), NULL, NULL, &status);
 #endif
       if (status != 0) {
         cu_context_->reporter->DemangleError(data, status);
         demangled_name_ = "";
+        raw_name_ = AddStringToPool(data);
         break;
       }
       if (demangled) {
         demangled_name_ = AddStringToPool(demangled);
         free(reinterpret_cast<void*>(demangled));
       }
       break;
     }
@@ -389,16 +394,18 @@ string DwarfCUToModule::GenericDIEHandle
   const string *enclosing_name;
   if (!qualified_name) {
     // Find the unqualified name. If the DIE has its own DW_AT_name
     // attribute, then use that; otherwise, check the specification.
     if (!name_attribute_.empty())
       unqualified_name = &name_attribute_;
     else if (specification_)
       unqualified_name = &specification_->unqualified_name;
+    else if (!raw_name_.empty())
+      unqualified_name = &raw_name_;
 
     // Find the name of the enclosing context. If this DIE has a
     // specification, it's the specification's enclosing context that
     // counts; otherwise, use this DIE's context.
     if (specification_)
       enclosing_name = &specification_->enclosing_name;
     else
       enclosing_name = &parent_context_->name;