Debug/Verbs

From J Wiki
Jump to navigation Jump to search
Overview   Commands   Stack   Stops   Watch   Verbs

Verbs

Debug is an addition to the definitions in script system\main\debug.ijs, which can be loaded as follows:

	load 'debug'

This script is loaded when you press Ctrl-K to run Debug.

The script defines:


dbg

turns Debug on (dbg 1) or off (dbg 0)

dblocals

displays local names on the stack

dbstack

displays the stack

dbstop

sets stops on all lines in a list of names

dbstopme

sets stops in current definition

dbstopnext

sets stop on next line of current definition


Verb dbg

To turn Debug on, enter:

   dbg 1        NB. same as Ctrl-K

To turn Debug off and disable suspension, enter:

   dbg 0        NB. same as closing Debug window

Verb dblocals

Displays local names on the stack, for example:

   dblocals''
+---+--------+
|jmp|+--+---+|
|   ||a |123||
|   |+--+---+|
|   ||y.|   ||
|   |+--+---+|
+---+--------+
|run|+--+-+  |
|   ||c |3|  |
|   |+--+-+  |
|   ||y.| |  |
|   |+--+-+  |
+---+--------+

Verb dbstack

Displays the current stack, for example:

   dbr 1
   plus=. +
   plus / 'abc'
      dbstack''
+----+--+--+--+-----+------+----+
|name|en|ln|nc|args |locals|susp|
+----+--+--+--+-----+------+----+
|plus|3 |0 |3 |+-+-+|      |*   |
|    |  |  |  ||b|c||      |    |
|    |  |  |  |+-+-+|      |    |
+----+--+--+--+-----+------+----+

Verb dbstop

This is a convenient way of setting stops on all lines in a list of names, for example:

   dbstop 'accpay intm vrep'

is equivalent to:

   dbss (dbsq''), ';accpay *:*;intm *:*;vrep *:*'

Using dbstop does not change any other stop settings, except that to clear all stops, enter:

   dbstop''

Verb dbstopme

This is a convenient way of setting stops on the current definition. If the argument is non-zero (with same meaning as the if. control word) and suspension is on, then all lines in the current definition are stopped, for example:

foo=: 3 : 0
dbstopme y.>2     NB. stop foo if y.>2
...
)

Using dbstopme does not change any other stop settings.

Verb dbstopnext

This sets a stop on the next line of the current definition. The argument is the same as for dbstopme.

Using dbstopnext does not change any other stop settings.