A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+52 -28
+2 -2
apps/codecs.c
··· 138 138 #ifdef RB_PROFILE 139 139 profile_thread, 140 140 profstop, 141 - profile_func_enter, 142 - profile_func_exit, 141 + __cyg_profile_func_enter, 142 + __cyg_profile_func_exit, 143 143 #endif 144 144 145 145 #if defined(HAVE_RECORDING) && !defined(SIMULATOR)
+2
apps/codecs/SOURCES
··· 7 7 a52.c 8 8 mpc.c 9 9 wavpack.c 10 + #ifndef RB_PROFILE 10 11 alac.c 12 + #endif 11 13 wma.c 12 14 #if MEMORYSIZE > 1 13 15 aac.c
+2 -2
apps/plugin.c
··· 335 335 #ifdef RB_PROFILE 336 336 profile_thread, 337 337 profstop, 338 - profile_func_enter, 339 - profile_func_exit, 338 + __cyg_profile_func_enter, 339 + __cyg_profile_func_exit, 340 340 #endif 341 341 342 342 #ifdef SIMULATOR
+4
apps/plugins/SUBDIRS
··· 33 33 /* For all the color targets */ 34 34 #if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \ 35 35 (LCD_DEPTH == 2) && !defined(ARCHOS_AV300) 36 + #ifndef RB_PROFILE 36 37 doom 38 + #endif 37 39 #endif 38 40 39 41 /* For all the swcodec targets */ 40 42 #if CONFIG_CODEC == SWCODEC 41 43 midi 42 44 /* beatbox */ 45 + #ifndef RB_PROFILE 43 46 mpegplayer 47 + #endif 44 48 #endif 45 49 46 50 #endif /* IRIVER_IFP7XX_SERIES */
+2 -2
firmware/export/profile.h
··· 39 39 void profile_thread_started(int current_thread) 40 40 NO_PROF_ATTR; 41 41 42 - void profile_func_exit(void *this_fn, void *call_site) 42 + void __cyg_profile_func_exit(void *this_fn, void *call_site) 43 43 NO_PROF_ATTR ICODE_ATTR; 44 - void profile_func_enter(void *this_fn, void *call_site) 44 + void __cyg_profile_func_enter(void *this_fn, void *call_site) 45 45 NO_PROF_ATTR ICODE_ATTR; 46 46 47 47 #endif /*_SYS_PROFILE_H*/
+13 -10
firmware/profile.c
··· 62 62 #include <sys/types.h> 63 63 #include "profile.h" 64 64 65 - 66 65 /* PFD is Profiled Function Data */ 67 66 68 67 /* Indices are shorts which means that we use 4k of RAM */ ··· 75 74 * for profiling, and allows for profiling sections of code with up-to 76 75 * 1024 function caller->callee pairs 77 76 */ 78 - #define NUMPFDS 1024 77 + #define NUMPFDS 512 79 78 80 79 struct pfd_struct { 81 80 void *self_pc; ··· 141 140 if (profiling < PROF_ERROR) { 142 141 /* After we de-mask, if profiling is active, reactivate the timer */ 143 142 timer_register(0, profile_timer_unregister, 144 - TIMER_FREQ/10000, 0, profile_timer_tick); 143 + TIMER_FREQ/10000, 0, profile_timer_tick IF_COP(, 0 ) ); 145 144 } 146 145 } 147 146 } ··· 168 167 last_pfd = (struct pfd_struct*)0; 169 168 pfds[0].link = 0; 170 169 pfds[0].self_pc = 0; 171 - memset(&indices,0,INDEX_SIZE * sizeof(unsigned short)); 170 + memset(indices,0,INDEX_SIZE * sizeof(unsigned short)); 172 171 timer_register( 173 - 0, profile_timer_unregister, TIMER_FREQ/10000, 0, profile_timer_tick); 172 + 0, profile_timer_unregister, TIMER_FREQ/10000, 0, profile_timer_tick IF_COP(, 0 ) ); 174 173 profiling = PROF_ON; 175 174 } 176 175 ··· 179 178 fdprintf(fd,"0x%08lX\t%08ld\t%08ld\t%04d\n", (size_t)pfd->self_pc, 180 179 pfd->count, pfd->time, depth); 181 180 if (link > 0 && link < NUMPFDS) { 182 - write_function_recursive(fd, &pfds[link], depth++); 181 + write_function_recursive(fd, &pfds[link], ++depth); 183 182 } 184 183 } 185 184 ··· 206 205 } 207 206 } 208 207 fdprintf(fd,"DEBUG PROFILE DATA FOLLOWS\n"); 209 - fdprintf(fd,"INDEX\tLOCATION\tSELF_PC\t\tCOUNT\t\tTIME\t\tLINK\tCALLER\n"); 208 + fdprintf(fd,"INDEX\tLOCATION\tSELF_PC\t\tCOUNT\t\tTIME\t\tLINK\tCALLER_IDX\n"); 210 209 for (i = 0; i < NUMPFDS; i++) { 211 210 struct pfd_struct *my_last_pfd = &pfds[i]; 212 211 if (my_last_pfd->self_pc != 0) { ··· 214 213 "%04d\t0x%08lX\t0x%08lX\t0x%08lX\t0x%08lX\t%04d\t0x%08lX\n", 215 214 i, (size_t)my_last_pfd, (size_t)my_last_pfd->self_pc, 216 215 my_last_pfd->count, my_last_pfd->time, my_last_pfd->link, 217 - (size_t)my_last_pfd->caller); 216 + (size_t)my_last_pfd->caller ); 218 217 } 219 218 } 220 219 fdprintf(fd,"INDEX_ADDRESS=INDEX\n"); ··· 224 223 close(fd); 225 224 } 226 225 227 - void profile_func_exit(void *self_pc, void *call_site) { 226 + void __cyg_profile_func_exit(void *self_pc, void *call_site) { 228 227 (void)call_site; 229 228 (void)self_pc; 230 229 /* When we started timing, we set the time to the tick at that time ··· 255 254 pfd = &pfds[temp];\ 256 255 pfd->self_pc = self_pc; pfd->count = 1; pfd->time = 0 257 256 258 - void profile_func_enter(void *self_pc, void *from_pc) { 257 + void __cyg_profile_func_enter(void *self_pc, void *from_pc) { 259 258 struct pfd_struct *pfd; 260 259 struct pfd_struct *prev_pfd; 261 260 unsigned short *pfd_index_pointer; ··· 339 338 profiling = PROF_ERROR; 340 339 return; 341 340 } 341 + 342 + 343 + 344 +
+27 -12
tools/profile_reader/profile_reader.pl
··· 36 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 40 # return hash(number:string) 41 41 sub read_library { 42 - open(OBJECT_FILE,"objdump -t $_[0] |") || 43 - error("Couldn't pipe objdump for $_[0]"); 42 + open(OBJECT_FILE,"$_[2] -t $_[0] |") || 43 + error("Couldn't pipe objdump for $_[0]\nCommand was: $_[2] -t $_[0]"); 44 44 my $library = $_[1]; 45 45 my %library = %$library; 46 46 my %retval; ··· 62 62 if ($parts[3] eq $parts[5]) { 63 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 66 my $region = $parts[3]; 67 67 my $symbolOffset = hex("0x" . $parts[0]); 68 68 my $sectionOffset = hex($library{$object . $region}); ··· 139 139 my $totalCalls = 0; 140 140 my $totalTicks = 0; 141 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 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 152 $pfds++; 145 153 $totalCalls += @$element[0]; 146 154 $totalTicks += @$element[1]; ··· 174 182 print STDERR ("Error: @_\n"); 175 183 } 176 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 186 print STDERR 179 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 192 print STDERR 181 193 ("\tmap map file, extension is .map\n"); 182 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 196 print STDERR 185 197 ("\tformat 0-2[_p] 0: by calls, 1: by ticks, 2: by name\n"); 186 198 print STDERR ··· 195 207 if ($ARGV[0] =~ m/-(h|help|-help)/) { 196 208 usage(); 197 209 } 198 - if (@ARGV < 2) { 199 - usage("Requires at least 2 arguments"); 210 + if (@ARGV < 3) { 211 + usage("Requires at least 3 arguments"); 200 212 } 201 213 if ($ARGV[0] !~ m/\.out$/) { 202 214 usage("Profile file must end in .out"); 203 215 } 204 - my $i = 1; 216 + my $i = 2; 205 217 my %symbols; 206 218 { 207 219 my %map; ··· 209 221 my $file = $ARGV[$i]; 210 222 if ($file =~ m/\.map$/) { 211 223 %map = read_map($file); 212 - } elsif ($file =~ m/\.[ao]$/) { 224 + } elsif ($file =~ m/\.(a|o|elf)$/) { 213 225 if (!%map) { 214 226 usage("No map file found before first object file"); 215 227 } 216 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 230 %symbols = merge_hashes(\%symbols,\%new_symbols); 219 231 } else { 220 232 last; ··· 224 236 if (!%symbols) { 225 237 warning("No symbols found"); 226 238 } 239 + if ($i >= @ARGV) { 240 + error("You forgot to specify any sort ordering on output (e.g. 0, 1_p, 2)"); 241 + } 227 242 my @pfds = create_list($ARGV[0],\%symbols); 228 243 for (; $i < @ARGV; $i++) { 229 244 print_sorted(\@pfds,split("_",$ARGV[$i]));