aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkstack.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkstack.pl')
-rwxr-xr-xscripts/checkstack.pl27
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 340ad6920511..3eca62566d6b 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -26,12 +26,17 @@
26# $& (whole re) matches the complete objdump line with the stack growth 26# $& (whole re) matches the complete objdump line with the stack growth
27# $1 (first bracket) matches the size of the stack growth 27# $1 (first bracket) matches the size of the stack growth
28# 28#
29# $dre is similar, but for dynamic stack redutions:
30# $& (whole re) matches the complete objdump line with the stack growth
31# $1 (first bracket) matches the dynamic amount of the stack growth
32#
29# use anything else and feel the pain ;) 33# use anything else and feel the pain ;)
30my (@stack, $re, $x, $xs); 34my (@stack, $re, $dre, $x, $xs);
31{ 35{
32 my $arch = shift; 36 my $arch = shift;
33 if ($arch eq "") { 37 if ($arch eq "") {
34 $arch = `uname -m`; 38 $arch = `uname -m`;
39 chomp($arch);
35 } 40 }
36 41
37 $x = "[0-9a-f]"; # hex character 42 $x = "[0-9a-f]"; # hex character
@@ -46,9 +51,11 @@ my (@stack, $re, $x, $xs);
46 } elsif ($arch =~ /^i[3456]86$/) { 51 } elsif ($arch =~ /^i[3456]86$/) {
47 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp 52 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
48 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o; 53 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
54 $dre = qr/^.*[as][du][db] (%.*),\%esp$/o;
49 } elsif ($arch eq 'x86_64') { 55 } elsif ($arch eq 'x86_64') {
50 # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp 56 # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
51 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o; 57 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o;
58 $dre = qr/^.*[as][du][db] (\%.*),\%rsp$/o;
52 } elsif ($arch eq 'ia64') { 59 } elsif ($arch eq 'ia64') {
53 #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12 60 #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
54 $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o; 61 $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
@@ -85,7 +92,7 @@ my (@stack, $re, $x, $xs);
85 # 0: 00 e8 38 01 LINK 0x4e0; 92 # 0: 00 e8 38 01 LINK 0x4e0;
86 $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; 93 $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
87 } else { 94 } else {
88 print("wrong or unknown architecture\n"); 95 print("wrong or unknown architecture \"$arch\"\n");
89 exit 96 exit
90 } 97 }
91} 98}
@@ -141,6 +148,22 @@ while (my $line = <STDIN>) {
141 next if ($size < 100); 148 next if ($size < 100);
142 push @stack, "$intro$size\n"; 149 push @stack, "$intro$size\n";
143 } 150 }
151 elsif (defined $dre && $line =~ m/$dre/) {
152 my $size = "Dynamic ($1)";
153
154 next if $line !~ m/^($xs*)/;
155 my $addr = $1;
156 $addr =~ s/ /0/g;
157 $addr = "0x$addr";
158
159 my $intro = "$addr $func [$file]:";
160 my $padlen = 56 - length($intro);
161 while ($padlen > 0) {
162 $intro .= ' ';
163 $padlen -= 8;
164 }
165 push @stack, "$intro$size\n";
166 }
144} 167}
145 168
146print sort bysize @stack; 169print sort bysize @stack;