From: Roland McGrath Date: Wed, 16 Sep 2009 02:16:18 +0000 (-0700) Subject: print-die.cc: Grok --refs-shared-cu, --refs-shared-file options to share the refs_map... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f4605b3c02dfe60d0474f44967275794b85b1d5c;p=thirdparty%2Felfutils.git print-die.cc: Grok --refs-shared-cu, --refs-shared-file options to share the refs_map across CUs or across files. --- diff --git a/tests/ChangeLog b/tests/ChangeLog index 7316f5cdb..a11de050b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2009-09-15 Roland McGrath + + * 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 * run-dwarfcmp-self.sh: Test dwarfcmp-test binary too. diff --git a/tests/print-die.cc b/tests/print-die.cc index 6816632ad..b472a270e 100644 --- a/tests/print-die.cc +++ b/tests/print-die.cc @@ -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 p) template 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 (cu), - - refs_map refs; + const typename file::debug_info_entry &die + = static_cast (cu); if (!print_offset && !elide_refs) prewalk_die (die, refs); print_die (die, 1, limit, refs); - - if (dump_refs) - for_each (nth_ref.begin (), nth_ref.end (), dump_nth); } template @@ -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 (*i, limit); + if (refs_shared_cu) + print_cu (*i, limit, refs_shared_file ? common_refs : file_refs); + else + { + refs_map refs; + print_cu (*i, limit, refs); + } + + if (dump_refs) + for_each (nth_ref.begin (), nth_ref.end (), dump_nth); } template