lkml.org 
[lkml]   [2003]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] add checkstack Makefile target
On Thu, 6 March 2003 02:50:22 +0100, Arnd Bergmann wrote:
>
> Ok, here is another regex for s390, including a changed $line
> calculation. I didn't have ksymoops around, but this change
> removes the need for it and should also speed things up.

Time for allnoconfig went down from 13s to 4s.
Time for allyesconfig went down from 44m to 59s.
Great!

The output is slightly less verbose, but that information wasn't too
useful anyway. Thanks a lot!

BTW: Your mailer did something horrible to the patch, and I had to fix
it manually. Hope it didn't break anything (i386 looks fine).

And mine appears to do the same. Better send it as an attachment until
I fix the cause. :(

Jörn

--
Eighty percent of success is showing up.
-- Woody Allen
diff -Naur linux-2.5.63/Makefile linux-2.5.63-csb1/Makefile
--- linux-2.5.63/Makefile Mon Feb 24 20:05:08 2003
+++ linux-2.5.63-csb1/Makefile Wed Mar 5 20:33:22 2003
@@ -908,3 +908,7 @@
descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)

FORCE:
+
+checkstack: #vmlinux FORCE
+ $(OBJDUMP) -d vmlinux | \
+ $(PERL) scripts/checkstack.pl $(ARCH)
diff -Naur linux-2.5.63/scripts/checkstack.pl linux-2.5.63-csb1/scripts/checkstack.pl
--- linux-2.5.63/scripts/checkstack.pl Thu Jan 1 01:00:00 1970
+++ linux-2.5.63-csb1/scripts/checkstack.pl Wed Mar 5 18:04:19 2003
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+# Check the stack usage of functions
+#
+# Copyright Joern Engel <joern@wh.fh-wedel.de>
+# Inspired by Linus Torvalds
+# Original idea maybe from Keith Owens
+#
+# Usage:
+# objdump -d vmlinux | \
+# stackcheck_ppc.pl
+#
+# TODO : Port to all architectures (one regex per arch)
+# Get rid of ksymoops
+# Speed this puppy up
+
+# check for arch
+#
+# $re is used for three matches:
+# $& (whole re) matches the complete objdump line with the stack growth
+# $1 (first bracket) matches the code that will be displayed in the output
+# $2 (second bracket) matches the size of the stack growth
+#
+# use anything else and feel the pain ;)
+{
+ my $arch = shift;
+ $x = "[0-9a-f]"; # hex character
+ $xs = "[0-9a-f ]"; # hex character or space
+ if ($arch =~ /^i386$/) {
+ #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
+ $re = qr/^.*(sub \$(0x$x{3,5}),\%esp)$/o;
+ } elsif ($arch =~ /^ppc$/) {
+ #c00029f4: 94 21 ff 30 stwu r1,-208(r1)
+ $re = qr/.*(stwu.*r1,-($x{3,5})\(r1\))/o;
+ } elsif ($arch =~ /^s390x?$/) {
+ # 11160: a7 fb ff 60 aghi %r15,-160
+ $re = qr/.*(ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2}))/o;
+ } else {
+ print("wrong or unknown architecture\n");
+ exit
+ }
+}
+
+sub bysize($) {
+ ($asize = $a) =~ s/$re/\2/;
+ ($bsize = $b) =~ s/$re/\2/;
+ $bsize <=> $asize
+}
+
+#
+# main()
+#
+$funcre = qr/^$x* \<(.*)\>:$/;
+while ($line = <STDIN>) {
+ if ($line =~ m/$funcre/) {
+ ($func = $line) =~ s/$funcre/\1/;
+ chomp($func);
+ }
+
+ if ($line =~ m/$re/) {
+ (my $addr = $line) =~ s/^($xs{8}).*/0x\1/o;
+ chomp($addr);
+
+ my $intro = "$addr $func:";
+ my $padlen = 56 - length($intro);
+ while ($padlen > 0) {
+ $intro .= ' ';
+ $padlen -= 8;
+ }
+ (my $code = $line) =~ s/$re/\1/;
+
+ $stack[@stack] = "$intro $code";
+ }
+}
+
+@sortedstack = sort bysize @stack;
+
+foreach $i (@sortedstack) {
+ print("$i");
+}
\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.027 / U:0.980 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site