From ff146c7e9ff8df6cf0187df61f25775700e15755 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Mon, 1 Mar 2010 18:02:46 -0500 Subject: [PATCH] add jim's map2dot tool --- tools/map2dot.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 tools/map2dot.pl diff --git a/tools/map2dot.pl b/tools/map2dot.pl new file mode 100755 index 000000000..1e834c68f --- /dev/null +++ b/tools/map2dot.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +# Try: +# gcc -static -o test test.c -Wl,--print-map | perl parse-map.pl | unflatten -l 3 | dot -Tpng > map.png +# +# This won't show all edges! An archive member is only listed the first +# time it needs to get included. But this shows at least one reason why each +# archive member appears in the final object. + +my $flag = 0; +my $line = ""; +print "digraph map {\n"; +print "rankdir = LR;"; +while(<>) +{ + $flag++ if /^Archive member included because of file \(symbol\)$/; + $flag++ if /^$/; + next unless $flag == 2; + + chomp ($line .= $_); + if ($line =~ /^(\S+)\s+(\S+)\s+\(([^)]+)\)$/s) { + $line = ""; + my $archive_member = $1; + my $because_file = $2; + my $because_symbol = $3; + $archive_member =~ s|.*/([^/]+)|$1|; + $because_file =~ s|.*/([^/]+)|$1|; + print "\"$because_file\" -> \"$archive_member\";\n"; + } +} +print "}\n";