Bug 524410 - part 4 - look through lexical block DIEs where appropriate; r=gsvelto
authorNathan Froyd <froydnj@mozilla.com>
Fri, 05 Apr 2019 16:35:10 +0000
changeset 468622 d048bcf083e5df1547230ecc780139a264389889
parent 468621 b3e5b74ed19fcf6c6f44457accccf4bb59eebcb3
child 468623 17040bb20e256476df548a6be770e7d8f78387ef
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs524410
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 524410 - part 4 - look through lexical block DIEs where appropriate; r=gsvelto DW_TAG_subprogram DIEs sometimes have child DW_TAG_lexical_block DIEs which in turn contain child DW_TAG_inlined_subroutine DIEs that we woud like to look at. If we skip the DW_TAG_inlined_subroutine DIEs, we miss important information. We therefore need to look through the DW_TAG_lexical_block DIEs to find the DIEs that we are interested in. Depends on D25471 Differential Revision: https://phabricator.services.mozilla.com/D25472
toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.h
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.cc
@@ -562,16 +562,46 @@ bool DwarfCUToModule::InlinedSubroutineH
   for (const auto& range : ranges) {
     FilePrivate::InlinedSubroutineRange inline_range(range, call_file_, call_line_);
     cu_context_->file_context->file_private_->inlined_ranges.push_back(inline_range);
   }
 
   return ignore_children;
 }
 
+// A handler class for DW_TAG_lexical_block DIEs.
+class DwarfCUToModule::LexicalBlockHandler: public GenericDIEHandler {
+ public:
+  LexicalBlockHandler(CUContext *cu_context, DIEContext *parent_context,
+                      uint64 offset)
+      : GenericDIEHandler(cu_context, parent_context, offset) {}
+
+  bool EndAttributes();
+
+  DIEHandler* FindChildHandler(uint64 offset, enum DwarfTag tag);
+};
+
+
+bool DwarfCUToModule::LexicalBlockHandler::EndAttributes() {
+  // Parse child DIEs if possible.
+  return true;
+}
+
+dwarf2reader::DIEHandler* DwarfCUToModule::LexicalBlockHandler::FindChildHandler(
+    uint64 offset,
+    enum DwarfTag tag) {
+  switch (tag) {
+    case dwarf2reader::DW_TAG_inlined_subroutine:
+      return new InlinedSubroutineHandler(cu_context_, parent_context_, offset);
+
+    default:
+      return NULL;
+  }
+}
+
 // A handler class for DW_TAG_subprogram DIEs.
 class DwarfCUToModule::FuncHandler: public GenericDIEHandler {
  public:
   FuncHandler(CUContext *cu_context, DIEContext *parent_context,
               uint64 offset)
       : GenericDIEHandler(cu_context, parent_context, offset),
         low_pc_(0), high_pc_(0), high_pc_form_(dwarf2reader::DW_FORM_addr),
         ranges_(0), abstract_origin_(NULL), inline_(false) { }
@@ -742,16 +772,24 @@ void DwarfCUToModule::FuncHandler::Finis
 
 dwarf2reader::DIEHandler *DwarfCUToModule::FuncHandler::FindChildHandler(
     uint64 offset,
     enum DwarfTag tag) {
   switch (tag) {
     case dwarf2reader::DW_TAG_inlined_subroutine:
       return new InlinedSubroutineHandler(cu_context_, parent_context_, offset);
 
+      // Compilers will sometimes give DW_TAG_subprogram DIEs
+      // DW_TAG_lexical_block children DIEs, which then in turn contain
+      // DW_TAG_inlined_subroutine DIEs.  We want to parse those
+      // grandchildren as though they belonged to the original
+      // DW_TAG_subprogram DIE.
+    case dwarf2reader::DW_TAG_lexical_block:
+      return new LexicalBlockHandler(cu_context_, parent_context_, offset);
+
     default:
       return NULL;
   }
 }
 
 // A handler for DIEs that contain functions and contribute a
 // component to their names: namespaces, classes, etc.
 class DwarfCUToModule::NamedScopeHandler: public GenericDIEHandler {
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.h
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf_cu_to_module.h
@@ -293,16 +293,17 @@ class DwarfCUToModule: public dwarf2read
   // dwarf_cu_to_module.cc.
   struct CUContext;
   struct DIEContext;
   struct Specification;
   class GenericDIEHandler;
   class FuncHandler;
   class InlinedSubroutineHandler;
   class NamedScopeHandler;
+  class LexicalBlockHandler;
 
   // A map from section offsets to specifications.
   typedef map<uint64, Specification> SpecificationByOffset;
 
   // Set this compilation unit's source language to LANGUAGE.
   void SetLanguage(DwarfLanguage language);
 
   // Read source line information at OFFSET in the .debug_line