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

Debug is a JQt GUI for the debug foreign conjunction, available from J803. After Debug is turned on, then if execution is halted because of a stop or execution error, the Debug window shows the current execution environment.

Panels in the Debug window show the code being executed, the stack, and values of various names:

  • any watch names
  • the arguments of the current definition
  • any names on the current line of code

For an introduction to Debug, see the Debug lab. For information on the debug foreign conjunction, see the Dictionary entry for the 13!:x family. In addition to the Debug GUI, several debug verbs are defined in the standard library, see the debug script.

Live Debugging

When you are in development and expect errors, you should run with Debug active. Use menu Run|Debug..., or press Ctrl-K when the J session has focus.

This displays the Debug window and enables suspension (dbr 1).

Then run your program. If execution is suspended because of a stop or execution error, the execution state is shown in the Debug window. You can probe the system state, or use the several commands that let you step through the execution session.

To turn Debug off and disable suspension, close the Debug window.

Postmortem Debugging

If you encounter an error when debugging is inactive, you will be prompted to enter postmortem debugging. Press ENTER at the prompt. During postmortem debugging you can probe the system state, but the suspension commands are unavailable.

Postmortem debugging makes debugging active and freezes the resources that were used during execution of the failing sentence. To return to normal operation execute

   dbr 0

Debug Settings

The Debug window is displayed when Debug is activated, so this provides a visual indication that Debug is active.

However, if you disable suspension directly, for example by entering:

   dbr 0

then Debug will no longer be active, even if the Debug window is still displayed. You can reactivate Debug by pressing Ctrl-K.