mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-26 21:20:29 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
865f6238f6
commit
c152efda47
@ -10,12 +10,15 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Parse arguments...
|
# Parse arguments...
|
||||||
|
my $FLAT = 0;
|
||||||
|
my $WHY = 0;
|
||||||
while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
|
while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
|
||||||
shift;
|
shift;
|
||||||
last if /^--$/; # Stop processing arguments on --
|
last if /^--$/; # Stop processing arguments on --
|
||||||
|
|
||||||
# List command line options here...
|
# List command line options here...
|
||||||
if (/^-flat$/) { $FLAT = 1; next; }
|
if (/^-flat$/) { $FLAT = 1; next; }
|
||||||
|
if (/^-why/) { $WHY = 1; $FLAT = 1; next; }
|
||||||
print "Unknown option: $_ : ignoring!\n";
|
print "Unknown option: $_ : ignoring!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,46 +79,54 @@ sub gen_one_entry {
|
|||||||
$lib_ns =~ s/(.*)\.[oa]/$1/;
|
$lib_ns =~ s/(.*)\.[oa]/$1/;
|
||||||
if ($FLAT) {
|
if ($FLAT) {
|
||||||
print "$lib:";
|
print "$lib:";
|
||||||
|
if ($WHY) { print "\n"; }
|
||||||
} else {
|
} else {
|
||||||
print " <dt><b>$lib</b</dt><dd><ul>\n";
|
print " <dt><b>$lib</b</dt><dd><ul>\n";
|
||||||
}
|
}
|
||||||
open UNDEFS,
|
open UNDEFS,
|
||||||
"$nmPath -g -u $Directory/$lib | sed -e 's/^ *U //' | sort | uniq |";
|
"$nmPath -g -u $Directory/$lib | sed -e 's/^ *U //' | sort | uniq |";
|
||||||
open DEPENDS,
|
my %DepLibs;
|
||||||
"| sort | uniq > GenLibDeps.out";
|
|
||||||
while (<UNDEFS>) {
|
while (<UNDEFS>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
my $lib_printed = 0;
|
||||||
if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) {
|
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) {
|
} elsif (defined($objdefs{$_}) && $objdefs{$_} ne $lib) {
|
||||||
$libroot = $lib;
|
$libroot = $lib;
|
||||||
$libroot =~ s/lib(.*).a/$1/;
|
$libroot =~ s/lib(.*).a/$1/;
|
||||||
if ($objdefs{$_} ne "$libroot.o") {
|
if ($objdefs{$_} ne "$libroot.o") {
|
||||||
print DEPENDS "$objdefs{$_}\n";
|
$DepLibs{$objdefs{$_}} = [] unless exists $DepLibs{$objdefs{$_}};
|
||||||
|
push(@{$DepLibs{$objdefs{$_}}}, $_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close UNDEFS;
|
close UNDEFS;
|
||||||
close DEPENDS;
|
for my $key (sort keys %DepLibs) {
|
||||||
open DF, "<GenLibDeps.out";
|
|
||||||
while (<DF>) {
|
|
||||||
chomp;
|
|
||||||
if ($FLAT) {
|
if ($FLAT) {
|
||||||
print " $_";
|
print " $key";
|
||||||
|
if ($WHY) {
|
||||||
|
print "\n";
|
||||||
|
my @syms = @{$DepLibs{$key}};
|
||||||
|
foreach $sym (@syms) {
|
||||||
|
print " $sym\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print " <li>$_</li>\n";
|
print " <li>$key</li>\n";
|
||||||
}
|
}
|
||||||
$suffix = substr($_,length($_)-1,1);
|
$suffix = substr($key,length($key)-1,1);
|
||||||
$_ =~ s/(.*)\.[oa]/$1/;
|
$key =~ s/(.*)\.[oa]/$1/;
|
||||||
if ($suffix eq "a") {
|
if ($suffix eq "a") {
|
||||||
if (!$FLAT) { print DOT "$lib_ns -> $_ [ weight=0 ];\n" };
|
if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=0 ];\n" };
|
||||||
} else {
|
} else {
|
||||||
if (!$FLAT) { print DOT "$lib_ns -> $_ [ weight=10];\n" };
|
if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=10];\n" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close DF;
|
|
||||||
if ($FLAT) {
|
if ($FLAT) {
|
||||||
print "\n";
|
if (!$WHY) {
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print " </ul></dd>\n";
|
print " </ul></dd>\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user