]> sourceware.org Git - libabigail.git/commitdiff
Do not build DIE -> parent map just because we see an asm TU
authorDodji Seketeli <dodji@redhat.com>
Wed, 20 Feb 2019 10:25:39 +0000 (11:25 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 20 Feb 2019 10:25:39 +0000 (11:25 +0100)
For languages like C that don't have namespaces, we don't need to
build the DIE -> parent map, and that speeds up the analysis of the
ELF binary in the DWARF reader.

Unfortunately, just because we are seeing some MIPS assembler
translation unit, dwarf_reader::read_context::build_die_parent_maps
unnecessarily builds the DIE -> parent map, making the ELF binary
analysis slower.

This patch introduces the new function
dwarf_reader::read_context::do_we_build_die_parent_maps to make the
decision about building the DIE -> parent map in a central place.  And
it makes dwarf_reader::read_context::build_die_parent_maps use it.

With this, analysing the linux kernel becomes faster again.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc

index 24ddd344c7e579bd4b86bca96e82a78c09177b54..d104d9d77c53fe451eb9f85de27582638878a940 100644 (file)
@@ -7912,6 +7912,45 @@ public:
 
   }
 
+  /// Determine if we do have to build a DIE -> parent map, depending
+  /// on a given language.
+  ///
+  /// Some languages like C++, Ada etc, do have the concept of
+  /// namespace and yet, the DIE data structure doesn't provide us
+  /// with a way to get the parent namespace of a given DIE.  So for
+  /// those languages, we need to build a DIE -> parent map so that we
+  /// can get the namespace DIE (or more generally the scope DIE) of a given
+  /// DIE as we need it.
+  ///
+  /// But then some more basic languages like C or assembly don't have
+  /// that need.
+  ///
+  /// This function, depending on the language, tells us if we need to
+  /// build the DIE -> parent map or not.
+  ///
+  /// @param lang the language to consider.
+  ///
+  /// @return true iff we need to build the DIE -> parent map for this
+  /// language.
+  bool
+  do_we_build_die_parent_maps(translation_unit::language lang)
+  {
+    if (is_c_language(lang))
+      return false;
+
+    switch (lang)
+      {
+      case translation_unit::LANG_UNKNOWN:
+#ifdef HAVE_DW_LANG_Mips_Assembler_enumerator
+      case translation_unit::LANG_Mips_Assembler:
+#endif
+       return false;
+      default:
+       break;
+      }
+    return true;
+  }
+
   /// Walk all the DIEs accessible in the debug info (and in the
   /// alternate debug info as well) and build maps representing the
   /// relationship DIE -> parent.  That is, make it so that we can get
@@ -7952,13 +7991,8 @@ public:
        uint64_t l = 0;
        die_unsigned_constant_attribute(&cu, DW_AT_language, l);
        translation_unit::language lang = dwarf_language_to_tu_language(l);
-       if (!is_c_language(lang) && lang != translation_unit::LANG_UNKNOWN)
-         {
-           // So we'll build the DIE -> parent map as we are
-           // looking at a translation unit that is not C.
-           we_do_have_to_build_die_parent_map = true;
-           break;
-         }
+       if (do_we_build_die_parent_maps(lang))
+         we_do_have_to_build_die_parent_map = true;
       }
 
     if (!we_do_have_to_build_die_parent_map)
This page took 0.05408 seconds and 5 git commands to generate.