Loading avstack.pl +130 −121 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ my %global_name; # "func" -> "func@file" my %ambiguous; # "func" -> 1 foreach (@ARGV) { # Disassemble this object file to obtain a callees. Sources in the # call graph are named "func@file". Targets in the call graph are # named either "offset@file" or "funcname". We also keep a list of Loading @@ -76,8 +77,8 @@ foreach (@ARGV) { my $objfile = $_; my $source; open(DISASSEMBLY, "$objdump -Cdr $objfile|") || die "Can't disassemble $objfile"; open( DISASSEMBLY, "$objdump -Cdr $objfile|" ) || die "Can't disassemble $objfile"; while (<DISASSEMBLY>) { chomp; Loading @@ -99,7 +100,8 @@ foreach (@ARGV) { if ( $t eq ".text" ) { $t = "\@$objfile"; } elsif ($t =~ /^\.text\+0x(.*)$/) { } elsif ( $t =~ /^\.text\+0x(.*)$/ ) { $t = "$1\@$objfile"; } Loading @@ -116,12 +118,16 @@ foreach (@ARGV) { open( SUFILE, "<$sufile" ) || die "Can't open $sufile"; while (<SUFILE>) { if (m{ ^ [^:]+ : \d+ : \d+ : [^\t]+? \s (?<name> \S+ ) \( .*? \) if ( m{ ^ [^:]+ : \d+ : \d+ : [^\t]+? \s (?<name> \S+ ) \( .*? \) (?: \s* \[with [^]]*\])? \t (?<size> \d+ )}x) { (?<size> \d+ )}x ) { $frame_size{"$+{name}\@$objfile"} = $+{size} + $call_cost; } else { } else { say "No match $_"; } } Loading @@ -145,12 +151,15 @@ foreach (keys %call_graph) { if ( defined( $addresses{$t} ) ) { $resolved{ $addresses{$t} } = 1; } elsif (defined($global_name{$t})) { } elsif ( defined( $global_name{$t} ) ) { $resolved{ $global_name{$t} } = 1; warn "Ambiguous resolution: $t" if defined( $ambiguous{$t} ); } elsif (defined($call_graph{$t})) { } elsif ( defined( $call_graph{$t} ) ) { $resolved{$t} = 1; } else { } else { $unresolved{$t} = 1; } } Loading Loading @@ -215,8 +224,7 @@ sub trace { foreach ( keys %call_graph ) { trace $_; } # Now, print results in a nice table. printf " %-30s %8s %8s %8s\n", "Func", "Cost", "Frame", "Height"; printf " %-30s %8s %8s %8s\n", "Func", "Cost", "Frame", "Height"; print "------------------------------------"; print "------------------------------------\n"; Loading @@ -238,7 +246,8 @@ foreach (sort { $total_cost{$b} <=> $total_cost{$a} } keys %visited) { if (/^__vector_/) { $max_iv = $cost if $cost > $max_iv; } elsif (/^main@/) { } elsif (/^main@/) { $main = $cost; } Loading Loading
avstack.pl +130 −121 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ my %global_name; # "func" -> "func@file" my %ambiguous; # "func" -> 1 foreach (@ARGV) { # Disassemble this object file to obtain a callees. Sources in the # call graph are named "func@file". Targets in the call graph are # named either "offset@file" or "funcname". We also keep a list of Loading @@ -76,8 +77,8 @@ foreach (@ARGV) { my $objfile = $_; my $source; open(DISASSEMBLY, "$objdump -Cdr $objfile|") || die "Can't disassemble $objfile"; open( DISASSEMBLY, "$objdump -Cdr $objfile|" ) || die "Can't disassemble $objfile"; while (<DISASSEMBLY>) { chomp; Loading @@ -99,7 +100,8 @@ foreach (@ARGV) { if ( $t eq ".text" ) { $t = "\@$objfile"; } elsif ($t =~ /^\.text\+0x(.*)$/) { } elsif ( $t =~ /^\.text\+0x(.*)$/ ) { $t = "$1\@$objfile"; } Loading @@ -116,12 +118,16 @@ foreach (@ARGV) { open( SUFILE, "<$sufile" ) || die "Can't open $sufile"; while (<SUFILE>) { if (m{ ^ [^:]+ : \d+ : \d+ : [^\t]+? \s (?<name> \S+ ) \( .*? \) if ( m{ ^ [^:]+ : \d+ : \d+ : [^\t]+? \s (?<name> \S+ ) \( .*? \) (?: \s* \[with [^]]*\])? \t (?<size> \d+ )}x) { (?<size> \d+ )}x ) { $frame_size{"$+{name}\@$objfile"} = $+{size} + $call_cost; } else { } else { say "No match $_"; } } Loading @@ -145,12 +151,15 @@ foreach (keys %call_graph) { if ( defined( $addresses{$t} ) ) { $resolved{ $addresses{$t} } = 1; } elsif (defined($global_name{$t})) { } elsif ( defined( $global_name{$t} ) ) { $resolved{ $global_name{$t} } = 1; warn "Ambiguous resolution: $t" if defined( $ambiguous{$t} ); } elsif (defined($call_graph{$t})) { } elsif ( defined( $call_graph{$t} ) ) { $resolved{$t} = 1; } else { } else { $unresolved{$t} = 1; } } Loading Loading @@ -215,8 +224,7 @@ sub trace { foreach ( keys %call_graph ) { trace $_; } # Now, print results in a nice table. printf " %-30s %8s %8s %8s\n", "Func", "Cost", "Frame", "Height"; printf " %-30s %8s %8s %8s\n", "Func", "Cost", "Frame", "Height"; print "------------------------------------"; print "------------------------------------\n"; Loading @@ -238,7 +246,8 @@ foreach (sort { $total_cost{$b} <=> $total_cost{$a} } keys %visited) { if (/^__vector_/) { $max_iv = $cost if $cost > $max_iv; } elsif (/^main@/) { } elsif (/^main@/) { $main = $cost; } Loading