]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
print-die.cc: Grok --refs-shared-cu, --refs-shared-file options to share the refs_map...
authorRoland McGrath <roland@redhat.com>
Wed, 16 Sep 2009 02:16:18 +0000 (19:16 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 16 Sep 2009 07:41:28 +0000 (00:41 -0700)
tests/ChangeLog
tests/print-die.cc

index 7316f5cdb61cdea184ab764acbcb12c4cbcf7c49..a11de050ba9c82c86cd7b21175afd184d544f6e4 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-15  Roland McGrath  <roland@redhat.com>
+
+       * print-die.cc: Grok --refs-shared-cu, --refs-shared-file options
+       to share the refs_map across CUs or across files.
+
 2009-08-28  Roland McGrath  <roland@redhat.com>
 
        * run-dwarfcmp-self.sh: Test dwarfcmp-test binary too.
index 6816632adddc3717048db7021c7a6a507e3e6222..b472a270ec3128d22be82005ec981b484dc98818 100644 (file)
@@ -50,6 +50,8 @@ static bool elide_refs;
 static bool dump_refs;
 static bool no_print;
 static bool output_stats;
+static bool refs_shared_cu;
+static bool refs_shared_file;
 
 static enum { copy_none, copy_edit, copy_output } make_copy;
 
@@ -88,6 +90,20 @@ print_die_main (int &argc, char **&argv, unsigned int &depth)
       ++argv;
     }
 
+  if (argc > 1 && !strcmp (argv[1], "--refs-shared-cu"))
+    {
+      refs_shared_cu = true;
+      --argc;
+      ++argv;
+    }
+
+  if (argc > 1 && !strcmp (argv[1], "--refs-shared-file"))
+    {
+      refs_shared_file = refs_shared_cu = true;
+      --argc;
+      ++argv;
+    }
+
   if (argc > 1 && !strcmp (argv[1], "--sort-attrs"))
     {
       sort_attrs = true;
@@ -277,20 +293,16 @@ dump_nth (pair<int, int> p)
 
 template<typename file>
 static void
-print_cu (const typename file::compile_unit &cu, const unsigned int limit)
+print_cu (const typename file::compile_unit &cu, const unsigned int limit,
+         refs_map &refs)
 {
-  const typename file::debug_info_entry &die = cu;
-  // static_cast<const typename file::debug_info_entry &> (cu),
-
-  refs_map refs;
+  const typename file::debug_info_entry &die
+    = static_cast<const typename file::debug_info_entry &> (cu);
 
   if (!print_offset && !elide_refs)
     prewalk_die<file> (die, refs);
 
   print_die<file> (die, 1, limit, refs);
-
-  if (dump_refs)
-    for_each (nth_ref.begin (), nth_ref.end (), dump_nth);
 }
 
 template<typename file>
@@ -300,9 +312,21 @@ print_file (const file &dw, const unsigned int limit)
   if (no_print)
     return;
 
+  static refs_map common_refs;
+  refs_map file_refs;
+
   for (typename file::compile_units::const_iterator i
         = dw.compile_units ().begin (); i != dw.compile_units ().end (); ++i)
-    print_cu<file> (*i, limit);
+    if (refs_shared_cu)
+      print_cu<file> (*i, limit, refs_shared_file ? common_refs : file_refs);
+    else
+      {
+       refs_map refs;
+       print_cu<file> (*i, limit, refs);
+      }
+
+  if (dump_refs)
+    for_each (nth_ref.begin (), nth_ref.end (), dump_nth);
 }
 
 template<typename file>