Skip to contentSkip to conversation

PATCH [0/2] - CHECKSTACK: sparc-stack-size and formatting

DISCUSSION Patrick Boettcher 3 participants 5 messages Nov 23, 2009 – Nov 30, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

I shamelessly stole the checkstack-script for a project of mine and now want to contribute what I changed:

1) CHECKSTACK: sparc: fix regex to match all stacksizes
2) CHECKSTACK: simplify text-formatting for displaying the stacksize

For 1): as there are no comments in the script as to why the regex was limiting the detection of stacksizes to less 300 bytes and if I understood it correctly, to a maximum of 1000, I simply removed it.

best regards,
--

Patrick Boettcher - Kernel Labs
http://www.kernellabs.com/

#1 lore raw

PATCH [1/2] - CHECKSTACK: sparc: fix regex to match all stacksize

----

tools/checkstack.pl +1 -1
index 14ee68e..e0af9c7 100755
@@ -97,7 +97,7 @@ my (@stack, $re, $dre, $x, $xs);
 		$re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
 	} elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
 		# f0019d10:       9d e3 bf 90     save  %sp, -112, %sp
-		$re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
+		$re = qr/.*save.*%sp, -(\d*), %sp/o;
 	} else {
 		print("wrong or unknown architecture \"$arch\"\n");
 		exit
#2 lore raw

PATCH [2/2] - CHECKSTACK: simplify text-formatting for displaying the stacksize

In reply to Patrick Boettcher

----

tools/checkstack.pl +3 -14
index e0af9c7..4fed8c7 100755
@@ -139,7 +139,7 @@ while (my $line = <STDIN>) {
 			$size += 0x80000000;
 			$size += 0x80000000;
 		}
-		next if ($size > 0x10000000);
+		next if ($size > 0x10000000) || ($size < 100);
 
 		next if $line !~ m/^($xs*)/;
 		my $addr = $1;
@@ -147,13 +147,7 @@ while (my $line = <STDIN>) {
 		$addr = "0x$addr";
 
 		my $intro = "$addr $func [$file]:";
-		my $padlen = 56 - length($intro);
-		while ($padlen > 0) {
-			$intro .= '	';
-			$padlen -= 8;
-		}
-		next if ($size < 100);
-		push @stack, "$intro$size\n";
+		push @stack, sprintf("%-64s %d\n", $intro, $size);
 	}
 	elsif (defined $dre && $line =~ m/$dre/) {
 		my $size = "Dynamic ($1)";
@@ -164,12 +158,7 @@ while (my $line = <STDIN>) {
 		$addr = "0x$addr";
 
 		my $intro = "$addr $func [$file]:";
-		my $padlen = 56 - length($intro);
-		while ($padlen > 0) {
-			$intro .= '	';
-			$padlen -= 8;
-		}
-		push @stack, "$intro$size\n";
+		push @stack, sprintf("%-64s %d\n", $intro, $size);
 	}
 }
 
#3 lore raw
In reply to Patrick Boettcher
Quoted 6 lines · Patrick Boettcher

Hi,

I shamelessly stole the checkstack-script for a project of mine and now want to contribute what I changed:

1) CHECKSTACK: sparc: fix regex to match all stacksizes

Please Cc sparc people for this, he should be David Miller, I think.

Quoted 5 lines

2) CHECKSTACK: simplify text-formatting for displaying the stacksize

For 1): as there are no comments in the script as to why the regex was limiting the detection of stacksizes to less 300 bytes and if I understood it correctly, to a maximum of 1000, I simply removed it.

Please don't do this, write your change log for each patch please.

Signature · 1 line
Live like a child, think like the god.
Acked-by
#4 lore raw
In reply to Patrick Boettcher

From: Patrick Boettcher <[email protected]>
Date: Mon, 23 Nov 2009 12:01:00 +0100 (CET)

Quoted 9 lines

I shamelessly stole the checkstack-script for a project of mine and now want to contribute what I changed:

1) CHECKSTACK: sparc: fix regex to match all stacksizes
2) CHECKSTACK: simplify text-formatting for displaying the stacksize

For 1): as there are no comments in the script as to why the regex was limiting the detection of stacksizes to less 300 bytes and if I understood it correctly, to a maximum of 1000, I simply removed it.

The limit is just an oversight as far as I can tell, your sparc regex fix looks fine to me, thanks!