Edward Pilatowicz <edward.pilatowicz at sun.com> wrote: ED> iirc, at some point, someone had a tool which could look at a kernel ED> panic stack trace and tell you the stack usage of each frame. but that ED> is only for post mortem analysis. afaik we don't have any way of ED> getting this information from the compiler, and we don't have any tools ED> that can do assembly analysis to determine this information.
Here is a little script that does just that: ---------------------------------------------------------------------- #! /usr/bin/perl # # This program is useful in dealing with stack overflows. It shows stack # consumption by each function. # # Alexander Kolbasov <Alexander.Kolbasov at sun.com> # # The input to the script is the result of MDB $C function. # $stsize = 0; $lastfunc = ''; while (<>) { @foo=split; $addr=$foo[0]; $addr =~ s/^0+//g; $tmp=hex($addr); $func=$foo[1]; $func =~ s/\+.*$//; if ($last) { $stsize -= $size; if ($size > 0) { printf "+%8d: %8d: %s %s\n", $stsize, $size, $lastaddr, $lastfunc; } else { printf "-%8d: %8s %s %s\n", $stsize, "", $lastaddr, $lastfunc; } $size = $tmp - $last; } $last = $tmp; $lastaddr = $addr; $lastfunc = $func; } ----------------------------------------------------------------------