SCI Kernel Documentation/Debugging Functions
Author: Jeff Stephenson
- 1 Debugging Functions
- 1.1 (SetDebug)
- 1.2 (InspectObj object)
- 1.3 (ShowSends)
- 1.4 (ShowObjs withID)
- 1.5 (ShowFree)
- 1.6 (MemoryInfo LargestPtr)
- 1.7 (MemoryInfo LargestHandle)
- 1.8 (MemoryInfo FreeHeap)
- 1.9 (MemoryInfo FreeHunk)
- 1.10 (StackUsage MStackSize)
- 1.11 (StackUsage MStackMax)
- 1.12 (StackUsage MStackCur)
- 1.13 (StackUsage PStackSize)
- 1.14 (StackUsage PStackMax)
- 1.15 (StackUsage PStackCur)
There a number of functions designed for debugging Script programs by providing information about the state of the program.
Pop up the debugging window. At the top of the window, in red, is the name (if any) of the object self. Below it is the op-code about to be executed. In columns on the right side of the window are the top five values on the stack and the top five parameters. On the left are the contents of the accumulator (acc), the address of the next instruction (the instruction pointer, or ip), and the address of the top of the stack (the stack pointer, or sp).
A number of instructions may be issued while in the debugger (Note that the debugger is case-sensitive, ie. Q != q):
<shft><shft>-Z Put the debugging window away. This also can be used to pop the debugging window up while the program is running. q Quit. Exit to DOS. Using <shft><shft>- to pop up the debugger and q to quit will generally get you out of the program even if your code is broken. s Toggle the send stack on/off. Enter Step to the next instruction, tracing into the procedure or method referenced by a call or send instruction. Tab Step to the next instruction treating a call or a send as an indivisible instruction (don't trace into them). tn Display the value of temporary variable number n. ln Display the value of local variable number n. gn Display the value of global variable number n. i Open an inspector window, allowing you to inspect the values of the properties of objects. See InspectObj below. o Look at all objects. O Look at all objects with their hex addresses given. The actual address to inspect is <addr>+$0006. a Look at object in the accumulator. c Look at current object on top of send stack.
Open an inspector window on object. This displays the property names and values for the object. Typing 'i' when this is displayed prompts for a property name, whose value will be displayed either as a number, string, or another object depending on what it is. If another object, 'i' can be typed again to inspect its properties, and so on until the interpreter runs out of stack.
Show the current send stack. This allows you to see how you got where you are. Entries in the display are of the form (object selector:) where object is the object to which a message whose selector was selector: was sent. The top line in the display is the most recent send, the line below that is the send to the method which made that send, and so on to the bottom line, which is the initial send from the main loop in the base script.
Display all static and dynamic objects which are currently in the heap. If withID is TRUE, show the object IDs as well.
Displays the free memory blocks in the heap in the form number-of-bytes@address.
Returns the size (in bytes) of the largest block of memory available in the heap.
Return the size (in bytes) of the largest hunk available in hunk space. If the largest available hunk is greater than 64K, returns 64K.
Return the amount of memory (in bytes) which is free in the heap.
Return the amount of memory (in paragraphs, or 16 byte blocks) which is free in hunk space.
Return the stack size of the PMachine stack.
Return the maximum stack size reached so far of the PMachine stack.
Return the current stack size of the PMachine stack.
Return the stack size of the Processor stack.
Return the maximum stack size reached so far of the Processor stack.
Return the current stack size of the Processor stack.