Skip to content

Commit 2bbc57a

Browse files
Cleanup perl warnings in stask analyzer
1 parent bb8c1bb commit 2bbc57a

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

utils/stm32stack.pl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
# interrupt handler which might execute.
4848

4949
use strict;
50+
use warnings;
5051
use Data::Dumper;
5152

5253
# Configuration: set these as appropriate for your architecture/project.
@@ -182,7 +183,7 @@ sub trace {
182183

183184
if ($visited{$f}) {
184185
$visited{$f} = "R" if $visited{$f} eq "?";
185-
return;
186+
return 0;
186187
}
187188

188189
$visited{$f} = "?";
@@ -196,9 +197,10 @@ sub trace {
196197
my $t = $_;
197198

198199
$has_caller{$t} = 1;
199-
trace($t);
200+
next unless trace($t);
200201

201-
my $is = $total_cost{$t};
202+
warn "No cost found for $t" if (! defined $total_cost{$t});
203+
my $is = $total_cost{$t} || 0;
202204
my $d = $call_depth{$t};
203205

204206
$max_frame = $is if $is > $max_frame;
@@ -209,6 +211,14 @@ sub trace {
209211
$call_depth{$f} = $max_depth + 1;
210212
$total_cost{$f} = $max_frame + ($frame_size{$f} || 0);
211213
$visited{$f} = " " if $visited{$f} eq "?";
214+
return 1;
215+
}
216+
217+
sub main_cost {
218+
if (defined $global_name{"main"} && defined $total_cost{$global_name{"main"}}) {
219+
return $total_cost{$global_name{"main"}};
220+
}
221+
return 0;
212222
}
213223

214224
foreach (keys %call_graph) { trace $_; }
@@ -251,9 +261,9 @@ sub trace {
251261

252262
print "Peak execution estimate (main + worst-case IV):\n";
253263
printf " main = %d, worst IV = %d, total = %d\n",
254-
$total_cost{$global_name{"main"}},
264+
main_cost(),
255265
$total_cost{"INTERRUPT"},
256-
$total_cost{$global_name{"main"}} + $total_cost{"INTERRUPT"};
266+
main_cost() + $total_cost{"INTERRUPT"};
257267

258268
print "\n";
259269

0 commit comments

Comments
 (0)