[llvm-commits] CVS: llvm/utils/GenLibDeps.pl
Reid Spencer
reid at x10sys.com
Tue Jul 25 12:12:21 PDT 2006
Changes in directory llvm/utils:
GenLibDeps.pl updated: 1.8 -> 1.9
---
Log message:
Add a feature for debugging library dependency cycles, -why option. This
implies -flat and will produce a list of all the symbols for each library
that another library depends on. Run the output through c++filt for
better readability. Also, don't generate a temporary file for storing the
dependent library names. Perl can handle it in a %hash.
---
Diffs of the changes: (+27 -16)
GenLibDeps.pl | 43 +++++++++++++++++++++++++++----------------
1 files changed, 27 insertions(+), 16 deletions(-)
Index: llvm/utils/GenLibDeps.pl
diff -u llvm/utils/GenLibDeps.pl:1.8 llvm/utils/GenLibDeps.pl:1.9
--- llvm/utils/GenLibDeps.pl:1.8 Fri May 12 21:48:45 2006
+++ llvm/utils/GenLibDeps.pl Tue Jul 25 14:12:06 2006
@@ -10,12 +10,15 @@
#
# Parse arguments...
+my $FLAT = 0;
+my $WHY = 0;
while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
shift;
last if /^--$/; # Stop processing arguments on --
# List command line options here...
if (/^-flat$/) { $FLAT = 1; next; }
+ if (/^-why/) { $WHY = 1; $FLAT = 1; next; }
print "Unknown option: $_ : ignoring!\n";
}
@@ -76,46 +79,54 @@
$lib_ns =~ s/(.*)\.[oa]/$1/;
if ($FLAT) {
print "$lib:";
+ if ($WHY) { print "\n"; }
} else {
print " <dt><b>$lib</b</dt><dd><ul>\n";
}
open UNDEFS,
"$nmPath -g -u $Directory/$lib | sed -e 's/^ *U //' | sort | uniq |";
- open DEPENDS,
- "| sort | uniq > GenLibDeps.out";
+ my %DepLibs;
while (<UNDEFS>) {
chomp;
+ my $lib_printed = 0;
if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) {
- print DEPENDS "$libdefs{$_}\n";
+ $DepLibs{$libdefs{$_}} = [] unless exists $DepLibs{$libdefs{$_}};
+ push(@{$DepLibs{$libdefs{$_}}}, $_);
} elsif (defined($objdefs{$_}) && $objdefs{$_} ne $lib) {
$libroot = $lib;
$libroot =~ s/lib(.*).a/$1/;
if ($objdefs{$_} ne "$libroot.o") {
- print DEPENDS "$objdefs{$_}\n";
+ $DepLibs{$objdefs{$_}} = [] unless exists $DepLibs{$objdefs{$_}};
+ push(@{$DepLibs{$objdefs{$_}}}, $_);
}
}
}
close UNDEFS;
- close DEPENDS;
- open DF, "<GenLibDeps.out";
- while (<DF>) {
- chomp;
+ for my $key (sort keys %DepLibs) {
if ($FLAT) {
- print " $_";
+ print " $key";
+ if ($WHY) {
+ print "\n";
+ my @syms = @{$DepLibs{$key}};
+ foreach $sym (@syms) {
+ print " $sym\n";
+ }
+ }
} else {
- print " <li>$_</li>\n";
+ print " <li>$key</li>\n";
}
- $suffix = substr($_,length($_)-1,1);
- $_ =~ s/(.*)\.[oa]/$1/;
+ $suffix = substr($key,length($key)-1,1);
+ $key =~ s/(.*)\.[oa]/$1/;
if ($suffix eq "a") {
- if (!$FLAT) { print DOT "$lib_ns -> $_ [ weight=0 ];\n" };
+ if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=0 ];\n" };
} else {
- if (!$FLAT) { print DOT "$lib_ns -> $_ [ weight=10];\n" };
+ if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=10];\n" };
}
}
- close DF;
if ($FLAT) {
- print "\n";
+ if (!$WHY) {
+ print "\n";
+ }
} else {
print " </ul></dd>\n";
}
More information about the llvm-commits
mailing list