Re: Happy new year, and some questions

Paul Chen (chen@geoworks.com)
Thu, 2 Jan 1997 10:39:22 -0800 (PST)

GWRepNate writes:
> In a message dated 97-01-01 16:17:25 EST, diel@intbuso.boeblingen.netsurf.de
> writes:
> > Nevertheless, work goes on and I have a new set of questions:
> >
> > Q2: Is there a similar way to determine the exact amount of stack space
> > required ?
>
> No easy method that I know of. The reason it's difficult is that Swat has
> no way of knowing how deep your subroutine calls will get, or if functions
> are recursive. Also, local variables are usually stored on the stack and Swat
> would have to take that into consideration as well.

True, Swat cannot tell you your maximum stack usage. But you can check
your stack usage by using the Swat "backtrace" command. The -r flag to
bt tells Swat to print out the contents of a particular register for each
entry in the backtrace. Hence, you can use the following command at
those places in your code where you think you may be using a lot of stack
space (e.g., deeply nested routine/message calls, or passing large
parameters to routines):

[myApp:0] 37 => bt -rsp

to print out the stack pointer along with your backtrace. This will
show how your stack is used.

This information is also available in the Geoworks Knowledge Database,
which you can find on the Geoworks Web site: www.geoworks.com, click on
Developer Relations --> Technical Support --> Knowledge Base. You can
search the database for keywords and view relevant articles, or you can
browse the entire database.

pc