File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151use Data::Dumper;
5252
5353# Configuration: set these as appropriate for your architecture/project.
54-
54+ my $debug = 0;
5555my $objdump = " arm-none-eabi-objdump" ;
5656my $call_cost = 4;
5757
179179my %call_depth ;
180180
181181sub trace {
182- my $f = shift ;
182+ my ($f , $indent ) = (@_ );
183+ $indent ||= " " ;
183184
184185 if ($visited {$f }) {
185- $visited {$f } = " R" if $visited {$f } eq " ?" ;
186- return 0;
186+ if ($visited {$f } eq " ?" ) {
187+ $visited {$f } = " R" ;
188+ $call_depth {$f } = 1;
189+ $total_cost {$f } = $frame_size {$f } || 0;
190+ }
191+ printf (" ${indent}$f -> %d \n " , $total_cost {$f }) if ($debug );
192+ return ;
187193 }
188194
189195 $visited {$f } = " ?" ;
@@ -197,10 +203,8 @@ sub trace {
197203 my $t = $_ ;
198204
199205 $has_caller {$t } = 1;
200- next unless trace($t );
201-
202- warn " No cost found for $t " if (! defined $total_cost {$t });
203- my $is = $total_cost {$t } || 0;
206+ trace($t , " $indent " );
207+ my $is = $total_cost {$t };
204208 my $d = $call_depth {$t };
205209
206210 $max_frame = $is if $is > $max_frame ;
@@ -211,7 +215,8 @@ sub trace {
211215 $call_depth {$f } = $max_depth + 1;
212216 $total_cost {$f } = $max_frame + ($frame_size {$f } || 0);
213217 $visited {$f } = " " if $visited {$f } eq " ?" ;
214- return 1;
218+ printf (" ${indent}$f -> %d \n " , $total_cost {$f }) if ($debug );
219+ return ;
215220}
216221
217222sub main_cost {
You can’t perform that action at this time.
0 commit comments