summaryrefslogtreecommitdiff
path: root/cesar/common
diff options
context:
space:
mode:
authorNicolas Schodet2011-12-15 15:19:03 +0100
committerNicolas Schodet2012-02-28 17:45:18 +0100
commit5068d61ef7d879b975eeb6e1cfdf79a0f2d66810 (patch)
tree2b443ed354c8689fdf2daa9e16fc754857fc3cf9 /cesar/common
parentcba8b5cdde130467260bcb5ec4b4d6e1a390f94a (diff)
cesar/common/tools/cpu-decode: read symbol file
Diffstat (limited to 'cesar/common')
-rwxr-xr-xcesar/common/tools/cpu-decode33
1 files changed, 32 insertions, 1 deletions
diff --git a/cesar/common/tools/cpu-decode b/cesar/common/tools/cpu-decode
index 1d2be39411..12592eeebd 100755
--- a/cesar/common/tools/cpu-decode
+++ b/cesar/common/tools/cpu-decode
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case bundling);
use Pod::Usage;
+use List::MoreUtils qw(lastval);
# Options parsing.
my $help;
@@ -10,10 +11,12 @@ my $man;
my $scale;
my $divisor = 25;
my $unit = 'us';
+my $syms;
GetOptions (
'help|h' => \$help,
'man' => \$man,
'scale|s=s' => \$scale,
+ 'syms|t=s' => \$syms,
) or pod2usage (2);
pod2usage (-verbose => 2) if $man;
pod2usage (1) if $help;
@@ -25,6 +28,31 @@ if (defined $scale)
($divisor, $unit) = ($1 + 0, $2);
}
+# Load symbols.
+my %syms;
+my @syms;
+if (defined $syms)
+{
+ open SYMS, "<$syms" or die "can not load $syms: $!";
+ while (<SYMS>)
+ {
+ if (/^([0-9a-f]{8})\s.*\s(\S+)$/)
+ {
+ $syms{hex ($1)} = $2;
+ }
+ }
+ close SYMS;
+ @syms = sort { $a <=> $b } keys %syms;
+}
+
+sub symbol
+{
+ return '' if !@syms;
+ my ($addr) = @_;
+ $addr = lastval { $_ < $addr } @syms;
+ return " ($syms{$addr})";
+}
+
my %map = (
# For each event:
# - event action:
@@ -119,7 +147,9 @@ my $sum = 0;
$sum += $_ for values %sum;
for (sort keys %sum)
{
- printf "$_: $efmt, %.1f %%\n",
+ my $c = $_;
+ $c =~ s/(sp|pc)=(0x[0-9a-f]{8})/"$1=$2" . symbol (hex ($2))/e;
+ printf "$c: $efmt, %.1f %%\n",
$sum{$_} / $divisor,
$sum{$_} * 100.0 / $sum;
}
@@ -139,6 +169,7 @@ cpu-decode [options] [files...]
-h, --help brief help message
--man output manual
-s, --scale=DIVISOR[/UNIT] scale factor and optional unit
+ -t, --syms=SYMBOL_FILE listing produced by `objdump -t'
=head1 DESCRIPTION