Debug/Stack
The Debug Stack
The debug stack is a record of the executions that led to the current state. It is shown in the Stack window of the debugger, which you can bring up by pressing the button to the right of the magnifying glass.
You can see the stack for yourself by executing dbstk''
Each line of the stack display shows the name of an executing entity, the line number it is executing, its arguments, and all the local names that are defined.
For tacit verbs the local names are omitted.
+------------------+--+--+--+--------+--------------+----+ |name |en|ln|nc|args |locals |susp| +------------------+--+--+--+--------+--------------+----+ |er |3 |0 |3 | |+-+---------+ |* | | | | | | ||y|0 1 2 3 4| | | | | | | | |+-+---------+ | | +------------------+--+--+--+--------+--------------+----+ |test |3 |1 |3 | |+--+---------+| | | | | | | ||iy|0 1 2 3 4|| | | | | | | |+--+---------+| | | | | | | ||y |5 || | | | | | | |+--+---------+| | +------------------+--+--+--+--------+--------------+----+
The columns are: name of entity; error number; line number; nameclass (3=verb); arguments; local names/values; suspension status.
Initial arguments are not available during postmortem debugging, but their values may still be defined as local names
Susp is '*' in the line of the entity that triggered the stop or error. If you got an error while you were debugging another error, each nested error starts with a suspension.
In the example above, verb test called verb er from line 1; line 0 of er failed with domain error.
Looking Into the Stack
While debugging, you can look into the private namespaces that were executing. You can even put the private names into sentences of your own. The top stack frame is numbered _1, the second _2, and so on. Stack-referencing indirect locatives cause the name to be looked up in the symbol table of the corresponding stack frame. In the debugging session shown above, you could have
iy___2 0 1 2 3 4
means 'a from the topmost stack frame'. Named indirect locatives can be used to the same effect if the value of the name is a negative integer.
Because stack-referencing indirect locatives refer to the debug stack, they are not available in normal J code.
Note: The commands you issue while debugging may themselves create stack frames. So that these stack frames will not interfere with the numbering of stack references, the numbers in stack-referencing indirect locatives are always relative to the topmost suspended frame.
Postmortem debugging
During postmortem debugging the arguments to the function are not available. You may look at the stack or refer to it with stack-referencing indirect locatives.