summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2008-07-28 22:43:41 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2008-07-28 22:43:41 +0000
commit52bdcbae856b07d3a793615b98dff338d26302ec (patch)
tree9ee975d98287ca851664cbc626e7d006c0a4264b /tools
parentc323d533c29fcf420df6b63ccf5c37340c7ba6c5 (diff)
downloadrockbox-52bdcbae856b07d3a793615b98dff338d26302ec.tar.gz
rockbox-52bdcbae856b07d3a793615b98dff338d26302ec.zip
Commit FS#9170 by Dave Hooper. Adds support for profiling on ARM, and fixes various issues with compiling profile builds. Also, note that profile_reader.pl syntax has changed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18142 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rwxr-xr-xtools/profile_reader/profile_reader.pl39
1 files changed, 27 insertions, 12 deletions
diff --git a/tools/profile_reader/profile_reader.pl b/tools/profile_reader/profile_reader.pl
index 6a45ddef02..ca40a901d8 100755
--- a/tools/profile_reader/profile_reader.pl
+++ b/tools/profile_reader/profile_reader.pl
@@ -36,11 +36,11 @@ sub read_map {
36 return %retval; 36 return %retval;
37} 37}
38 38
39# string (filename.[ao]), hash(string:number) 39# string (filename.(a|o|elf)), hash(number:string), string(objdump_tool)
40# return hash(number:string) 40# return hash(number:string)
41sub read_library { 41sub read_library {
42 open(OBJECT_FILE,"objdump -t $_[0] |") || 42 open(OBJECT_FILE,"$_[2] -t $_[0] |") ||
43 error("Couldn't pipe objdump for $_[0]"); 43 error("Couldn't pipe objdump for $_[0]\nCommand was: $_[2] -t $_[0]");
44 my $library = $_[1]; 44 my $library = $_[1];
45 my %library = %$library; 45 my %library = %$library;
46 my %retval; 46 my %retval;
@@ -62,7 +62,7 @@ sub read_library {
62 if ($parts[3] eq $parts[5]) { 62 if ($parts[3] eq $parts[5]) {
63 next; 63 next;
64 } 64 }
65 if ($parts[3] =~ m/\.(text|data|rodata|bss|icode|idata|irodata|ibss)/) { 65 if ($parts[3] =~ m/\.(text|data|rodata|bss|icode|idata|irodata|ibss|iram)/) {
66 my $region = $parts[3]; 66 my $region = $parts[3];
67 my $symbolOffset = hex("0x" . $parts[0]); 67 my $symbolOffset = hex("0x" . $parts[0]);
68 my $sectionOffset = hex($library{$object . $region}); 68 my $sectionOffset = hex($library{$object . $region});
@@ -139,8 +139,16 @@ sub print_sorted {
139 my $totalCalls = 0; 139 my $totalCalls = 0;
140 my $totalTicks = 0; 140 my $totalTicks = 0;
141 $pfds = 0; 141 $pfds = 0;
142
143 # we use a key sort, which means numerical fields need to be
144 # numerically sortable by an alphanumeric sort - we can simply
145 # do this by giving the numeric keys trailing zeros. Note that
146 # simple string concatenation (what this used to do) would not do this
142 foreach $element(@pfds) { 147 foreach $element(@pfds) {
143 $elements{@$element[$sort_index] . @$element[2]} = $element; 148 $ne = $element;
149 @$ne[0] = sprintf( "%08d", @$element[0]);
150 @$ne[1] = sprintf( "%08d", @$element[1]);
151 $elements{@$ne[$sort_index] . @$element[2]} = $element;
144 $pfds++; 152 $pfds++;
145 $totalCalls += @$element[0]; 153 $totalCalls += @$element[0];
146 $totalTicks += @$element[1]; 154 $totalTicks += @$element[1];
@@ -174,13 +182,17 @@ sub usage {
174 print STDERR ("Error: @_\n"); 182 print STDERR ("Error: @_\n");
175 } 183 }
176 print STDERR ("USAGE:\n"); 184 print STDERR ("USAGE:\n");
177 print STDERR ("$0 profile.out map obj[...] [map obj[...]...] sort[...]\n"); 185 print STDERR ("$0 profile.out objdump_tool map obj[...] [map obj[...]...] sort[...]\n");
178 print STDERR 186 print STDERR
179 ("\tprofile.out output from the profiler, extension is .out\n"); 187 ("\tprofile.out output from the profiler, extension is .out\n");
188 print STDERR
189 ("\tobjdump_tool name of objdump executable for this platform\n");
190 print STDERR
191 ("\t e.g. arm-elf-objdump\n");
180 print STDERR 192 print STDERR
181 ("\tmap map file, extension is .map\n"); 193 ("\tmap map file, extension is .map\n");
182 print STDERR 194 print STDERR
183 ("\tobj library or object file, extension is .a or .o\n"); 195 ("\tobj library or object file, extension is .a or .o or .elf\n");
184 print STDERR 196 print STDERR
185 ("\tformat 0-2[_p] 0: by calls, 1: by ticks, 2: by name\n"); 197 ("\tformat 0-2[_p] 0: by calls, 1: by ticks, 2: by name\n");
186 print STDERR 198 print STDERR
@@ -195,13 +207,13 @@ sub usage {
195if ($ARGV[0] =~ m/-(h|help|-help)/) { 207if ($ARGV[0] =~ m/-(h|help|-help)/) {
196 usage(); 208 usage();
197} 209}
198if (@ARGV < 2) { 210if (@ARGV < 3) {
199 usage("Requires at least 2 arguments"); 211 usage("Requires at least 3 arguments");
200} 212}
201if ($ARGV[0] !~ m/\.out$/) { 213if ($ARGV[0] !~ m/\.out$/) {
202 usage("Profile file must end in .out"); 214 usage("Profile file must end in .out");
203} 215}
204my $i = 1; 216my $i = 2;
205my %symbols; 217my %symbols;
206{ 218{
207 my %map; 219 my %map;
@@ -209,12 +221,12 @@ my %symbols;
209 my $file = $ARGV[$i]; 221 my $file = $ARGV[$i];
210 if ($file =~ m/\.map$/) { 222 if ($file =~ m/\.map$/) {
211 %map = read_map($file); 223 %map = read_map($file);
212 } elsif ($file =~ m/\.[ao]$/) { 224 } elsif ($file =~ m/\.(a|o|elf)$/) {
213 if (!%map) { 225 if (!%map) {
214 usage("No map file found before first object file"); 226 usage("No map file found before first object file");
215 } 227 }
216 my @parts = split(/\//,$file); 228 my @parts = split(/\//,$file);
217 my %new_symbols = read_library($file,$map{$parts[$#parts]}); 229 my %new_symbols = read_library($file,$map{$parts[$#parts]},$ARGV[1]);
218 %symbols = merge_hashes(\%symbols,\%new_symbols); 230 %symbols = merge_hashes(\%symbols,\%new_symbols);
219 } else { 231 } else {
220 last; 232 last;
@@ -224,6 +236,9 @@ my %symbols;
224if (!%symbols) { 236if (!%symbols) {
225 warning("No symbols found"); 237 warning("No symbols found");
226} 238}
239if ($i >= @ARGV) {
240 error("You forgot to specify any sort ordering on output (e.g. 0, 1_p, 2)");
241}
227my @pfds = create_list($ARGV[0],\%symbols); 242my @pfds = create_list($ARGV[0],\%symbols);
228for (; $i < @ARGV; $i++) { 243for (; $i < @ARGV; $i++) {
229 print_sorted(\@pfds,split("_",$ARGV[$i])); 244 print_sorted(\@pfds,split("_",$ARGV[$i]));