mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
add jim's map2dot tool
This commit is contained in:
parent
58561f5b71
commit
ff146c7e9f
31
tools/map2dot.pl
Executable file
31
tools/map2dot.pl
Executable file
@ -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";
|
Loading…
Reference in New Issue
Block a user