StackMon v1.3 ------------- © 1993-94 David Kinder ---------------------- Introduction ------------ StackMon is a small utility to help programmers (and other users). Amiga programs use their stack (a special area of memory) to store temporary addresses, data, etc. The default stack is 4096 bytes, but this may not be enough; some compilers can require over 100Kb. The stack size for a shell is set by the 'stack' command. For a program run from Workbench, the size is given in the icon; use the Workbench 'Information' option to examine this value. Use --- StackMon requires AmigaDOS 2.04 or higher. There are no startup options; just run StackMon from a shell or click on its icon. When run StackMon presents a list of all the tasks and processes currently running. The list is sorted alphabetically, with processes before tasks. This list is not updated automatically, as constructing this list requires suspension of multitasking. If you run a program you want to monitor after starting StackMon, click on the 'Update list' gadget so that it appears in the list. If the program you want to monitor was run from the Workbench, its name will be that of the icon; if run from the shell the name is the exact name typed into the shell, with path. Click on the program you wish to monitor and StackMon will begin monitoring. The display consists of numbers and a fuel gauge showing the current stack use relative to the size of the stack. The numbers are: Current: This is the amount of stack in use when the program was last monitored. Largest: The largest recorded stack ever in use by this program. Stack : The stack allocated for this program. You can also tell StackMon which program to monitor by entering its name in the string gadget below the task list. The name entered must be EXACTLY that of the program, i.e. if the program is to be started with 1> work:drawer/program You must type 'work:drawer/program' into the gadget, making sure that the case of all characters matches. If the program is not found, StackMon will periodically search the task list for the program. If the program appears, monitoring will begin. In this way StackMon can be used to monitor programs that only run for a short time before exiting. If the program terminates while being monitored, monitoring ceases, and the message 'Task not found' appears in the window. Monitoring of a program can also be stopped by clicking on the 'Stop' gadget. To change from monitoring one program to another, simply click on the other program's name in the list. If the program exceeds its allowed stack, the message 'Stack Overflow' will appear. Note that this behaviour by a program will make the system very unstable and a crash is probably imminent. When setting the stack for a program, always leave at least ~2Kb extra space, since DOS can also use this stack and future versions of DOS may use more stack. Caveat ------ StackMon takes a 'snapshot' of the stack use of a program, so a very sudden 'burst' of stack use may be missed. This is not very likely, however, as StackMon checks the program several times a second. Compiler -------- StackMon was written using Amiga E v2.1b, a freely distributable compiler. Note that E programs have their own stack managememt system, so StackMon is not useful with these programs. However, E programs do not appear to ever have stack overflow problems, as the compiler estimates the stack required at compile time. History ------- v1.0 First release. v1.1 Renamed 'Cancel' gadget to 'Stop'. Task list is now sorted alphabetically. Added string gadget to allow user to type in name of program to be monitored. Removed Enforcer hits. (Thanks to Karsten Weiss for Enforcer testing and suggesting some improvements.) v1.2 String gadget is always active. StackMon now continually checks the maximum stack size so that stack swapping (as performed eg. by the shell) is monitored correctly. Routine to find task name improved. Impossible stack sizes (eg. negative) are replaced by '???'. v1.3 Handles being opened on a public screen. List gadget is now the correct size under AmigaDOS 3.1. Address ------- Bug reports, comments, etc. to: Internet email (prefered): kinder@teaching.physics.ox.ac.uk dkinder@vax.ox.ax.uk Post: David Kinder, 2, Clwtt Cottages, Bangor Rd., Gyfelia, Clwyd. LL13 0YL.